FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Image.H
1 //
2 // "$Id: Fl_Image.H 9709 2012-11-09 16:02:08Z manolo $"
3 //
4 // Image header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 /* \file
20 Fl_Image, Fl_RGB_Image classes . */
21
22 #ifndef Fl_Image_H
23 # define Fl_Image_H
24
25 # include "Enumerations.H"
26 #include <stdlib.h>
27
28 class Fl_Widget;
29 class Fl_Pixmap;
30 struct Fl_Menu_Item;
31 struct Fl_Label;
32
44 class FL_EXPORT Fl_Image {
45 int w_, h_, d_, ld_, count_;
46 const char * const *data_;
47
48 // Forbid use of copy contructor and assign operator
49 Fl_Image & operator=(const Fl_Image &);
50 Fl_Image(const Fl_Image &);
51
52 protected:
53
57 void w(int W) {w_ = W;}
61 void h(int H) {h_ = H;}
65 void d(int D) {d_ = D;}
69 void ld(int LD) {ld_ = LD;}
73 void data(const char * const *p, int c) {data_ = p; count_ = c;}
74 void draw_empty(int X, int Y);
75
76 static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
77 static void measure(const Fl_Label *lo, int &lw, int &lh);
78
79 public:
80
84 int w() const {return w_;}
87 int h() const {return h_;}
93 int d() const {return d_;}
99 int ld() const {return ld_;}
106 int count() const {return count_;}
111 const char * const *data() const {return data_;}
112
119 Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
120 virtual ~Fl_Image();
121 virtual Fl_Image *copy(int W, int H);
129 Fl_Image *copy() { return copy(w(), h()); }
130 virtual void color_average(Fl_Color c, float i);
137 void inactive() { color_average(FL_GRAY, .33f); }
138 virtual void desaturate();
139 virtual void label(Fl_Widget*w);
140 virtual void label(Fl_Menu_Item*m);
148 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
153 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
154 virtual void uncache();
155 };
156
168 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
169 friend class Fl_Quartz_Graphics_Driver;
170 friend class Fl_GDI_Graphics_Driver;
171 friend class Fl_Xlib_Graphics_Driver;
172 static size_t max_size_;
173 public:
174
175 const uchar *array;
176 int alloc_array; // Non-zero if array was allocated
177
178 private:
179
180 #if defined(__APPLE__) || defined(WIN32)
181 void *id_; // for internal use
182 void *mask_; // for internal use (mask bitmap)
183 #else
184 unsigned id_; // for internal use
185 unsigned mask_; // for internal use (mask bitmap)
186 #endif // __APPLE__ || WIN32
187
188 public:
189
205 Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
206 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
207 Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
208 virtual ~Fl_RGB_Image();
209 virtual Fl_Image *copy(int W, int H);
210 Fl_Image *copy() { return copy(w(), h()); }
211 virtual void color_average(Fl_Color c, float i);
212 virtual void desaturate();
213 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
214 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
215 virtual void label(Fl_Widget*w);
216 virtual void label(Fl_Menu_Item*m);
217 virtual void uncache();
227 static void max_size(size_t size) { max_size_ = size;}
232 static size_t max_size() {return max_size_;}
233 };
234
235 #endif // !Fl_Image_H
236
237 //
238 // End of "$Id: Fl_Image.H 9709 2012-11-09 16:02:08Z manolo $".
239 //
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
Fl_Image::d
void d(int D)
Sets the current image depth.
Definition: Fl_Image.H:65
Fl_Image::Fl_Image
Fl_Image(int W, int H, int D)
The constructor creates an empty image with the specified width, height, and depth.
Definition: Fl_Image.H:119
Fl_Image::desaturate
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition: Fl_Image.cxx:99
Fl_Pixmap
The Fl_Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency...
Definition: Fl_Pixmap.H:41
Fl_Image::label
virtual void label(Fl_Widget *w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item...
Definition: Fl_Image.cxx:109
Fl_Image::ld
void ld(int LD)
Sets the current line data size in bytes.
Definition: Fl_Image.H:69
Fl_Graphics_Driver::size
Fl_Fontsize size()
see fl_size().
Definition: Fl_Device.H:383
Fl_Quartz_Graphics_Driver
The Mac OS X-specific graphics class.
Definition: Fl_Device.H:410
Fl_RGB_Image::Fl_RGB_Image
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0)
The constructor creates a new image from the specified data.
Definition: Fl_Image.H:205
Fl_Image
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition: Fl_Image.H:44
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:168
Fl_Image::draw
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
Definition: Fl_Image.cxx:52
Fl_RGB_Image::max_size
static size_t max_size()
Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
Definition: Fl_Image.H:232
Fl_Image::inactive
void inactive()
The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appear...
Definition: Fl_Image.H:137
Enumerations.H
This file contains type definitions and general enumerations.
Fl_Image::copy
Fl_Image * copy()
The copy() method creates a copy of the specified image.
Definition: Fl_Image.H:129
Fl_Xlib_Graphics_Driver
The Xlib-specific graphics class.
Definition: Fl_Device.H:493
Fl_Image::w
void w(int W)
Sets the current image width in pixels.
Definition: Fl_Image.H:57
Fl_Image::data
const char *const * data() const
Returns a pointer to the current image data array.
Definition: Fl_Image.H:111
Fl_Label
This struct stores all information for a text or mixed graphics label.
Definition: Fl_Widget.H:64
Fl_Image::h
void h(int H)
Sets the current image height in pixels.
Definition: Fl_Image.H:61
Fl_Image::ld
int ld() const
Returns the current line data size in bytes.
Definition: Fl_Image.H:99
Fl_Image::d
int d() const
Returns the current image depth.
Definition: Fl_Image.H:93
Fl_Image::color_average
virtual void color_average(Fl_Color c, float i)
The color_average() method averages the colors in the image with the FLTK color value c...
Definition: Fl_Image.cxx:90
Fl_Color
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:774
Fl_Align
unsigned Fl_Align
FLTK type for alignment control.
Definition: Enumerations.H:668
Fl_Image::data
void data(const char *const *p, int c)
Sets the current array pointer and count of pointers in the array.
Definition: Fl_Image.H:73
Fl_Image::w
int w() const
Returns the current image width in pixels.
Definition: Fl_Image.H:84
Fl_RGB_Image::max_size
static void max_size(size_t size)
Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
Definition: Fl_Image.H:227
Fl_Image::uncache
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition: Fl_Image.cxx:49
Fl_Image::h
int h() const
Returns the current image height in pixels.
Definition: Fl_Image.H:87
Fl_Image::count
int count() const
The count() method returns the number of data values associated with the image.
Definition: Fl_Image.H:106
Fl_GDI_Graphics_Driver
The MSWindows-specific graphics class.
Definition: Fl_Device.H:447
Fl_Image::draw
void draw(int X, int Y)
Draws the image.
Definition: Fl_Image.H:153
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
- © 1998-2012 by Bill Spitzak and others.