• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Shared_Image.H

Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 // Shared image header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2017 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00022 #ifndef Fl_Shared_Image_H
00023 #  define Fl_Shared_Image_H
00024 
00025 #  include "Fl_Image.H"
00026 
00027 
00028 // Test function for adding new formats
00029 typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header,
00030                                        int headerlen);
00031 
00032 // Shared images class.
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_; // method used to rescale RGB source images
00057 #if FLTK_ABI_VERSION >= 10304
00058   Fl_Image *scaled_image_;
00059 #endif
00060 protected:
00061 
00062   static Fl_Shared_Image **images_;     // Shared images
00063   static int    num_images_;            // Number of shared images
00064   static int    alloc_images_;          // Allocated shared images
00065   static Fl_Shared_Handler *handlers_;  // Additional format handlers
00066   static int    num_handlers_;          // Number of format handlers
00067   static int    alloc_handlers_;        // Allocated format handlers
00068 
00069   const char    *name_;                 // Name of image file
00070   int           original_;              // Original image?
00071   int           refcount_;              // Number of times this image has been used
00072   Fl_Image      *image_;                // The image that is shared
00073   int           alloc_image_;           // Was the image allocated?
00074 
00075   static int    compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
00076 
00077   // Use get() and release() to load/delete images in memory...
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 // The following function is provided in the fltk_images library and
00134 // registers all of the "extra" image file formats that are not part
00135 // of the core FLTK library...
00136 //
00137 
00138 FL_EXPORT extern void fl_register_images();
00139 
00140 #endif // !Fl_Shared_Image_H
00141 
00142 //
00143 // End of "$Id$"
00144 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.