FLTK 1.3.2

- 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: Fl_Shared_Image.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
    00003 //
    00004 // Shared image header file for the Fast Light Tool Kit (FLTK).
    00005 //
    00006 // Copyright 1998-2010 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.
    00040 class FL_EXPORT Fl_Shared_Image : public Fl_Image {
    00041
    00042   friend class Fl_JPEG_Image;
    00043   friend class Fl_PNG_Image;
    00044
    00045 protected:
    00046
    00047   static Fl_Shared_Image **images_;     // Shared images
    00048   static int    num_images_;            // Number of shared images
    00049   static int    alloc_images_;          // Allocated shared images
    00050   static Fl_Shared_Handler *handlers_;  // Additional format handlers
    00051   static int    num_handlers_;          // Number of format handlers
    00052   static int    alloc_handlers_;        // Allocated format handlers
    00053
    00054   const char    *name_;                 // Name of image file
    00055   int           original_;              // Original image?
    00056   int           refcount_;              // Number of times this image has been used
    00057   Fl_Image      *image_;                // The image that is shared
    00058   int           alloc_image_;           // Was the image allocated?
    00059
    00060   static int    compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1);
    00061
    00062   // Use get() and release() to load/delete images in memory...
    00063   Fl_Shared_Image();
    00064   Fl_Shared_Image(const char *n, Fl_Image *img = 0);
    00065   virtual ~Fl_Shared_Image();
    00066   void add();
    00067   void update();
    00068
    00069   public:
    00071   const char    *name() { return name_; }
    00073   int           refcount() { return refcount_; }
    00074   void          release();
    00075   void          reload();
    00076
    00077   virtual Fl_Image *copy(int W, int H);
    00078   Fl_Image *copy() { return copy(w(), h()); }
    00079   virtual void color_average(Fl_Color c, float i);
    00080   virtual void desaturate();
    00081   virtual void draw(int X, int Y, int W, int H, int cx, int cy);
    00082   void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
    00083   virtual void uncache();
    00084
    00085   static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0);
    00086   static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0);
    00087   static Fl_Shared_Image **images();
    00088   static int            num_images();
    00089   static void           add_handler(Fl_Shared_Handler f);
    00090   static void           remove_handler(Fl_Shared_Handler f);
    00091 };
    00092
    00093 //
    00094 // The following function is provided in the fltk_images library and
    00095 // registers all of the "extra" image file formats that are not part
    00096 // of the core FLTK library...
    00097 //
    00098
    00099 FL_EXPORT extern void fl_register_images();
    00100
    00101 #endif // !Fl_Shared_Image_H
    00102
    00103 //
    00104 // End of "$Id: Fl_Shared_Image.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
    00105 //