FXImage.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             I m a g e    O b j e c t                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXImage.h,v 1.64 2006/01/22 17:58:05 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXIMAGE_H
00025 #define FXIMAGE_H
00026 
00027 #ifndef FXDRAWABLE_H
00028 #include "FXDrawable.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00035 enum {
00036   IMAGE_KEEP       = 0x00000001,      
00037   IMAGE_OWNED      = 0x00000002,      
00038   IMAGE_DITHER     = 0,               
00039   IMAGE_NEAREST    = 0x00000004,      
00040   IMAGE_OPAQUE     = 0x00000008,      
00041   IMAGE_ALPHACOLOR = 0x00000010,      
00042   IMAGE_SHMI       = 0x00000020,      
00043   IMAGE_SHMP       = 0x00000040,      
00044   IMAGE_ALPHAGUESS = 0x00000080       
00045   };
00046 
00047 
00048 class FXDC;
00049 class FXDCWindow;
00050 
00051 
00060 class FXAPI FXImage : public FXDrawable {
00061   FXDECLARE(FXImage)
00062   friend class FXDC;
00063   friend class FXDCWindow;
00064 protected:
00065   FXColor *data;        // Pixel data
00066   FXuint   options;     // Options
00067 private:
00068 #ifdef WIN32
00069   virtual FXID GetDC() const;
00070   virtual int ReleaseDC(FXID) const;
00071 #endif
00072 #ifndef WIN32
00073   void render_true_32(void *xim,FXuchar *img);
00074   void render_true_24(void *xim,FXuchar *img);
00075   void render_true_16_fast(void *xim,FXuchar *img);
00076   void render_true_16_dither(void *xim,FXuchar *img);
00077   void render_true_8_fast(void *xim,FXuchar *img);
00078   void render_true_8_dither(void *xim,FXuchar *img);
00079   void render_true_N_fast(void *xim,FXuchar *img);
00080   void render_true_N_dither(void *xim,FXuchar *img);
00081   void render_index_4_fast(void *xim,FXuchar *img);
00082   void render_index_4_dither(void *xim,FXuchar *img);
00083   void render_index_8_fast(void *xim,FXuchar *img);
00084   void render_index_8_dither(void *xim,FXuchar *img);
00085   void render_index_N_fast(void *xim,FXuchar *img);
00086   void render_index_N_dither(void *xim,FXuchar *img);
00087   void render_gray_8_fast(void *xim,FXuchar *img);
00088   void render_gray_8_dither(void *xim,FXuchar *img);
00089   void render_gray_N_fast(void *xim,FXuchar *img);
00090   void render_gray_N_dither(void *xim,FXuchar *img);
00091   void render_mono_1_fast(void *xim,FXuchar *img);
00092   void render_mono_1_dither(void *xim,FXuchar *img);
00093 #endif
00094 protected:
00095   FXImage();
00096 private:
00097   FXImage(const FXImage&);
00098   FXImage &operator=(const FXImage&);
00099 public:
00100 
00110   FXImage(FXApp* a,const FXColor *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
00111 
00113   void setOptions(FXuint opts);
00114 
00116   FXuint getOptions() const { return options; }
00117 
00124   virtual void setData(FXColor *pix,FXuint opts=0);
00125 
00132   virtual void setData(FXColor *pix,FXuint opts,FXint w,FXint h);
00133 
00135   FXColor* getData() const { return data; }
00136 
00138   FXColor getPixel(FXint x,FXint y) const { return data[y*width+x]; }
00139 
00141   void setPixel(FXint x,FXint y,FXColor color){ data[y*width+x]=color; }
00142 
00144   bool hasAlpha() const;
00145 
00154   virtual void create();
00155 
00160   virtual void detach();
00161 
00166   virtual void destroy();
00167 
00173   virtual void restore();
00174 
00182   virtual void render();
00183 
00188   virtual void release();
00189 
00195   virtual void resize(FXint w,FXint h);
00196 
00201   virtual void scale(FXint w,FXint h,FXint quality=0);
00202 
00204   virtual void mirror(bool horizontal,bool vertical);
00205 
00210   virtual void rotate(FXint degrees);
00211 
00218   virtual void crop(FXint x,FXint y,FXint w,FXint h,FXColor color=0);
00219 
00221   virtual void fill(FXColor color);
00222 
00224   virtual void fade(FXColor color,FXint factor=255);
00225 
00231   virtual void xshear(FXint shear,FXColor clr=0);
00232 
00238   virtual void yshear(FXint shear,FXColor clr=0);
00239 
00241   virtual void hgradient(FXColor left,FXColor right);
00242 
00244   virtual void vgradient(FXColor top,FXColor bottom);
00245 
00247   virtual void gradient(FXColor topleft,FXColor topright,FXColor bottomleft,FXColor bottomright);
00248 
00250   virtual void blend(FXColor color);
00251 
00253   virtual void save(FXStream& store) const;
00254 
00256   virtual void load(FXStream& store);
00257 
00259   virtual bool savePixels(FXStream& store) const;
00260 
00262   virtual bool loadPixels(FXStream& store);
00263 
00265   virtual ~FXImage();
00266   };
00267 
00268 }
00269 
00270 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:22 2009 for TnFOX by doxygen v1.4.7