Paul R schrieb:
> Hi All,
>
> Previously when using the image as backdrop feature I have assigned
> the image in my FLUID UI design. My problem now is that I need to
> create an array of buttons on the fly, and i need to assign an image
> overlay in my own code.

> static unsigned char idata_pill[] =

You need to know about format of "xpm" images - they are stored as ASCII 
text and you can insert this text into a header file, to get the image 
data. When you save an image als ".xpm" and open it with a text editor, 
it is easy to see, how to use it. There is something like
"static const char * const pXPM_Pic[] = {...}" and you can use this 
pointer directly. Maybe there is less "const", but you should add it, to 
get rid of compiler warnings.

For further usage see this code, showing a logo out of xpm:

"Fl_Logo.h"
------------------------------------------
#ifndef FL_LOGO_H
#define FL_LOGO_H

#include <FL/Fl_Box.H>

class Fl_Pixmap;

class Fl_Logo: public Fl_Box
{
        public:
                Fl_Logo(int x, int y, int w, int h, const char* l= 0);
                virtual ~Fl_Logo();

        private:
                Fl_Pixmap*      mp_Pic;

                virtual void draw();
};
#endif
------------------------------------------
"Fl_Logo.cpp"

#include <Fl/fl_draw.H>
#include <FL/Fl_Pixmap.H>
#include "logo_cms.h"   // xpm-data

#include "Fl_Logo.h"

//=============================================================================
Fl_Logo::Fl_Logo(int x, int y, int w, int h, const char* l):
        Fl_Box(x, y, w, h, l),
        mp_Pic(new Fl_Pixmap(pLogo_CMS))
{}
//-----------------------------------------------------------------------------
Fl_Logo::~Fl_Logo()
{
        delete mp_Pic;
}
//-----------------------------------------------------------------------------
void Fl_Logo::draw()
{
        Fl_Box::draw();
        if (mp_Pic && mp_Pic->w())
        {
                int nw= w();
                int nh= h();
                double f1= double(h())/double(w());
                double f2= double(mp_Pic->h())/ double(mp_Pic->w());
                if (f1 > f2)
                {       // adjust bitmap regarding to height
                        nh= int((mp_Pic->h() *w())/mp_Pic->w());                
        }
                else
                {       // adjust bitmap regarding to width
                        nw= int((mp_Pic->w() *h())/ mp_Pic->h());               
        }
                Fl_Image* Scale= mp_Pic->copy(nw, nh);

                Scale->draw(x(), y(), w(), h());
                delete Scale;
        }
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to