00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00022 #ifndef Fl_Shared_Image_H
00023 # define Fl_Shared_Image_H
00024
00025 # include "Fl_Image.H"
00026
00027
00028
00029 typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header,
00030 int headerlen);
00031
00032
00050 class FL_EXPORT Fl_Shared_Image : public Fl_Image {
00051
00052 friend class Fl_JPEG_Image;
00053 friend class Fl_PNG_Image;
00054
00055 private:
00056 static Fl_RGB_Scaling scaling_algorithm_;
00057 #if FLTK_ABI_VERSION >= 10304
00058 Fl_Image *scaled_image_;
00059 #endif
00060 protected:
00061
00062 static Fl_Shared_Image **images_;
00063 static int num_images_;
00064 static int alloc_images_;
00065 static Fl_Shared_Handler *handlers_;
00066 static int num_handlers_;
00067 static int alloc_handlers_;
00068
00069 const char *name_;
00070 int original_;
00071 int refcount_;
00072 Fl_Image *image_;
00073 int alloc_image_;
00074
00075 static int compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
00076
00077
00078 Fl_Shared_Image();
00079 Fl_Shared_Image(const char *n, Fl_Image *img = 0);
00080 virtual ~Fl_Shared_Image();
00081 void add();
00082 void update();
00083
00084 public:
00086 const char *name() { return name_; }
00087
00091 int refcount() { return refcount_; }
00092
00100 int original() { return original_; }
00101
00102 void release();
00103 void reload();
00104
00105 virtual Fl_Image *copy(int W, int H);
00106 Fl_Image *copy() { return copy(w(), h()); }
00107 virtual void color_average(Fl_Color c, float i);
00108 virtual void desaturate();
00109 virtual void draw(int X, int Y, int W, int H, int cx, int cy);
00110 void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
00111 void scale(int width, int height, int proportional = 1, int can_expand = 0);
00112 virtual void uncache();
00113
00114 static Fl_Shared_Image *find(const char *name, int W = 0, int H = 0);
00115 static Fl_Shared_Image *get(const char *name, int W = 0, int H = 0);
00116 static Fl_Shared_Image *get(Fl_RGB_Image *rgb, int own_it = 1);
00117 static Fl_Shared_Image **images();
00118 static int num_images();
00119 static void add_handler(Fl_Shared_Handler f);
00120 static void remove_handler(Fl_Shared_Handler f);
00129 static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; }
00130 };
00131
00132
00133
00134
00135
00136
00137
00138 FL_EXPORT extern void fl_register_images();
00139
00140 #endif // !Fl_Shared_Image_H
00141
00142
00143
00144