fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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
29 typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header,
30  int headerlen);
31 
32 // Shared images class.
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...
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_; }
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 
138 FL_EXPORT extern void fl_register_images();
139 
140 #endif // !Fl_Shared_Image_H
141 
142 //
143 // End of "$Id$"
144 //
Fl_Shared_Image::original_
int original_
Definition: Fl_Shared_Image.H:70
Fl_Shared_Image::image_
Fl_Image * image_
Definition: Fl_Shared_Image.H:72
Fl_Color
unsigned int Fl_Color
Definition: Enumerations.H:934
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
find
static Fl_Font_Descriptor * find(Fl_Font fnum, Fl_Fontsize size)
Definition: fl_font_mac.cxx:250
Fl_Image::uncache
virtual void uncache()
Definition: Fl_Image.cxx:63
Fl_RGB_Scaling
Fl_RGB_Scaling
Definition: Fl_Image.H:37
Fl_Shared_Image::alloc_handlers_
static int alloc_handlers_
Definition: Fl_Shared_Image.H:67
H
static int H
Definition: Fl_Tooltip.cxx:76
Fl_Shared_Image::num_images_
static int num_images_
Definition: Fl_Shared_Image.H:63
Fl_Shared_Image::alloc_images_
static int alloc_images_
Definition: Fl_Shared_Image.H:64
Fl_Shared_Image::name
const char * name()
Definition: Fl_Shared_Image.H:86
FL_EXPORT
#define FL_EXPORT
Definition: Fl_Export.H:35
Fl_Shared_Image::original
int original()
Definition: Fl_Shared_Image.H:100
fl_register_images
void fl_register_images()
Register the image formats.
Definition: fl_images_core.cxx:54
Fl_Shared_Image::scaling_algorithm
static void scaling_algorithm(Fl_RGB_Scaling algorithm)
Definition: Fl_Shared_Image.H:129
Fl_Shared_Image::alloc_image_
int alloc_image_
Definition: Fl_Shared_Image.H:73
Fl_Image::color_average
virtual void color_average(Fl_Color c, float i)
Definition: Fl_Image.cxx:106
Fl_Shared_Image::name_
const char * name_
Definition: Fl_Shared_Image.H:69
Fl_JPEG_Image
Definition: Fl_JPEG_Image.H:32
Fl_Shared_Image::refcount
int refcount()
Definition: Fl_Shared_Image.H:91
Fl_Image::copy
Fl_Image * copy()
Definition: Fl_Image.H:150
Fl_Shared_Image::draw
void draw(int X, int Y)
Definition: Fl_Shared_Image.H:110
Fl_Shared_Image::refcount_
int refcount_
Definition: Fl_Shared_Image.H:71
Fl_Image::h
int h() const
Definition: Fl_Image.H:115
Fl_Shared_Image::copy
Fl_Image * copy()
Definition: Fl_Shared_Image.H:106
compare
static int compare(const char *a, const char *b)
Definition: Fl_Menu_add.cxx:81
Fl_Image::draw
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0)
Definition: Fl_Image.cxx:66
Fl_Shared_Image::images_
static Fl_Shared_Image ** images_
Definition: Fl_Shared_Image.H:62
Fl_Image::w
int w() const
Definition: Fl_Image.H:111
f
Fl_Box_Draw_F * f
Definition: fl_boxtype.cxx:285
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Image.H
Fl_Shared_Handler
Fl_Image *(* Fl_Shared_Handler)(const char *name, uchar *header, int headerlen)
Definition: Fl_Shared_Image.H:29
images
static Fluid_Image ** images
Definition: Fluid_Image.cxx:156
Fl_Shared_Image::scaling_algorithm_
static Fl_RGB_Scaling scaling_algorithm_
Definition: Fl_Shared_Image.H:56
uchar
unsigned char uchar
Definition: fl_types.h:30
name
static const char * name
Definition: Fl_arg.cxx:53
Fl_RGB_Image
Definition: Fl_Image.H:202
Fl_Shared_Image
Definition: Fl_Shared_Image.H:50
Fl_PNG_Image
Definition: Fl_PNG_Image.H:32
Fl_Image::desaturate
virtual void desaturate()
Definition: Fl_Image.cxx:117
Fl_Shared_Image::num_handlers_
static int num_handlers_
Definition: Fl_Shared_Image.H:66
Fl_Shared_Image::handlers_
static Fl_Shared_Handler * handlers_
Definition: Fl_Shared_Image.H:65