FLTK 1.3.4: Fl_Shared_Image.H Source File

FLTK 1.3.4

Fl_Shared_Image.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_Shared_Image.H 12002 2016-10-01 22:35:37Z AlbrechtS $"
3 //
4 // Shared image header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2016 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_Shared_Image_H
23 # define Fl_Shared_Image_H
24
25 # include "Fl_Image.H"
26
27
28 // Test function for adding new formats
29 typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header,
30 int headerlen);
31
32 // Shared images class.
50 class FL_EXPORT Fl_Shared_Image : public Fl_Image {
51
52 friend class Fl_JPEG_Image;
53 friend class Fl_PNG_Image;
54
55 private:
56 static Fl_RGB_Scaling scaling_algorithm_; // method used to rescale RGB source images
57 #if FLTK_ABI_VERSION >= 10304
58 Fl_Image *scaled_image_;
59 #endif
60 protected:
61
62 static Fl_Shared_Image **images_; // Shared images
63 static int num_images_; // Number of shared images
64 static int alloc_images_; // Allocated shared images
65 static Fl_Shared_Handler *handlers_; // Additional format handlers
66 static int num_handlers_; // Number of format handlers
67 static int alloc_handlers_; // Allocated format handlers
68
69 const char *name_; // Name of image file
70 int original_; // Original image?
71 int refcount_; // Number of times this image has been used
72 Fl_Image *image_; // The image that is shared
73 int alloc_image_; // Was the image allocated?
74
75 static int compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
76
77 // Use get() and release() to load/delete images in memory...
78 Fl_Shared_Image();
79 Fl_Shared_Image(const char *n, Fl_Image *img = 0);
80 virtual ~Fl_Shared_Image();
81 void add();
82 void update();
83
84 public:
86 const char *name() { return name_; }
88 int refcount() { return refcount_; }
89 void release();
90 void reload();
91
92 virtual Fl_Image *copy(int W, int H);
93 Fl_Image *copy() { return copy(w(), h()); }
94 virtual void color_average(Fl_Color c, float i);
95 virtual void desaturate();
96 virtual void draw(int X, int Y, int W, int H, int cx, int cy);
97 void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
98 void scale(int width, int height, int proportional = 1, int can_expand = 0);
99 virtual void uncache();
100
101 static Fl_Shared_Image *find(const char *name, int W = 0, int H = 0);
102 static Fl_Shared_Image *get(const char *name, int W = 0, int H = 0);
103 static Fl_Shared_Image *get(Fl_RGB_Image *rgb, int own_it = 1);
104 static Fl_Shared_Image **images();
105 static int num_images();
106 static void add_handler(Fl_Shared_Handler f);
107 static void remove_handler(Fl_Shared_Handler f);
116 static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; }
117 };
118
119 //
120 // The following function is provided in the fltk_images library and
121 // registers all of the "extra" image file formats that are not part
122 // of the core FLTK library...
123 //
124
125 FL_EXPORT extern void fl_register_images();
126
127 #endif // !Fl_Shared_Image_H
128
129 //
130 // End of "$Id: Fl_Shared_Image.H 12002 2016-10-01 22:35:37Z AlbrechtS $"
131 //
Fl_Image::desaturate
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition: Fl_Image.cxx:117
Fl_Image::h
int h() const
Returns the current image height in pixels.
Definition: Fl_Image.H:115
Fl_PNG_Image
The Fl_PNG_Image class supports loading, caching, and drawing of Portable Network Graphics (PNG) imag...
Definition: Fl_PNG_Image.H:32
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
Fl_Image::w
int w() const
Returns the current image width in pixels.
Definition: Fl_Image.H:111
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:202
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:66
Fl_Shared_Image::name
const char * name()
Returns the filename of the shared image.
Definition: Fl_Shared_Image.H:86
Fl_JPEG_Image
The Fl_JPEG_Image class supports loading, caching, and drawing of Joint Photographic Experts Group (...
Definition: Fl_JPEG_Image.H:32
Fl_Image::copy
Fl_Image * copy()
The copy() method creates a copy of the specified image.
Definition: Fl_Image.H:150
Fl_Shared_Image::scaling_algorithm
static void scaling_algorithm(Fl_RGB_Scaling algorithm)
Sets what algorithm is used when resizing a source image.
Definition: Fl_Shared_Image.H:116
Fl_Shared_Image::refcount
int refcount()
Returns the number of references of this shared image.
Definition: Fl_Shared_Image.H:88
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:106
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:934
fl_register_images
FL_EXPORT void fl_register_images()
Register the image formats.
Definition: fl_images_core.cxx:54
Fl_Shared_Image
This class supports caching, loading, scaling, and drawing of image files.
Definition: Fl_Shared_Image.H:50
Fl_Image::uncache
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition: Fl_Image.cxx:63
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_RGB_Scaling
Fl_RGB_Scaling
The scaling algorithm to use for RGB images.
Definition: Fl_Image.H:37
- © 1998-2016 by Bill Spitzak and others.