FLTK 1.3.3
Fl_Image.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_Image.H 10379 2014-10-14 13:32:59Z AlbrechtS $"
3 //
4 // Image header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2014 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 
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 
39 };
40 
52 class FL_EXPORT Fl_Image {
53  int w_, h_, d_, ld_, count_;
54  const char * const *data_;
55  static Fl_RGB_Scaling RGB_scaling_;
56 
57  // Forbid use of copy constructor and assign operator
58  Fl_Image & operator=(const Fl_Image &);
59  Fl_Image(const Fl_Image &);
60 
61  protected:
62 
66  void w(int W) {w_ = W;}
70  void h(int H) {h_ = H;}
74  void d(int D) {d_ = D;}
78  void ld(int LD) {ld_ = LD;}
82  void data(const char * const *p, int c) {data_ = p; count_ = c;}
83  void draw_empty(int X, int Y);
84 
85  static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
86  static void measure(const Fl_Label *lo, int &lw, int &lh);
87 
88  public:
89 
93  int w() const {return w_;}
96  int h() const {return h_;}
102  int d() const {return d_;}
108  int ld() const {return ld_;}
115  int count() const {return count_;}
120  const char * const *data() const {return data_;}
121 
128  Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
129  virtual ~Fl_Image();
130  virtual Fl_Image *copy(int W, int H);
138  Fl_Image *copy() { return copy(w(), h()); }
139  virtual void color_average(Fl_Color c, float i);
146  void inactive() { color_average(FL_GRAY, .33f); }
147  virtual void desaturate();
148  virtual void label(Fl_Widget*w);
149  virtual void label(Fl_Menu_Item*m);
157  virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
162  void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
163  virtual void uncache();
164 
165  // set RGB image scaling method
166  static void RGB_scaling(Fl_RGB_Scaling);
167 
168  // get RGB image scaling method
169  static Fl_RGB_Scaling RGB_scaling();
170 };
171 
183 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
184  friend class Fl_Quartz_Graphics_Driver;
185  friend class Fl_GDI_Graphics_Driver;
186  friend class Fl_Xlib_Graphics_Driver;
187  static size_t max_size_;
188 public:
189 
190  const uchar *array;
191  int alloc_array; // Non-zero if array was allocated
192 
193  private:
194 
195 #if defined(__APPLE__) || defined(WIN32)
196  void *id_; // for internal use
197  void *mask_; // for internal use (mask bitmap)
198 #else
199  unsigned id_; // for internal use
200  unsigned mask_; // for internal use (mask bitmap)
201 #endif // __APPLE__ || WIN32
202 
203  public:
204 
220  Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
221  Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
222  Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
223  virtual ~Fl_RGB_Image();
224  virtual Fl_Image *copy(int W, int H);
225  Fl_Image *copy() { return copy(w(), h()); }
226  virtual void color_average(Fl_Color c, float i);
227  virtual void desaturate();
228  virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
229  void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
230  virtual void label(Fl_Widget*w);
231  virtual void label(Fl_Menu_Item*m);
232  virtual void uncache();
242  static void max_size(size_t size) { max_size_ = size;}
247  static size_t max_size() {return max_size_;}
248 };
249 
250 #endif // !Fl_Image_H
251 
252 //
253 // End of "$Id: Fl_Image.H 10379 2014-10-14 13:32:59Z AlbrechtS $".
254 //
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
void d(int D)
Sets the current image depth.
Definition: Fl_Image.H:74
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:128
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition: Fl_Image.cxx:101
default RGB image scaling algorithm
Definition: Fl_Image.H:37
The Fl_Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency...
Definition: Fl_Pixmap.H:41
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:111
void ld(int LD)
Sets the current line data size in bytes.
Definition: Fl_Image.H:78
Fl_Fontsize size()
see fl_size().
Definition: Fl_Device.H:383
The Mac OS X-specific graphics class.
Definition: Fl_Device.H:410
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:220
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition: Fl_Image.H:52
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:183
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:54
more accurate, but slower RGB image scaling algorithm
Definition: Fl_Image.H:38
static size_t max_size()
Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
Definition: Fl_Image.H:247
void inactive()
The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appear...
Definition: Fl_Image.H:146
This file contains type definitions and general enumerations.
Fl_Image * copy()
The copy() method creates a copy of the specified image.
Definition: Fl_Image.H:138
The Xlib-specific graphics class.
Definition: Fl_Device.H:494
void w(int W)
Sets the current image width in pixels.
Definition: Fl_Image.H:66
const char *const * data() const
Returns a pointer to the current image data array.
Definition: Fl_Image.H:120
This struct stores all information for a text or mixed graphics label.
Definition: Fl_Widget.H:64
void h(int H)
Sets the current image height in pixels.
Definition: Fl_Image.H:70
int ld() const
Returns the current line data size in bytes.
Definition: Fl_Image.H:108
int d() const
Returns the current image depth.
Definition: Fl_Image.H:102
The Fl_Menu_Item structure defines a single menu item that is used by the Fl_Menu_ class...
Definition: Fl_Menu_Item.H:109
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:92
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
unsigned Fl_Align
FLTK type for alignment control.
Definition: Enumerations.H:690
void data(const char *const *p, int c)
Sets the current array pointer and count of pointers in the array.
Definition: Fl_Image.H:82
int w() const
Returns the current image width in pixels.
Definition: Fl_Image.H:93
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:242
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition: Fl_Image.cxx:51
int h() const
Returns the current image height in pixels.
Definition: Fl_Image.H:96
int count() const
The count() method returns the number of data values associated with the image.
Definition: Fl_Image.H:115
The MSWindows-specific graphics class.
Definition: Fl_Device.H:447
void draw(int X, int Y)
Draws the image.
Definition: Fl_Image.H:162
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_RGB_Scaling
The scaling algorithm to use for RGB images.
Definition: Fl_Image.H:36