1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Image header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2017-05-17 14:54:18 +03:00
|
|
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2005-04-16 04:13:17 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2014-10-13 15:25:36 +04:00
|
|
|
/** \file
|
|
|
|
Fl_Image, Fl_RGB_Image classes. */
|
2008-09-16 11:26:22 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Image_H
|
2016-02-09 21:25:02 +03:00
|
|
|
#define Fl_Image_H
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2016-02-09 21:25:02 +03:00
|
|
|
#include "Enumerations.H"
|
2012-11-09 20:02:08 +04:00
|
|
|
#include <stdlib.h>
|
2016-02-09 21:25:02 +03:00
|
|
|
#include "Fl_Widget.H" // for fl_uintptr_t
|
2003-01-11 22:47:30 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
class Fl_Widget;
|
2014-06-12 17:28:04 +04:00
|
|
|
class Fl_Pixmap;
|
1998-10-06 22:21:25 +04:00
|
|
|
struct Fl_Menu_Item;
|
2003-01-10 22:29:09 +03:00
|
|
|
struct Fl_Label;
|
2016-10-30 10:26:13 +03:00
|
|
|
class Fl_RGB_Image;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
|
2014-10-14 17:32:59 +04:00
|
|
|
/** \enum Fl_RGB_Scaling
|
2015-05-24 02:42:26 +03:00
|
|
|
The scaling algorithm to use for RGB images.
|
2014-10-14 15:53:51 +04:00
|
|
|
*/
|
|
|
|
enum Fl_RGB_Scaling {
|
2015-05-24 02:42:26 +03:00
|
|
|
FL_RGB_SCALING_NEAREST = 0, ///< default RGB image scaling algorithm
|
|
|
|
FL_RGB_SCALING_BILINEAR ///< more accurate, but slower RGB image scaling algorithm
|
2014-10-14 15:53:51 +04:00
|
|
|
};
|
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2018-03-19 20:43:18 +03:00
|
|
|
\brief Base class for image caching, scaling and drawing.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2018-03-19 20:43:18 +03:00
|
|
|
Fl_Image is the base class used for caching, scaling and drawing all kinds of images
|
2020-07-01 19:03:10 +03:00
|
|
|
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
|
2015-05-24 02:42:26 +03:00
|
|
|
type-specific image handling.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2018-03-22 19:38:38 +03:00
|
|
|
Each image possesses two (width, height) pairs. 1) The width and height of the
|
|
|
|
image raw data are returned by data_w() and data_h(). These values are set
|
|
|
|
when the image is created and remain unchanged. 2) The width and height
|
|
|
|
of the area filled by the image when it gets drawn are returned by w() and h().
|
|
|
|
The values are equal to data_w() and data_h() when the image is created,
|
|
|
|
and can be changed by the scale() member function.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
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.
|
2008-09-14 22:19:41 +04:00
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
class FL_EXPORT Fl_Image {
|
2016-11-03 00:08:15 +03:00
|
|
|
friend class Fl_Graphics_Driver;
|
2015-05-24 02:42:26 +03:00
|
|
|
public:
|
2015-05-24 20:19:57 +03:00
|
|
|
static const int ERR_NO_IMAGE = -1;
|
|
|
|
static const int ERR_FILE_ACCESS = -2;
|
|
|
|
static const int ERR_FORMAT = -3;
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
private:
|
2001-11-25 19:38:11 +03:00
|
|
|
int w_, h_, d_, ld_, count_;
|
2018-03-22 19:38:38 +03:00
|
|
|
int data_w_, data_h_;
|
2001-11-22 18:35:02 +03:00
|
|
|
const char * const *data_;
|
2018-03-19 20:43:18 +03:00
|
|
|
static Fl_RGB_Scaling RGB_scaling_; // method used when copying RGB images
|
|
|
|
static Fl_RGB_Scaling scaling_algorithm_; // method used to rescale RGB source images before drawing
|
2014-10-14 15:53:51 +04:00
|
|
|
// Forbid use of copy constructor and assign operator
|
2002-01-07 23:40:02 +03:00
|
|
|
Fl_Image & operator=(const Fl_Image &);
|
|
|
|
Fl_Image(const Fl_Image &);
|
2020-11-17 13:23:24 +03:00
|
|
|
// Presently redefined in Fl_SVG_Image
|
|
|
|
virtual void cache_size(int &width, int &height) {}
|
2002-01-07 23:40:02 +03:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
protected:
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2018-03-22 19:38:38 +03:00
|
|
|
Sets the width of the image data.
|
2018-03-26 11:20:17 +03:00
|
|
|
This protected function sets both image widths: the width of the image data returned by data_w() and
|
|
|
|
the image drawing width in FLTK units returned by w().
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2018-03-22 19:38:38 +03:00
|
|
|
void w(int W) {w_ = W; data_w_ = W;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2018-03-22 19:38:38 +03:00
|
|
|
Sets the height of the image data.
|
2018-03-26 11:20:17 +03:00
|
|
|
This protected function sets both image heights: the height of the image data returned by data_h() and
|
|
|
|
the image drawing height in FLTK units returned by h().
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2018-03-22 19:38:38 +03:00
|
|
|
void h(int H) {h_ = H; data_h_ = H;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2015-05-24 02:42:26 +03:00
|
|
|
Sets the current image depth.
|
|
|
|
*/
|
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.
|
2016-10-14 19:35:52 +03:00
|
|
|
|
|
|
|
Color images may contain extra data that is included after every
|
|
|
|
line of color image data and is normally not present.
|
|
|
|
|
|
|
|
If \p LD is zero, then line data size is assumed to be w() * d() bytes.
|
|
|
|
|
|
|
|
If \p LD is non-zero, then it must be positive and larger than w() * d()
|
|
|
|
to account for the extra data per line.
|
2011-01-30 12:24:40 +03:00
|
|
|
*/
|
2001-11-25 19:38:11 +03:00
|
|
|
void ld(int LD) {ld_ = LD;}
|
2020-07-01 19:03:10 +03:00
|
|
|
/**
|
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);
|
2018-03-19 20:43:18 +03:00
|
|
|
int draw_scaled(int X, int Y, int W, int H);
|
2002-04-26 15:32:37 +04:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
public:
|
2001-11-22 18:35:02 +03:00
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
/**
|
2019-04-14 10:54:55 +03:00
|
|
|
Returns the current image drawing width in FLTK units.
|
2018-03-22 19:38:38 +03:00
|
|
|
The values of w() and data_w() are identical unless scale() has been called
|
2018-03-19 20:43:18 +03:00
|
|
|
after which they may differ.
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int w() const {return w_;}
|
2015-05-24 02:42:26 +03:00
|
|
|
/**
|
2019-04-14 10:54:55 +03:00
|
|
|
Returns the current image drawing height in FLTK units.
|
2018-03-22 19:38:38 +03:00
|
|
|
The values of h() and data_h() are identical unless scale() has been called
|
2018-03-19 20:43:18 +03:00
|
|
|
after which they may differ.
|
2011-01-30 12:24:40 +03:00
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
int h() const {return h_;}
|
2018-03-19 20:43:18 +03:00
|
|
|
/**
|
2018-03-22 19:38:38 +03:00
|
|
|
Returns the width of the image data.
|
2018-03-19 20:43:18 +03:00
|
|
|
*/
|
2018-03-22 19:38:38 +03:00
|
|
|
int data_w() const {return data_w_;}
|
2018-03-19 20:43:18 +03:00
|
|
|
/**
|
2018-03-22 19:38:38 +03:00
|
|
|
Returns the height of the image data.
|
2018-03-19 20:43:18 +03:00
|
|
|
*/
|
2018-03-22 19:38:38 +03:00
|
|
|
int data_h() const {return data_h_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2019-04-14 10:54:55 +03:00
|
|
|
Returns the image depth.
|
2011-01-30 12:24:40 +03:00
|
|
|
The return value will be 0 for bitmaps, 1 for
|
2015-05-24 02:42:26 +03: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
|
|
|
/**
|
2015-05-24 02:42:26 +03:00
|
|
|
Returns the current line data size in bytes.
|
2016-10-14 19:35:52 +03:00
|
|
|
\see ld(int)
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2001-11-25 19:38:11 +03:00
|
|
|
int ld() const {return ld_;}
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2015-05-24 02:42:26 +03: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
|
|
|
/**
|
2015-05-24 02:42:26 +03:00
|
|
|
Returns a pointer to the current image data array.
|
|
|
|
Use the count() method to find the size of the data array.
|
|
|
|
*/
|
2001-11-22 18:35:02 +03:00
|
|
|
const char * const *data() const {return data_;}
|
2015-05-24 02:42:26 +03:00
|
|
|
int fail();
|
2020-06-05 22:11:15 +03:00
|
|
|
/**
|
|
|
|
Releases an Fl_Image - the same as '\p delete \p this'.
|
|
|
|
|
|
|
|
This virtual method is for almost all image classes the same as calling
|
|
|
|
\code
|
|
|
|
delete image;
|
|
|
|
\endcode
|
|
|
|
where image is an \p Fl_Image \p * pointer.
|
|
|
|
|
|
|
|
However, for subclass Fl_Shared_Image this virtual method is
|
|
|
|
reimplemented and maintains shared images.
|
|
|
|
|
|
|
|
This virtual method makes it possible to \p delete all image types in
|
|
|
|
the same way by calling
|
|
|
|
\code
|
|
|
|
image->release();
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
Reasoning: If you have an 'Fl_Image *' pointer and don't know if the
|
|
|
|
object is one of the class Fl_Shared_Image or any other subclass of
|
|
|
|
Fl_Image (for instance Fl_RGB_Image) then you can't just use operator
|
|
|
|
delete since this is not appropriate for Fl_Shared_Image objects.
|
|
|
|
|
|
|
|
The virtual method release() handles this properly.
|
|
|
|
|
|
|
|
\since 1.4.0 in the base class Fl_Image and virtual in Fl_Shared_Image
|
|
|
|
*/
|
|
|
|
virtual void release() {
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns whether an image is an Fl_Shared_Image or not.
|
|
|
|
|
|
|
|
This virtual method returns a pointer to an Fl_Shared_Image if this
|
|
|
|
object is an instance of Fl_Shared_Image or NULL if not. This can be
|
|
|
|
used to detect if a given Fl_Image object is a shared image, i.e.
|
|
|
|
derived from Fl_Shared_Image.
|
|
|
|
|
|
|
|
\since 1.4.0
|
|
|
|
*/
|
|
|
|
virtual class Fl_Shared_Image *as_shared_image() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
Fl_Image(int W, int H, int D);
|
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
|
|
|
/**
|
2018-03-23 20:03:24 +03:00
|
|
|
Creates a copy of the specified image.
|
|
|
|
The image should be deleted (or in the case of Fl_Shared_Image, released)
|
|
|
|
when you are done with it.
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2018-03-23 20:03:24 +03:00
|
|
|
Fl_Image *copy() { Fl_Image *img = copy(data_w(), data_h()); img->scale(w(), h(), 0, 1); return img;}
|
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 void color_average(Fl_Color c, float i);
|
2008-09-14 22:19:41 +04:00
|
|
|
/**
|
2015-05-24 02:42:26 +03:00
|
|
|
The inactive() method calls
|
|
|
|
color_average(FL_BACKGROUND_COLOR, 0.33f) to produce
|
|
|
|
an image that appears grayed out.
|
2015-04-28 23:51:32 +03:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
An internal copy is made of the original image before
|
|
|
|
changes are applied, to avoid modifying the original 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
|
|
|
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
|
|
|
/**
|
2017-08-30 11:59:50 +03:00
|
|
|
Draws the image to the current drawing surface with a bounding box.
|
2015-05-24 02:42:26 +03:00
|
|
|
Arguments <tt>X,Y,W,H</tt> specify
|
2020-07-01 19:03:10 +03:00
|
|
|
a bounding box for the image, with the origin
|
2015-05-24 02:42:26 +03:00
|
|
|
(upper-left corner) of the image offset by the \c cx
|
|
|
|
and \c cy arguments.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2015-03-12 11:59:14 +03:00
|
|
|
In other words: <tt>fl_push_clip(X,Y,W,H)</tt> is applied,
|
|
|
|
the image is drawn with its upper-left corner at <tt>X-cx,Y-cy</tt> and its own width and height,
|
|
|
|
<tt>fl_pop_clip</tt><tt>()</tt> is applied.
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
2008-09-14 22:19:41 +04:00
|
|
|
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
|
|
|
|
/**
|
2017-08-30 11:59:50 +03:00
|
|
|
Draws the image to the current drawing surface.
|
|
|
|
\param X, Y specify the upper-lefthand corner of the image.
|
2015-05-24 02:42:26 +03:00
|
|
|
*/
|
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
|
|
|
|
2017-09-11 21:54:10 +03:00
|
|
|
// used by fl_define_FL_IMAGE_LABEL() to avoid 'friend' declaration
|
|
|
|
static Fl_Labeltype define_FL_IMAGE_LABEL();
|
|
|
|
|
2014-10-14 15:53:51 +04:00
|
|
|
// set RGB image scaling method
|
|
|
|
static void RGB_scaling(Fl_RGB_Scaling);
|
|
|
|
// get RGB image scaling method
|
|
|
|
static Fl_RGB_Scaling RGB_scaling();
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2018-03-19 20:43:18 +03:00
|
|
|
// set the image drawing size
|
|
|
|
virtual void scale(int width, int height, int proportional = 1, int can_expand = 0);
|
|
|
|
/** Sets what algorithm is used when resizing a source image to draw it.
|
|
|
|
The default algorithm is FL_RGB_SCALING_BILINEAR.
|
|
|
|
Drawing an Fl_Image is sometimes performed by first resizing the source image
|
|
|
|
and then drawing the resized copy. This occurs, e.g., when drawing to screen under X11
|
|
|
|
without Xrender support after having called scale().
|
|
|
|
This function controls what method is used when the image to be resized is an Fl_RGB_Image.
|
|
|
|
\version 1.4
|
|
|
|
*/
|
|
|
|
static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; }
|
|
|
|
/** Gets what algorithm is used when resizing a source image to draw it. */
|
|
|
|
static Fl_RGB_Scaling scaling_algorithm() {return scaling_algorithm_;}
|
2020-01-30 20:54:18 +03:00
|
|
|
static bool register_images_done;
|
2014-09-03 15:00:56 +04:00
|
|
|
};
|
|
|
|
|
2020-06-15 20:05:34 +03:00
|
|
|
class Fl_SVG_Image;
|
2015-05-24 02:42:26 +03: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
|
2014-10-14 15:53:51 +04:00
|
|
|
contents of the screen.
|
|
|
|
|
|
|
|
Fl_RGB_Image is defined in
|
2008-09-14 22:19:41 +04:00
|
|
|
<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 {
|
2016-11-03 00:08:15 +03:00
|
|
|
friend class Fl_Graphics_Driver;
|
2012-11-09 20:02:08 +04:00
|
|
|
static size_t max_size_;
|
2010-05-27 21:20:18 +04:00
|
|
|
public:
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2016-08-27 17:16:32 +03:00
|
|
|
/** Points to the start of the object's data array
|
2020-06-15 20:05:34 +03:00
|
|
|
\see class Fl_SVG_Image which delays initialization of this member variable.
|
2016-08-27 17:16:32 +03:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
const uchar *array;
|
2016-08-27 17:16:32 +03:00
|
|
|
/** If non-zero, the object's data array is delete[]'d when deleting the object.
|
|
|
|
*/
|
|
|
|
int alloc_array;
|
2001-11-25 19:38:11 +03:00
|
|
|
|
2016-02-09 21:25:02 +03:00
|
|
|
private:
|
|
|
|
// These two variables are used to cache the image and mask for the main display graphics driver
|
|
|
|
fl_uintptr_t id_;
|
|
|
|
fl_uintptr_t mask_;
|
2018-03-28 16:00:12 +03:00
|
|
|
int cache_w_, cache_h_; // size of image when cached
|
2015-05-24 02:42:26 +03:00
|
|
|
public:
|
2010-03-16 02:47:47 +03:00
|
|
|
|
2015-05-24 02:42:26 +03:00
|
|
|
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0);
|
2014-06-12 17:28:04 +04:00
|
|
|
Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
|
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);
|
2018-03-23 20:03:24 +03:00
|
|
|
Fl_Image *copy() { return Fl_Image::copy(); }
|
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 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();
|
2012-11-09 20:02:08 +04:00
|
|
|
/** Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2012-11-09 20:02:08 +04:00
|
|
|
The image size in bytes of an Fl_RGB_Image object is the value of the product w() * h() * d().
|
2020-07-01 19:03:10 +03:00
|
|
|
If this product exceeds size, the created object of a derived class of Fl_RGB_Image
|
2012-11-09 20:02:08 +04:00
|
|
|
won't be loaded with the image data.
|
2020-07-01 19:03:10 +03:00
|
|
|
This does not apply to direct RGB image creation with
|
2012-11-09 20:02:08 +04:00
|
|
|
Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD).
|
2020-07-01 19:03:10 +03:00
|
|
|
The default max_size() value is essentially infinite.
|
2012-11-09 20:02:08 +04:00
|
|
|
*/
|
|
|
|
static void max_size(size_t size) { max_size_ = size;}
|
|
|
|
/** Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2012-11-09 20:02:08 +04:00
|
|
|
\sa void Fl_RGB_Image::max_size(size_t)
|
|
|
|
*/
|
|
|
|
static size_t max_size() {return max_size_;}
|
2020-06-15 20:05:34 +03:00
|
|
|
/** Returns whether an image is an Fl_SVG_Image or not.
|
|
|
|
This virtual method returns a pointer to the Fl_SVG_Image if this object is an instance of Fl_SVG_Image or NULL if not. */
|
|
|
|
virtual Fl_SVG_Image *as_svg_image() { return NULL; }
|
|
|
|
/** Makes sure the object is fully initialized.
|
|
|
|
In particular, makes sure member variable \ref array is non-null. */
|
|
|
|
virtual void normalize() {}
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2002-10-11 18:17:24 +04:00
|
|
|
#endif // !Fl_Image_H
|