class Fl_Image
This class holds an image, normally used to label a widget. The
subclasses define how the data is interpreted, and usually store
server-side cached versions of the image. All the current types
define pixel arrays, but other types of images, such as vector
graphics, can be defined.
Methods
ulong id, mask;
void _draw(int X, int Y, int W, int H, int cx, int cy);
Subclasses may use these protected members of the base class to
draw a cached pixel array. They must first set id and
mask to the color and transparency offscreen windows, using
system-specific code. Then they can call _draw() to draw
them.
int w,h
These members hold the width and height of the image. They are not
correct until measure() is called. These are public instance
variables for back comptability, but you should never set them.
virtual void Fl_Image::measure(int W, int H);
Measure how big the image will be if it is drawn inside a W,H
rectangle and put the result into w,h. For most image types this does
nothing and w,h are set by the constructor. This may be used to
initialize the scaling for variable-sized images.
virtual void Fl_Image::draw(int x,int y,int w,int h, int cx,int
cy);
Draw the image so the point cx,cy of the image is at
x,y. The image may be scaled or clipped to fit in the w,h
rectangle, but this is not necessary (although obeying the current
fl_clip value is!).
void Fl_Image::draw(int x,int y,int w,int h, Fl_Flags align);
This non-virtual function uses measure() and the
align flags to figure out cx,cy and call the normal draw
function. This allows you to center or align any edge of the image
with a bounding box.
virtual Fl_Image::~Fl_Image();
The destructor throws away any server-cached information, but in most
cases does not destroy the local data passed to a constructor.
This object encapsulates the width, height, and bits of an X bitmap
(XBM), and allows you to make an Fl_Widget use a bitmap as a
label, or to just draw the bitmap directly.
Fl_Bitmap(const char *bits, int W, int H)
Fl_Bitmap(const uchar *bits, int W, int H)
Construct using an X bitmap. The bits pointer is simply copied to the
object, so it must point at persistent storage. The two constructors
are provided because various X implementations disagree about the type
of bitmap data. To use an XBM file use:
#include "foo.xbm"
...
Fl_Bitmap bitmap = new Fl_Bitmap(foo_bits, foo_width, foo_height);
~Fl_Bitmap()
The destructor will destroy any X pixmap created. It does not do
anything to the bits data.
void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)
1 bits are drawn with the current color, 0 bits
are unchanged.
The image is clipped to the destination rectangle: the area
ox,oy,w,h is copied to x,y,w,h.
void draw(int x, int y)
Draws the bitmap with the upper-left corner at x,y. This is
the same as doing draw(x,y,this->w,this->h,0,0).
This object encapsulates the data from an XPM image, and allows you to
make an Fl_Widget use a pixmap as a label, or to just draw
the pixmap directly.
Fl_Pixmap(char *const* data)
Construct using XPM data. The data pointer is simply copied to the
object, so it must point at persistent storage. To use an XPM file do:
#include <fltk/Fl_Pixmap.h>
#include "foo.xpm"
...
Fl_Pixmap pixmap = new Fl_Pixmap(foo);
~Fl_Pixmap()
The destructor will destroy any X pixmap created. It does not do
anything to the data.
void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)
The image is clipped to the destination rectangle: the area
ox,oy,w,h is copied to x,y,w,h. The current
implementation converts the pixmap to 24-bit RGB data and uses fl_draw_image() to draw it. Thus you
will get dithered colors on an 8 bit screen.
void draw(int x, int y)
Draws the image with the upper-left corner at x,y. This is
the same as doing draw(x,y,this->w,this->h,0,0).
This object encapsulates a full-color RGB image, and allows you to
make an Fl_Widget use an image as a label, or to just draw the
image directly.
Fl_RGB_Image(const uchar *data, int W, int H, int D = 3, int LD = 0)
Construct using a pointer to RGB data. W and H are
the size of the image in pixels. D is the delta between pixels
(it may be more than 3 to skip alpha or other data, or negative to flip
the image left/right). LD is the delta between lines (it may
be more than D * W to crop images, or negative to flip the
image vertically). The data pointer is simply copied to the object, so
it must point at persistent storage.
~Fl_RGB_Image()
The destructor will destroy any X pixmap created. It does not do
anything to the data.
void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)
The image is clipped to the destination rectangle: the area
ox,oy,w,h is copied to x,y,w,h.
void draw(int x, int y)
Draws the image with the upper-left corner at x,y. This is
the same as doing draw(x,y,this->w,this->h,0,0).