1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Image header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2011-01-30 12:24:40 +03:00
|
|
|
// Copyright 1998-2011 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Image, Fl_RGB_Image classes . */
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Image_H
|
2002-10-11 18:17:24 +04:00
|
|
|
# define Fl_Image_H
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2003-01-12 04:22:21 +03:00
|
|
|
# include "Enumerations.H"
|
2003-01-11 22:47:30 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
class Fl_Widget;
|
|
|
|
struct Fl_Menu_Item;
|
2003-01-10 22:29:09 +03:00
|
|
|
struct Fl_Label;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
Fl_Image is the base class used for caching and
|
|
|
|
drawing all kinds of images in FLTK. This class keeps track of
|
|
|
|
common image data such as the pixels, colormap, width, height,
|
|
|
|
and depth. Virtual methods are used to provide type-specific
|
|
|
|
image handling.</P>
|
|
|
|
|
|
|
|
<P>Since the Fl_Image class does not support image
|
|
|
|
drawing by itself, calling the draw() method results in
|
|
|
|
a box with an X in it being drawn instead.
|
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
class FL_EXPORT Fl_Image {
|
2001-11-25 19:38:11 +03:00
|
|
|
int w_, h_, d_, ld_, count_;
|
2001-11-22 18:35:02 +03:00
|
|
|
const char * const *data_;
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2002-01-07 23:40:02 +03:00
|
|
|
// Forbid use of copy contructor and assign operator
|
|
|
|
Fl_Image & operator=(const Fl_Image &);
|
|
|
|
Fl_Image(const Fl_Image &);
|
|
|
|
|
2001-11-22 18:35:02 +03:00
|
|
|
protected:
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Sets the current image width in pixels.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
void w(int W) {w_ = W;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Sets the current image height in pixels.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
void h(int H) {h_ = H;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Sets the current image depth.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
void d(int D) {d_ = D;}
|
2011-01-30 12:24:40 +03:00
|
|
|
/**
|
|
|
|
Sets the current line data size in bytes.
|
|
|
|
*/
|
2001-11-25 19:38:11 +03:00
|
|
|
void ld(int LD) {ld_ = LD;}
|
2011-01-30 12:24:40 +03:00
|
|
|
/**
|
|
|
|
Sets the current array pointer and count of pointers in the array.
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
void data(const char * const *p, int c) {data_ = p; count_ = c;}
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_empty(int X, int Y);
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
|
|
|
|
static void measure(const Fl_Label *lo, int &lw, int &lh);
|
2002-04-26 15:32:37 +04:00
|
|
|
|
2001-11-22 18:35:02 +03:00
|
|
|
public:
|
|
|
|
|
2011-01-30 12:24:40 +03:00
|
|
|
/**
|
|
|
|
Returns the current image width in pixels.
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int w() const {return w_;}
|
2011-01-30 12:24:40 +03:00
|
|
|
/** Returns the current image height in pixels.
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int h() const {return h_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Returns the current image depth.
|
|
|
|
The return value will be 0 for bitmaps, 1 for
|
2008-09-14 22:19:41 +04:00
|
|
|
pixmaps, and 1 to 4 for color images.</P>
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int d() const {return d_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Returns the current line data size in bytes.
|
|
|
|
Line data is extra data that is included
|
|
|
|
after each line of color image data and is normally not present.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-11-25 19:38:11 +03:00
|
|
|
int ld() const {return ld_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
The count() method returns the number of data values
|
|
|
|
associated with the image. The value will be 0 for images with
|
|
|
|
no associated data, 1 for bitmap and color images, and greater
|
|
|
|
than 2 for pixmap images.
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int count() const {return count_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Returns a pointer to the current image data array.
|
|
|
|
Use the count() method to find the size of the data array.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
const char * const *data() const {return data_;}
|
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
The constructor creates an empty image with the specified
|
|
|
|
width, height, and depth. The width and height are in pixels.
|
|
|
|
The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and
|
|
|
|
1 to 4 for color images.
|
|
|
|
*/
|
2001-11-25 19:38:11 +03:00
|
|
|
Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;}
|
2001-08-06 03:58:54 +04:00
|
|
|
virtual ~Fl_Image();
|
OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image
classes: new copy(), copy(w,h), desaturate(), color_average(), and
inactive() methods, alloc_xyz member for copied data, etc.
Updated test programs to use inactive() and copy() methods to create
inactive images for the test buttons, plus the inactive button to toggle
it...
Added start of separate image classes, a la 2.0, for various image formats.
FLUID will also be updated for it...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2001-11-19 04:06:45 +03:00
|
|
|
virtual Fl_Image *copy(int W, int H);
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
The copy() method creates a copy of the specified
|
|
|
|
image. If the width and height are provided, the image is
|
|
|
|
resized to the specified size. The image should be deleted (or in
|
|
|
|
the case of Fl_Shared_Image, released) when you are done
|
|
|
|
with it.
|
|
|
|
*/
|
OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image
classes: new copy(), copy(w,h), desaturate(), color_average(), and
inactive() methods, alloc_xyz member for copied data, etc.
Updated test programs to use inactive() and copy() methods to create
inactive images for the test buttons, plus the inactive button to toggle
it...
Added start of separate image classes, a la 2.0, for various image formats.
FLUID will also be updated for it...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2001-11-19 04:06:45 +03:00
|
|
|
Fl_Image *copy() { return copy(w(), h()); }
|
|
|
|
virtual void color_average(Fl_Color c, float i);
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
The inactive() method calls
|
|
|
|
color_average(FL_BACKGROUND_COLOR, 0.33f) to produce
|
|
|
|
an image that appears grayed out. <I>This method does not
|
|
|
|
alter the original image data.</I>
|
|
|
|
*/
|
OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image
classes: new copy(), copy(w,h), desaturate(), color_average(), and
inactive() methods, alloc_xyz member for copied data, etc.
Updated test programs to use inactive() and copy() methods to create
inactive images for the test buttons, plus the inactive button to toggle
it...
Added start of separate image classes, a la 2.0, for various image formats.
FLUID will also be updated for it...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2001-11-19 04:06:45 +03:00
|
|
|
void inactive() { color_average(FL_GRAY, .33f); }
|
|
|
|
virtual void desaturate();
|
2001-08-06 03:58:54 +04:00
|
|
|
virtual void label(Fl_Widget*w);
|
|
|
|
virtual void label(Fl_Menu_Item*m);
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Draws the image with a bounding box.
|
|
|
|
This form specifies
|
2008-09-14 22:19:41 +04:00
|
|
|
a bounding box for the image, with the origin
|
|
|
|
(upper-lefthand corner) of the image offset by the cx
|
|
|
|
and cy arguments.
|
|
|
|
*/
|
|
|
|
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
|
|
|
|
/**
|
2011-01-30 12:24:40 +03:00
|
|
|
Draws the image.
|
|
|
|
This form specifies the upper-lefthand corner of the image.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
|
|
|
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
|
2002-08-05 21:50:25 +04:00
|
|
|
virtual void uncache();
|
2001-08-06 03:58:54 +04:00
|
|
|
};
|
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
|
|
|
The Fl_RGB_Image class supports caching and drawing
|
|
|
|
of full-color images with 1 to 4 channels of color information.
|
|
|
|
Images with an even number of channels are assumed to contain
|
|
|
|
alpha information, which is used to blend the image with the
|
|
|
|
contents of the screen.</P>
|
|
|
|
|
|
|
|
<P>Fl_RGB_Image is defined in
|
|
|
|
<FL/Fl_Image.H>, however for compatibility reasons
|
|
|
|
<FL/Fl_RGB_Image.H> should be included.
|
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
|
2010-05-27 21:20:18 +04:00
|
|
|
friend class Fl_Quartz_Graphics_Driver;
|
|
|
|
friend class Fl_GDI_Graphics_Driver;
|
|
|
|
friend class Fl_Xlib_Graphics_Driver;
|
|
|
|
public:
|
2001-08-06 03:58:54 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
const uchar *array;
|
OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image
classes: new copy(), copy(w,h), desaturate(), color_average(), and
inactive() methods, alloc_xyz member for copied data, etc.
Updated test programs to use inactive() and copy() methods to create
inactive images for the test buttons, plus the inactive button to toggle
it...
Added start of separate image classes, a la 2.0, for various image formats.
FLUID will also be updated for it...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2001-11-19 04:06:45 +03:00
|
|
|
int alloc_array; // Non-zero if array was allocated
|
2001-11-25 19:38:11 +03:00
|
|
|
|
2010-03-16 02:47:47 +03:00
|
|
|
private:
|
|
|
|
|
2003-01-15 22:41:58 +03:00
|
|
|
#if defined(__APPLE__) || defined(WIN32)
|
2010-03-16 02:47:47 +03:00
|
|
|
void *id_; // for internal use
|
|
|
|
void *mask_; // for internal use (mask bitmap)
|
2003-01-10 22:29:09 +03:00
|
|
|
#else
|
2010-03-16 02:47:47 +03:00
|
|
|
unsigned id_; // for internal use
|
|
|
|
unsigned mask_; // for internal use (mask bitmap)
|
2003-01-15 22:41:58 +03:00
|
|
|
#endif // __APPLE__ || WIN32
|
2010-03-16 02:47:47 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/** The constructor creates a new image from the specified data. */
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
|
2010-03-16 02:47:47 +03:00
|
|
|
Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
|
2001-08-06 03:58:54 +04:00
|
|
|
virtual ~Fl_RGB_Image();
|
OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image
classes: new copy(), copy(w,h), desaturate(), color_average(), and
inactive() methods, alloc_xyz member for copied data, etc.
Updated test programs to use inactive() and copy() methods to create
inactive images for the test buttons, plus the inactive button to toggle
it...
Added start of separate image classes, a la 2.0, for various image formats.
FLUID will also be updated for it...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2001-11-19 04:06:45 +03:00
|
|
|
virtual Fl_Image *copy(int W, int H);
|
|
|
|
Fl_Image *copy() { return copy(w(), h()); }
|
|
|
|
virtual void color_average(Fl_Color c, float i);
|
|
|
|
virtual void desaturate();
|
2001-08-06 03:58:54 +04:00
|
|
|
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
|
|
|
|
void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
|
|
|
|
virtual void label(Fl_Widget*w);
|
|
|
|
virtual void label(Fl_Menu_Item*m);
|
2002-08-05 21:50:25 +04:00
|
|
|
virtual void uncache();
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2002-10-11 18:17:24 +04:00
|
|
|
#endif // !Fl_Image_H
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|