00001 #ifndef _RGB16Image_H 00002 #define _RGB16Image_H 00003 00004 00005 00025 #include <stdio.h> 00026 00027 #include "AnImage.hpp" 00028 #include "RImage.hpp" 00029 #include "FImage.hpp" 00030 #include "CImage.hpp" 00031 00032 00033 class RGB16Image : public AnImage 00034 { 00035 private: 00036 00037 unsigned short* palign; 00038 unsigned short* p1; 00039 unsigned short** image; 00040 00041 00042 public: 00043 00044 RGB16Image(int w, int h); 00045 RGB16Image(int w, int h, unsigned short data); 00046 RGB16Image(int w, int h, unsigned short* data); 00047 RGB16Image(int w, int h, unsigned short red, unsigned short green, unsigned short blue); 00048 RGB16Image(int w, int h, unsigned short* red, unsigned short* green, unsigned short* blue); 00049 RGB16Image(RImage& red, RImage& green, RImage& blue); 00050 virtual ~RGB16Image(){ delete[] image; p1=0; delete[] palign; } 00051 00052 00053 virtual unsigned char* getData(){ return (unsigned char*)p1; } 00054 00055 virtual void set(AnImage* src){ setData(src,0); } 00056 00057 virtual void set(FImage& data, int ch=0); 00058 virtual void set(RImage& data, int ch=0); 00059 virtual void set(CImage& data, int ctype=0, int ch=0); 00060 virtual void setChannel(AnImage* channel, int ch=0); 00061 virtual void setValues(unsigned short value); 00062 00063 virtual AnImage* copy(); 00064 00065 // data limits of each image type 00066 virtual int getMinBoundaryValue(){ return 0; } 00067 virtual int getMaxBoundaryValue(){ return 65535; } 00068 virtual int getPower2MaxRangeBoundary(){ return 16; } 00069 00070 virtual AnImage* flipHorizontal(); 00071 virtual AnImage* flipVertical(); 00072 00073 virtual AnImage* rotate90Left(); 00074 virtual AnImage* rotate90Right(); 00075 virtual AnImage* rotate180(); 00076 00077 virtual AnImage* scaleDown(int multiplier=2); 00078 virtual AnImage* scaleUp(int multiplier=2); 00079 virtual AnImage* scaleUp(int multiplier, int r, int g, int b); 00080 virtual AnImage* zeroInterleaving(); 00081 00082 virtual AnImage* partImage(int x0=0, int y0=0, int w=256, int h=256); 00083 virtual AnImage* subImage(int x0, int y0, int x1, int y1); 00084 virtual AnImage* smallImage(double xscale, double yscale); 00085 virtual AnImage* smallImage(int width); 00086 00087 virtual int available8BitsColors(); 00088 00089 virtual void setData(AnImage* src, AnImage* mask=0); 00090 00091 virtual int getRed(int x, int y){ return image[y][x*3]; } 00092 virtual int getGreen(int x, int y){ return image[y][x*3+1]; } 00093 virtual int getBlue(int x, int y){ return image[y][x*3+2]; } 00094 virtual int getGrey(int x, int y) // luminance 00095 { return (3*getRed(x,y)+5*getGreen(x,y)+2*getBlue(x,y))/10; } 00096 00097 virtual void setRed(int x, int y, int value){ image[y][x*3]=value; } 00098 virtual void setGreen(int x, int y, int value){ image[y][x*3+1]=value; } 00099 virtual void setBlue(int x, int y, int value){ image[y][x*3+2]=value; } 00100 virtual void setGrey(int x, int y, int value) 00101 { 00102 image[y][x*3]=value; 00103 image[y][x*3+1]=value; 00104 image[y][x*3+2]=value; 00105 } 00106 00107 virtual void set(int x, int y, int rgb){ /* do nothing */ } 00108 virtual int get(int x, int y) 00109 { return (3*getRed(x,y)+5*getGreen(x,y)+2*getBlue(x,y))/10; } 00110 00111 // RGB simulation 00112 virtual void setRGB(int x, int y, int r, int g, int b) 00113 { 00114 image[y][x*3]=r; 00115 image[y][x*3+1]=g; 00116 image[y][x*3+2]=b; 00117 } 00118 00119 00120 virtual int getRGB(int x, int y){ /* do nothing */ return 0; } 00121 00122 virtual void report(FILE* file); 00123 virtual void output(); 00124 }; 00125 00126 #endif