2
// "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z manolo $"
4
// Image header file for the Fast Light Tool Kit (FLTK).
6
// Copyright 1998-2011 by Bill Spitzak and others.
8
// This library is free software; you can redistribute it and/or
9
// modify it under the terms of the GNU Library General Public
10
// License as published by the Free Software Foundation; either
11
// version 2 of the License, or (at your option) any later version.
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// Library General Public License for more details.
18
// You should have received a copy of the GNU Library General Public
19
// License along with this library; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
// Please report all bugs and problems on the following page:
25
// http://www.fltk.org/str.php
29
Fl_Image, Fl_RGB_Image classes . */
34
# include "Enumerations.H"
41
Fl_Image is the base class used for caching and
42
drawing all kinds of images in FLTK. This class keeps track of
43
common image data such as the pixels, colormap, width, height,
44
and depth. Virtual methods are used to provide type-specific
47
<P>Since the Fl_Image class does not support image
48
drawing by itself, calling the draw() method results in
49
a box with an X in it being drawn instead.
51
class FL_EXPORT Fl_Image {
52
int w_, h_, d_, ld_, count_;
53
const char * const *data_;
55
// Forbid use of copy contructor and assign operator
56
Fl_Image & operator=(const Fl_Image &);
57
Fl_Image(const Fl_Image &);
62
Sets the current image width in pixels.
64
void w(int W) {w_ = W;}
66
Sets the current image height in pixels.
68
void h(int H) {h_ = H;}
70
Sets the current image depth.
72
void d(int D) {d_ = D;}
74
Sets the current line data size in bytes.
76
void ld(int LD) {ld_ = LD;}
78
Sets the current array pointer and count of pointers in the array.
80
void data(const char * const *p, int c) {data_ = p; count_ = c;}
81
void draw_empty(int X, int Y);
83
static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
84
static void measure(const Fl_Label *lo, int &lw, int &lh);
89
Returns the current image width in pixels.
91
int w() const {return w_;}
92
/** Returns the current image height in pixels.
94
int h() const {return h_;}
96
Returns the current image depth.
97
The return value will be 0 for bitmaps, 1 for
98
pixmaps, and 1 to 4 for color images.</P>
100
int d() const {return d_;}
102
Returns the current line data size in bytes.
103
Line data is extra data that is included
104
after each line of color image data and is normally not present.
106
int ld() const {return ld_;}
108
The count() method returns the number of data values
109
associated with the image. The value will be 0 for images with
110
no associated data, 1 for bitmap and color images, and greater
111
than 2 for pixmap images.
113
int count() const {return count_;}
115
Returns a pointer to the current image data array.
116
Use the count() method to find the size of the data array.
118
const char * const *data() const {return data_;}
121
The constructor creates an empty image with the specified
122
width, height, and depth. The width and height are in pixels.
123
The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and
124
1 to 4 for color images.
126
Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
128
virtual Fl_Image *copy(int W, int H);
130
The copy() method creates a copy of the specified
131
image. If the width and height are provided, the image is
132
resized to the specified size. The image should be deleted (or in
133
the case of Fl_Shared_Image, released) when you are done
136
Fl_Image *copy() { return copy(w(), h()); }
137
virtual void color_average(Fl_Color c, float i);
139
The inactive() method calls
140
color_average(FL_BACKGROUND_COLOR, 0.33f) to produce
141
an image that appears grayed out. <I>This method does not
142
alter the original image data.</I>
144
void inactive() { color_average(FL_GRAY, .33f); }
145
virtual void desaturate();
146
virtual void label(Fl_Widget*w);
147
virtual void label(Fl_Menu_Item*m);
149
Draws the image with a bounding box.
151
a bounding box for the image, with the origin
152
(upper-lefthand corner) of the image offset by the cx
155
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
158
This form specifies the upper-lefthand corner of the image.
160
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
161
virtual void uncache();
165
The Fl_RGB_Image class supports caching and drawing
166
of full-color images with 1 to 4 channels of color information.
167
Images with an even number of channels are assumed to contain
168
alpha information, which is used to blend the image with the
169
contents of the screen.</P>
171
<P>Fl_RGB_Image is defined in
172
<FL/Fl_Image.H>, however for compatibility reasons
173
<FL/Fl_RGB_Image.H> should be included.
175
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
176
friend class Fl_Quartz_Graphics_Driver;
177
friend class Fl_GDI_Graphics_Driver;
178
friend class Fl_Xlib_Graphics_Driver;
182
int alloc_array; // Non-zero if array was allocated
186
#if defined(__APPLE__) || defined(WIN32)
187
void *id_; // for internal use
188
void *mask_; // for internal use (mask bitmap)
190
unsigned id_; // for internal use
191
unsigned mask_; // for internal use (mask bitmap)
192
#endif // __APPLE__ || WIN32
196
/** The constructor creates a new image from the specified data. */
197
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
198
Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
199
virtual ~Fl_RGB_Image();
200
virtual Fl_Image *copy(int W, int H);
201
Fl_Image *copy() { return copy(w(), h()); }
202
virtual void color_average(Fl_Color c, float i);
203
virtual void desaturate();
204
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
205
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
206
virtual void label(Fl_Widget*w);
207
virtual void label(Fl_Menu_Item*m);
208
virtual void uncache();
211
#endif // !Fl_Image_H
214
// End of "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z manolo $".