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

Fl_Image.H

Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 // Image header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 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_Image_H
00023 #  define Fl_Image_H
00024 
00025 #  include "Enumerations.H"
00026 #include <stdlib.h>
00027 
00028 class Fl_Widget;
00029 class Fl_Pixmap;
00030 struct Fl_Menu_Item;
00031 struct Fl_Label;
00032 
00033 
00037 enum Fl_RGB_Scaling {
00038   FL_RGB_SCALING_NEAREST = 0, 
00039   FL_RGB_SCALING_BILINEAR     
00040 };
00041 
00042 
00055 class FL_EXPORT Fl_Image {
00056     
00057 public:
00058   static const int ERR_NO_IMAGE    = -1;
00059   static const int ERR_FILE_ACCESS = -2;
00060   static const int ERR_FORMAT      = -3;
00061     
00062 private:
00063   int w_, h_, d_, ld_, count_;
00064   const char * const *data_;
00065   static Fl_RGB_Scaling RGB_scaling_;
00066 
00067   // Forbid use of copy constructor and assign operator
00068   Fl_Image & operator=(const Fl_Image &);
00069   Fl_Image(const Fl_Image &);
00070 
00071 protected:
00072 
00076   void w(int W) {w_ = W;}
00080   void h(int H) {h_ = H;}
00084   void d(int D) {d_ = D;}
00096   void ld(int LD) {ld_ = LD;}
00100   void data(const char * const *p, int c) {data_ = p; count_ = c;}
00101   void draw_empty(int X, int Y);
00102 
00103   static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la);
00104   static void measure(const Fl_Label *lo, int &lw, int &lh);
00105 
00106 public:
00107 
00111   int w() const {return w_;}
00115   int h() const {return h_;}
00121   int d() const {return d_;}
00126   int ld() const {return ld_;}
00133   int count() const {return count_;}
00138   const char * const *data() const {return data_;}
00139   int fail();
00140   Fl_Image(int W, int H, int D);
00141   virtual ~Fl_Image();
00142   virtual Fl_Image *copy(int W, int H);
00150   Fl_Image *copy() { return copy(w(), h()); }
00151   virtual void color_average(Fl_Color c, float i);
00160   void inactive() { color_average(FL_GRAY, .33f); }
00161   virtual void desaturate();
00162   virtual void label(Fl_Widget*w);
00163   virtual void label(Fl_Menu_Item*m);
00175   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent
00180   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
00181   virtual void uncache();
00182 
00183   // set RGB image scaling method
00184   static void RGB_scaling(Fl_RGB_Scaling);
00185 
00186   // get RGB image scaling method
00187   static Fl_RGB_Scaling RGB_scaling();
00188 };
00189 
00190 
00202 class FL_EXPORT Fl_RGB_Image : public Fl_Image {
00203   friend class Fl_Quartz_Graphics_Driver;
00204   friend class Fl_GDI_Graphics_Driver;
00205   friend class Fl_GDI_Printer_Graphics_Driver;
00206   friend class Fl_Xlib_Graphics_Driver;
00207   static size_t max_size_;
00208 public:
00209 
00212   const uchar *array;
00215   int alloc_array;
00216 
00217   private:
00218 
00219 #if defined(__APPLE__) || defined(WIN32)
00220   void *id_; // for internal use
00221   void *mask_; // for internal use (mask bitmap)
00222 #else
00223   unsigned id_; // for internal use
00224   unsigned mask_; // for internal use (mask bitmap)
00225 #endif // __APPLE__ || WIN32
00226 
00227 public:
00228 
00229   Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0);
00230   Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
00231   virtual ~Fl_RGB_Image();
00232   virtual Fl_Image *copy(int W, int H);
00233   Fl_Image *copy() { return copy(w(), h()); }
00234   virtual void color_average(Fl_Color c, float i);
00235   virtual void desaturate();
00236   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
00237   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
00238   virtual void label(Fl_Widget*w);
00239   virtual void label(Fl_Menu_Item*m);
00240   virtual void uncache();
00250   static void max_size(size_t size) { max_size_ = size;}
00255   static size_t max_size() {return max_size_;}
00256 };
00257 
00258 #endif // !Fl_Image_H
00259 
00260 //
00261 // End of "$Id$".
00262 //
  • © 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.