FLTK 1.3.3: Fl_Shared_Image.H Source File

FLTK 1.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Shared_Image.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_Shared_Image.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
3 //
4 // Shared image header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 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.
40 class FL_EXPORT Fl_Shared_Image : public Fl_Image {
41
42 friend class Fl_JPEG_Image;
43 friend class Fl_PNG_Image;
44
45 protected:
46
47 static Fl_Shared_Image **images_; // Shared images
48 static int num_images_; // Number of shared images
49 static int alloc_images_; // Allocated shared images
50 static Fl_Shared_Handler *handlers_; // Additional format handlers
51 static int num_handlers_; // Number of format handlers
52 static int alloc_handlers_; // Allocated format handlers
53
54 const char *name_; // Name of image file
55 int original_; // Original image?
56 int refcount_; // Number of times this image has been used
57 Fl_Image *image_; // The image that is shared
58 int alloc_image_; // Was the image allocated?
59
60 static int compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
61
62 // Use get() and release() to load/delete images in memory...
63 Fl_Shared_Image();
64 Fl_Shared_Image(const char *n, Fl_Image *img = 0);
65 virtual ~Fl_Shared_Image();
66 void add();
67 void update();
68
69 public:
71 const char *name() { return name_; }
73 int refcount() { return refcount_; }
74 void release();
75 void reload();
76
77 virtual Fl_Image *copy(int W, int H);
78 Fl_Image *copy() { return copy(w(), h()); }
79 virtual void color_average(Fl_Color c, float i);
80 virtual void desaturate();
81 virtual void draw(int X, int Y, int W, int H, int cx, int cy);
82 void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
83 virtual void uncache();
84
85 static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0);
86 static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0);
87 static Fl_Shared_Image **images();
88 static int num_images();
89 static void add_handler(Fl_Shared_Handler f);
90 static void remove_handler(Fl_Shared_Handler f);
91 };
92
93 //
94 // The following function is provided in the fltk_images library and
95 // registers all of the "extra" image file formats that are not part
96 // of the core FLTK library...
97 //
98
99 FL_EXPORT extern void fl_register_images();
100
101 #endif // !Fl_Shared_Image_H
102
103 //
104 // End of "$Id: Fl_Shared_Image.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
105 //
Fl_Image::desaturate
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition: Fl_Image.cxx:101
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
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition: Fl_Image.H:52
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
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:54
Fl_Shared_Image::name
const char * name()
Returns the filename of the shared image.
Definition: Fl_Shared_Image.H:71
Fl_JPEG_Image
The Fl_JPEG_Image class supports loading, caching, and drawing of Joint Photographic Experts Group (J...
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:138
Fl_Shared_Image::refcount
int refcount()
Returns the number of references of this shared image.
Definition: Fl_Shared_Image.H:73
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:92
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
fl_register_images
FL_EXPORT void fl_register_images()
Register the image formats.
Definition: fl_images_core.cxx:54
Fl_Image::w
int w() const
Returns the current image width in pixels.
Definition: Fl_Image.H:93
Fl_Shared_Image
This class supports caching, loading, and drawing of image files.
Definition: Fl_Shared_Image.H:40
Fl_Image::uncache
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition: Fl_Image.cxx:51
Fl_Image::h
int h() const
Returns the current image height in pixels.
Definition: Fl_Image.H:96
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
- © 1998-2014 by Bill Spitzak and others.