00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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;
00066 FXuint 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