00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _unatima_hpp_
00026 #define _unatima_hpp_
00027
00028 #include <ubit/ubit_config.h>
00029 #include <ubit/unatgraph.hpp>
00030
00031
00039 class UNatIma {
00040 public:
00041 static const char* const GIF;
00042 static const char* const JPG;
00043 static const char* const XPM;
00044 static const char* const XPM_DATA;
00045
00046 UNatIma(UNatDisp*, UX_Image xima, UX_Image ximashape);
00053 ~UNatIma();
00054
00055
00056
00057 u_dim getWidth() const;
00058 u_dim getHeight() const;
00059
00060 const UX_Image getXImage() const {return xima;}
00061 const UX_Image getXImageShape() const {return ximashape;}
00062
00063 bool isRealized() const;
00064 bool isShaped() const {return ximashape != null;}
00065
00066
00067
00068 static int readImage(UNatDisp*, const char* filename, const char* filetype,
00069 UNatIma*& natima);
00076 UNatIma* createScaledImage(float xscale, float yscale);
00077 UNatIma* createScaledImage(UNatDisp* to_nd, float xscale, float yscale);
00084
00085
00086 static UX_Image createEmptyImage(UNatDisp*, u_dim width, u_dim height,
00087 u_dim depth);
00097 static UX_Image createScaledImage(UNatDisp* to_nd, UNatDisp* from_nd,
00098 UX_Image from_ima,
00099 float xscale, float yscale);
00108
00109
00110 static bool blendImages(UNatDisp*, UX_Image xima1, UX_Image xima2,
00111 float alpha);
00112 static bool blendImage(UNatDisp*, UX_Image xima1, UX_Color pixel2,
00113 float alpha);
00119 static unsigned long* allocXColors(UNatDisp *nd,
00120 const XColor* colors, int colorCount);
00122
00123
00124
00126 typedef int (*Reader) (class UNatDisp*, const char *fpath, UNatIma*& natima);
00127
00129 typedef int (*Writer) (class UNatDisp*, const char *fpath, const UNatIma* natima);
00130
00131
00132
00133 static int xpmFileReader(UNatDisp*, const char *fpath, UNatIma*& natima);
00134 static int xpmDataReader(UNatDisp*, const char *xpm_data, UNatIma*& natima);
00135 static int gifFileReader(UNatDisp*, const char *fpath, UNatIma*& natima);
00136 static int jpegFileReader(UNatDisp*, const char *fpath,UNatIma*& natima);
00138
00139 #ifndef NO_DOC
00140
00141
00142
00143 protected:
00144 friend class UGraph;
00145 friend class UIma;
00146 friend class UPix;
00147 friend class UNatPix;
00148
00149 UNatDisp *natdisp;
00150 UX_Image xima, ximashape;
00151 int lscale;
00152
00153 #ifdef WITH_GL
00154 GLuint glIma;
00155 unsigned char *imaData;
00156 bool createGLTexture(UNatDisp*);
00157 #endif
00158 #endif
00159 };
00160
00161
00162
00163
00164 class UNatPix {
00165 friend class UGraph;
00166 friend class UPix;
00167 UNatDisp *natdisp;
00168 UX_Pixmap xpix, xpixshape;
00169 u_dim width, height;
00170 int depth, lscale;
00171 #ifdef WITH_GL
00172 GLuint glIma;
00173 #endif
00174
00175 public:
00176
00177
00178 UNatPix(UNatDisp*, UX_Pixmap xpix, UX_Pixmap xpixshape,
00179 u_dim width, u_dim height, int depth);
00180
00181
00182
00183
00184 UNatPix(UNatDisp*, UX_Image xima, UX_Image ximashape);
00185 UNatPix(UNatDisp*, UNatIma*);
00186 ~UNatPix();
00187
00188 void set(UX_Image xima, UX_Image ximashape);
00189
00190 u_dim getWidth() const {return width;}
00191 u_dim getHeight() const {return height;}
00192 bool isRealized() const {return xpix != None;}
00193 bool isShaped() const {return xpixshape != None;}
00194 const UX_Pixmap getXPixmap() const {return xpix;}
00195 const UX_Pixmap getXPixmapShape() const {return xpixshape;}
00196 };
00197
00198 #endif
00199
00200