00001 #ifndef _ByteImage_H 00002 #define _ByteImage_H 00003 00004 #include <stdio.h> 00005 00006 00007 00026 #include "AnImage.hpp" 00027 #include "RImage.hpp" 00028 #include "FImage.hpp" 00029 #include "CImage.hpp" 00030 00031 class ByteImage : public AnImage 00032 { 00033 private: 00034 unsigned char* palign; 00035 unsigned char* p1; 00036 unsigned char** image; 00037 00038 protected: 00039 00040 void beltramiGRestoration(int iterations, double coeff, RImage* im); 00041 00042 public: 00043 00044 ByteImage(int w, int h); 00045 ByteImage(int w, int h, unsigned char data); 00046 ByteImage(int w, int h, unsigned char* data); 00047 ByteImage(RImage& data); 00048 virtual ~ByteImage(){ delete[] image; delete[] palign; p1=0; } 00049 00050 virtual AnImage* copy() 00051 { 00052 return new ByteImage(width,height, p1); 00053 } 00054 00055 virtual AnImage* rotate90Left(); 00056 virtual AnImage* rotate90Right(); 00057 00058 virtual AnImage* scaleDown(int multiplier=2); 00059 virtual AnImage* scaleUp(int multiplier=2); 00060 virtual AnImage* zeroInterleaving(); 00061 00062 virtual AnImage* partImage(int x0=0, int y0=0, int w=256, int h=256); 00063 virtual AnImage* subImage(int x0, int y0, int x1, int y1); 00064 virtual AnImage* smallImage(double xscale, double yscale); 00065 virtual AnImage* smallImage(int newWidth); 00066 00067 virtual int available8BitsColors(); 00068 00069 virtual void set(FImage& data, int ch=0); 00070 virtual void set(RImage& data, int ch=0); 00071 virtual void set(CImage& data, int ctype=0, int ch=0); 00072 virtual void setValues(unsigned char value); 00073 00074 virtual void setChannel(AnImage* channel, int ch=0); 00075 00076 00077 virtual int getRed(int x, int y){ return image[y][x]; } 00078 virtual int getGreen(int x, int y){ return image[y][x]; } 00079 virtual int getBlue(int x, int y){ return image[y][x]; } 00080 virtual int getGrey(int x, int y){ return image[y][x]; } 00081 00082 virtual void setRed(int x, int y, int value){ image[y][x]=value; } 00083 virtual void setGreen(int x, int y, int value){ image[y][x]=value; } 00084 virtual void setBlue(int x, int y, int value){ image[y][x]=value; } 00085 virtual void setGrey(int x, int y, int value){ image[y][x]=value; } 00086 00087 virtual void set(int x, int y, int value){ image[y][x]=value; } 00088 virtual int get(int x, int y) 00089 { return image[y][x]; } 00090 00091 // RGB simulation 00092 virtual void setRGB(int x, int y, int r, int g, int b) 00093 { 00094 int val= (3*r+5*g+2*b)/10; 00095 00096 image[y][x]=val; 00097 } 00098 00099 virtual unsigned char* getData(){ return p1; } 00100 00101 virtual void restaure(int iterations, double coeff); 00102 virtual void restaure(int type, int iterations, double coeff); 00103 00104 virtual void report(FILE* file); 00105 virtual void output(); 00106 }; 00107 00108 #endif