00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029
00030
00031
00032 #ifndef __IMAGE_HEADERFILE__
00033 #define __IMAGE_HEADERFILE__
00034
00035 #include "PocketKnife.h"
00036
00037
00038 namespace PN {
00039
00041
00042 class Image
00043 {
00044 public:
00046
00050 static Image* createFromPixelBuffer(int nWidth, int nHeight, unsigned short* nPixels, bool nOwner);
00051
00052 virtual ~Image()
00053 {
00054 if( pixelsOwner )
00055 delete[] pixels;
00056 }
00057
00059 int getWidth() const { return width; }
00060
00062 int getHeight() const { return height; }
00063
00065 void setTransparentColor(int nRed, int nGreen, int nBlue);
00066
00068 void clear(int nRed, int nGreen, int nBlue);
00069
00071 void clear(unsigned short nColor);
00072
00074
00081 void drawImage(int nX, int nY, const Image* nImage,
00082 int nSx0, int nSy0, int nSx1, int nSy1,
00083 bool nTransparent=false);
00084
00086
00091 void drawImage(int nX, int nY, const Image* nImage, bool nTransparent=false);
00092
00093
00095
00099 void fillRect(int nX0, int nY0, int nX1, int nY1, int nRed, int nGreen, int nBlue, int nTransparency=0);
00100
00102
00106 void fillRect(int nX0, int nY0, int nX1, int nY1, unsigned short nColor, int nTransparency=0);
00107
00109
00112 void drawLine(int x1, int y1, int x2, int y2, unsigned short col);
00113
00115
00118 void drawLine(int x1, int y1, int x2, int y2, int r, int g, int b);
00119
00121
00124 void setPixel(int x, int y, unsigned short col);
00125
00127
00130 void setPixel(int x, int y, int r, int g, int b);
00131
00133 unsigned short* getPixels() { return pixels; }
00134
00136 const unsigned short* getPixels() const { return pixels; }
00137
00139
00142 unsigned short getPixel(int nX, int nY) const { return pixels[nY*width+nX]; }
00143
00145
00149 void setPixels(int nWidth, int nHeight, unsigned short* nPixels, bool nPixelsOwner);
00150
00151 unsigned short getColorKey() const { return colorKey; }
00152
00153 protected:
00154 Image(int nWidth, int nHeight, unsigned short* nPixels, bool nPixelsOwner)
00155 : width(nWidth), height(nHeight), pixels(nPixels), pixelsOwner(nPixelsOwner)
00156 {}
00157
00158
00159 Image(Image* nImage)
00160 : width(nImage->width), height(nImage->height), pixels(nImage->pixels), pixelsOwner(true)
00161 {
00162 nImage->pixelsOwner = false;
00163 }
00164
00165 int width, height;
00166 unsigned short* pixels;
00167 bool pixelsOwner;
00168
00169 unsigned short colorKey;
00170 };
00171
00172 }
00173
00174
00175 #endif //__IMAGE_HEADERFILE__