00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXIMAGE_H
00022 #define FXIMAGE_H
00023
00024 #ifndef FXDRAWABLE_H
00025 #include "FXDrawable.h"
00026 #endif
00027
00028 namespace FX {
00029
00030
00032 enum {
00033 IMAGE_KEEP = 0x00000001,
00034 IMAGE_OWNED = 0x00000002,
00035 IMAGE_DITHER = 0,
00036 IMAGE_NEAREST = 0x00000004,
00037 IMAGE_OPAQUE = 0x00000008,
00038 IMAGE_ALPHACOLOR = 0x00000010,
00039 IMAGE_SHMI = 0x00000020,
00040 IMAGE_SHMP = 0x00000040,
00041 IMAGE_ALPHAGUESS = 0x00000080,
00042 IMAGE_THRESGUESS = 0x00000100
00043 };
00044
00045
00046 class FXDC;
00047 class FXDCWindow;
00048
00049
00067 class FXAPI FXImage : public FXDrawable {
00068 FXDECLARE(FXImage)
00069 friend class FXDC;
00070 friend class FXDCWindow;
00071 protected:
00072 FXColor *data;
00073 FXuint options;
00074 private:
00075 #ifdef WIN32
00076 virtual FXID GetDC() const;
00077 virtual int ReleaseDC(FXID) const;
00078 #else
00079 void render_true_32(void *xim,FXuchar *img);
00080 void render_true_24(void *xim,FXuchar *img);
00081 void render_true_16_fast(void *xim,FXuchar *img);
00082 void render_true_16_dither(void *xim,FXuchar *img);
00083 void render_true_8_fast(void *xim,FXuchar *img);
00084 void render_true_8_dither(void *xim,FXuchar *img);
00085 void render_true_N_fast(void *xim,FXuchar *img);
00086 void render_true_N_dither(void *xim,FXuchar *img);
00087 void render_index_4_fast(void *xim,FXuchar *img);
00088 void render_index_4_dither(void *xim,FXuchar *img);
00089 void render_index_8_fast(void *xim,FXuchar *img);
00090 void render_index_8_dither(void *xim,FXuchar *img);
00091 void render_index_N_fast(void *xim,FXuchar *img);
00092 void render_index_N_dither(void *xim,FXuchar *img);
00093 void render_gray_8_fast(void *xim,FXuchar *img);
00094 void render_gray_8_dither(void *xim,FXuchar *img);
00095 void render_gray_N_fast(void *xim,FXuchar *img);
00096 void render_gray_N_dither(void *xim,FXuchar *img);
00097 void render_mono_1_fast(void *xim,FXuchar *img);
00098 void render_mono_1_dither(void *xim,FXuchar *img);
00099 #endif
00100 protected:
00101 FXImage();
00102 private:
00103 FXImage(const FXImage&);
00104 FXImage &operator=(const FXImage&);
00105 public:
00106
00116 FXImage(FXApp* a,const FXColor *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
00117
00119 void setOptions(FXuint opts);
00120
00122 FXuint getOptions() const { return options; }
00123
00125 void setOwned(FXbool owned);
00126
00128 FXbool isOwned() const;
00129
00136 virtual void setData(FXColor *pix,FXuint opts=0);
00137
00144 virtual void setData(FXColor *pix,FXuint opts,FXint w,FXint h);
00145
00147 FXColor* getData() const { return data; }
00148
00150 FXColor getPixel(FXint x,FXint y) const { return data[y*width+x]; }
00151
00153 void setPixel(FXint x,FXint y,FXColor color){ data[y*width+x]=color; }
00154
00156 FXbool hasAlpha() const;
00157
00166 virtual void create();
00167
00172 virtual void detach();
00173
00178 virtual void destroy();
00179
00185 virtual void restore();
00186
00194 virtual void render();
00195
00200 virtual void release();
00201
00207 virtual void resize(FXint w,FXint h);
00208
00213 virtual void scale(FXint w,FXint h,FXint quality=0);
00214
00216 virtual void mirror(FXbool horizontal,FXbool vertical);
00217
00222 virtual void rotate(FXint degrees);
00223
00230 virtual void crop(FXint x,FXint y,FXint w,FXint h,FXColor color=0);
00231
00233 virtual void fill(FXColor color);
00234
00236 virtual void fade(FXColor color,FXint factor=255);
00237
00243 virtual void xshear(FXint shear,FXColor clr=0);
00244
00250 virtual void yshear(FXint shear,FXColor clr=0);
00251
00253 virtual void hgradient(FXColor left,FXColor right);
00254
00256 virtual void vgradient(FXColor top,FXColor bottom);
00257
00259 virtual void gradient(FXColor topleft,FXColor topright,FXColor bottomleft,FXColor bottomright);
00260
00262 virtual void blend(FXColor color);
00263
00265 virtual void invert();
00266
00268 virtual void colorize(FXColor color);
00269
00271 virtual FXbool savePixels(FXStream& store) const;
00272
00274 virtual FXbool loadPixels(FXStream& store);
00275
00277 virtual void save(FXStream& store) const;
00278
00280 virtual void load(FXStream& store);
00281
00283 virtual ~FXImage();
00284 };
00285
00286 }
00287
00288 #endif