NTK 1.3.0
Fl_Image.H
1//
2// "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z 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; 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.
12//
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.
17//
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
21// USA.
22//
23// Please report all bugs and problems on the following page:
24//
25// http://www.fltk.org/str.php
26//
27
28/* \file
29 Fl_Image, Fl_RGB_Image classes . */
30
31#ifndef Fl_Image_H
32# define Fl_Image_H
33
34# include "Enumerations.H"
35
36class Fl_Widget;
37struct Fl_Menu_Item;
38struct Fl_Label;
39
51class FL_EXPORT Fl_Image {
52 int w_, h_, d_, ld_, count_;
53 const char * const *data_;
54
55 // Forbid use of copy contructor and assign operator
56 Fl_Image & operator=(const Fl_Image &);
57 Fl_Image(const Fl_Image &);
58
59 protected:
60
64 void w(int W) {w_ = W;}
68 void h(int H) {h_ = H;}
72 void d(int D) {d_ = D;}
76 void ld(int LD) {ld_ = LD;}
80 void data(const char * const *p, int c) {data_ = p; count_ = c;}
81 void draw_empty(int X, int Y);
82
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);
85
86 public:
87
91 int w() const {return w_;}
94 int h() const {return h_;}
100 int d() const {return d_;}
106 int ld() const {return ld_;}
113 int count() const {return count_;}
118 const char * const *data() const {return data_;}
119
126 Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
127 virtual ~Fl_Image();
128 virtual Fl_Image *copy(int W, int H);
136 Fl_Image *copy() { return copy(w(), h()); }
137 virtual void color_average(Fl_Color c, float 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);
155 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
160 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
161 virtual void uncache();
162};
163
175class 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;
179 friend class Fl_Cairo_Graphics_Driver;
180public:
181
182 const uchar *array;
183 int alloc_array; // Non-zero if array was allocated
184
185 private:
186
187#if defined(__APPLE__) || defined(WIN32)
188 void *id_; // for internal use
189 void *mask_; // for internal use (mask bitmap)
190#else
191 unsigned id_; // for internal use
192 unsigned mask_; // for internal use (mask bitmap)
193#endif // __APPLE__ || WIN32
194
195 public:
196
198 Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
199 Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
200 virtual ~Fl_RGB_Image();
201 virtual Fl_Image *copy(int W, int H);
202 Fl_Image *copy() { return copy(w(), h()); }
203 virtual void color_average(Fl_Color c, float i);
204 virtual void desaturate();
205 virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
206 void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
207 virtual void label(Fl_Widget*w);
208 virtual void label(Fl_Menu_Item*m);
209 virtual void uncache();
210};
211
212#endif // !Fl_Image_H
213
214//
215// End of "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z manolo $".
216//
This file contains type definitions and general enumerations.
unsigned Fl_Align
FLTK type for alignment control.
Definition Enumerations.H:658
unsigned int Fl_Color
an FLTK color value
Definition Enumerations.H:764
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition Fl_Image.H:51
int count() const
The count() method returns the number of data values associated with the image.
Definition Fl_Image.H:113
void d(int D)
Sets the current image depth.
Definition Fl_Image.H:72
void draw(int X, int Y)
Draws the image.
Definition Fl_Image.H:160
void data(const char *const *p, int c)
Sets the current array pointer and count of pointers in the array.
Definition Fl_Image.H:80
const char *const * data() const
Returns a pointer to the current image data array.
Definition Fl_Image.H:118
void h(int H)
Sets the current image height in pixels.
Definition Fl_Image.H:68
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:101
int w() const
Returns the current image width in pixels.
Definition Fl_Image.H:91
void ld(int LD)
Sets the current line data size in bytes.
Definition Fl_Image.H:76
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:126
Fl_Image * copy()
The copy() method creates a copy of the specified image.
Definition Fl_Image.H:136
void w(int W)
Sets the current image width in pixels.
Definition Fl_Image.H:64
int ld() const
Returns the current line data size in bytes.
Definition Fl_Image.H:106
void inactive()
The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appear...
Definition Fl_Image.H:144
int h() const
Returns the current image height in pixels.
Definition Fl_Image.H:94
int d() const
Returns the current image depth.
Definition Fl_Image.H:100
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:175
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:198
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:111
unsigned char uchar
unsigned char
Definition fl_types.h:39
This struct stores all information for a text or mixed graphics label.
Definition Fl_Widget.H:75
The Fl_Menu_Item structure defines a single menu item that is used by the Fl_Menu_ class.
Definition Fl_Menu_Item.H:118