FLTK 1.3.9: Fl_Shared_Image.H Source File

FLTK 1.3.9

Loading...
Searching...
No Matches
Fl_Shared_Image.H
Go to the documentation of this file.
1//
2// "$Id$"
3//
4// Shared image header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2017 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
29typedef 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
55private:
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
60protected:
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
84public:
86 const char *name() { return name_; }
87
91 int refcount() { return refcount_; }
92
100 int original() { return original_; }
101
102 void release();
103 void reload();
104
105 virtual Fl_Image *copy(int W, int H);
106 Fl_Image *copy() { return copy(w(), h()); }
107 virtual void color_average(Fl_Color c, float i);
108 virtual void desaturate();
109 virtual void draw(int X, int Y, int W, int H, int cx, int cy);
110 void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
111 void scale(int width, int height, int proportional = 1, int can_expand = 0);
112 virtual void uncache();
113
114 static Fl_Shared_Image *find(const char *name, int W = 0, int H = 0);
115 static Fl_Shared_Image *get(const char *name, int W = 0, int H = 0);
116 static Fl_Shared_Image *get(Fl_RGB_Image *rgb, int own_it = 1);
117 static Fl_Shared_Image **images();
118 static int num_images();
119 static void add_handler(Fl_Shared_Handler f);
120 static void remove_handler(Fl_Shared_Handler f);
129 static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; }
130};
131
132//
133// The following function is provided in the fltk_images library and
134// registers all of the "extra" image file formats that are not part
135// of the core FLTK library...
136//
137
138FL_EXPORT extern void fl_register_images();
139
140#endif // !Fl_Shared_Image_H
141
142//
143// End of "$Id$"
144//
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:932
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
Fl_RGB_Scaling
Fl_RGB_Scaling
The scaling algorithm to use for RGB images.
Definition Fl_Image.H:37
fl_register_images
FL_EXPORT void fl_register_images()
Register the image formats.
Definition fl_images_core.cxx:54
Fl_Image
Base class for image caching and drawing.
Definition Fl_Image.H:55
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_Image::desaturate
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition Fl_Image.cxx:117
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_Image::w
int w() const
Returns the current image width in pixels.
Definition Fl_Image.H:111
Fl_Image::copy
Fl_Image * copy()
The copy() method creates a copy of the specified image.
Definition Fl_Image.H:150
Fl_Image::h
int h() const
Returns the current image height in pixels.
Definition Fl_Image.H:115
Fl_Image::uncache
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition Fl_Image.cxx:63
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_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_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_Shared_Image
This class supports caching, loading, scaling, and drawing of image files.
Definition Fl_Shared_Image.H:50
Fl_Shared_Image::name
const char * name()
Returns the filename of the shared image.
Definition Fl_Shared_Image.H:86
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:129
Fl_Shared_Image::original
int original()
Returns whether this is an original image.
Definition Fl_Shared_Image.H:100
Fl_Shared_Image::refcount
int refcount()
Returns the number of references of this shared image.
Definition Fl_Shared_Image.H:91
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30