It is undefined whether the location or drawing of the image is affected by the current transformation, so you should only call these when it is the identity.
All untyped arguments are integers.
void fl_draw_bitmap(const uchar*, X, Y, W, H, LD = 0);
void fl_draw_image(const uchar*, X, Y, W, H, D = 3, LD = 0);
void fl_draw_image_mono(const uchar*, X, Y, W, H, D = 1, LD = 0);
It is highly recommended that you put the following code before the first show() of any window in your program to get rid of the dithering if possible:
Fl::visual(FL_RGB)
Gray scale (1-channel) images may be drawn. This is done if abs(D)
is less than 3, or by calling fl_draw_image_mono
. Only
one 8-bit sample is used for each pixel, and (on screens with
different numbers of bits for red, green, and blue) only gray colors
are used. Setting D greater than 1 will let you display one channel
of a color image.
The X version does not support all possible visuals. If fltk cannot draw the image in the current visual it will abort. Fltk supports any visual of 8 bits or less, and all common TrueColor visuals up to 32 bits.
typedef void (*fl_draw_image_cb)(void*, x, y, w, uchar*);
void fl_draw_image(fl_draw_image_cb, void*, X, Y, W, H, D = 3);
void fl_draw_image_mono(fl_draw_image_cb, void*, X, Y, W, H, D = 1);
The callback is called with the void* user data pointer (this can be used to point at a structure of information about the image), and the x, y, and w of the scan line desired from the image. 0,0 is the upper-left corner (not X,Y). A pointer to a buffer to put the data into is passed. You must copy w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire W*D pixels, this is for convienence with some decompression schemes where you must decompress the entire line at once: decompress it into the buffer, and then if x is not zero, memcpy the data over so the x'th pixel is at the start of the buffer.
You can assumme the y's will be consecutive, except the first one may be greater than zero.
If D is 4 or more, you must fill in the unused bytes with zero.
int fl_draw_pixmap(char** data, X, Y, Fl_Color=FL_GRAY);
To use an XPM, do "#include "foo.xpm"
" and then
"fl_draw_pixmap(foo, X, Y)
".
In the current version the XPM data is converted to 8-bit full color and passed through fl_draw_image(). This is obviously not the most efficient way to do it, and has the same visual limitations as listed above for fl_draw_image(). Transparent colors are replaced by the optional Fl_Color argument (this may change in the future).
Fltk supports some (questionable) enhancements to the XPM format.
int fl_measure_pixmap(char** data, int &w, int
&h);
Fl_Bitmap(const char *bits, int W, int H);
Fl_Bitmap(const uchar *bits, int W, int H);
#include "foo.xbm"
, and then do "new
Fl_Bitmap(foo_bits,foo_width,foo_height)
"
~Fl_Bitmap()
void draw(int x, int y, int w, int h, int ox=0, int oy=0);
void draw(int x, int y);
draw(x,y,this->w,this->h,0,0)
.
void label(Fl_Widget *);
The current implementation converts the pixmap to 8 bit color data and uses fl_draw_image() to draw it. Thus you will get dithered colors on an 8 bit screen.
Fl_Pixmap(char * const * data);
#include "foo.xpm"
, and then do "new
Fl_Pixmap(foo)
"
~Fl_Pixmap()
void draw(int x, int y, int w, int h, int ox=0, int oy=0);
void draw(int x, int y);
draw(x,y,this->w,this->h,0,0)
.
void label(Fl_Widget *);
See fl_draw_image() for what happens. On 8 bit screens dithering is used.
Fl_Image(char uchar *data, int W, int H, int D=3, int LD=0);
~Fl_Image()
void draw(int x, int y, int w, int h, int ox=0, int oy=0);
void draw(int x, int y);
draw(x,y,this->w,this->h,0,0)
.
void label(Fl_Widget *);