00001
00019 #include "vetFrameRGBETI.h"
00020
00026 vetFrameRGBETI::vetFrameRGBETI(vetFrameCache& img) : picture(img.width, img.height, 32, 3, 0)
00027 {
00028 *this << img;
00029 }
00030
00031 vetFrameRGBETI::vetFrameRGBETI(vetFrameCache24& img) : picture(img.width, img.height, 32, 3, 0)
00032 {
00033 *this << img;
00034 }
00035
00036 vetFrameRGBETI::vetFrameRGBETI(vetFrameRGB& img) : picture(img.getWidth(), img.getHeight(), 32, 3, 0)
00037 {
00038 *this << img;
00039 }
00040
00041
00042
00043 int vetFrameRGBETI::setPixel(unsigned int x, unsigned int y, PixelRGB p)
00051 {
00052 int ret = get_channel(0).put_GL( x, y, (int)p[0]) +
00053 get_channel(1).put_GL( x, y, (int)p[1]) +
00054 get_channel(2).put_GL( x, y, (int)p[2]) ;
00055
00056 if ( ret )
00057 return VETRET_PARAM_ERR;
00058
00059 return VETRET_OK;
00060 }
00061
00062
00063 int vetFrameRGBETI::getPixel(unsigned int x, unsigned int y, PixelRGB& p)
00071 {
00072 if ( x>(unsigned int)(get_dimx()-1) || y>(unsigned int)(get_dimy()-1) )
00073 return VETRET_PARAM_ERR;
00074
00075 p[0] = get_channel(0).get_GL(x, y);
00076 p[1] = get_channel(1).get_GL(x, y);
00077 p[2] = get_channel(2).get_GL(x, y);
00078
00079 return VETRET_OK;
00080 }
00081
00082
00083
00084 vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameCache& img)
00085 {
00086 INFO("vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameCache& img) [pushing data]")
00087
00088 if ( get_dimx() == 0 || get_dimy() == 0 )
00089 throw "Cannot do that with empty image (no size)";
00090
00091 if ( (unsigned int)get_dimx() != img.width || (unsigned int)get_dimy() != img.height)
00092 {
00093 img.width = (unsigned int)get_dimx();
00094 img.height = (unsigned int)get_dimy();
00095 if ( img.data != NULL )
00096 delete [] img.data;
00097 img.data = new PixelRGB[img.width*img.height];
00098 }
00099
00100 for (unsigned int y = 0; y < img.height; y++)
00101 for (unsigned int x = 0; x < img.width; x++)
00102 {
00103 img.data[y * img.width + x][0] = get_channel(0).get_GL(x, y);
00104 img.data[y * img.width + x][1] = get_channel(1).get_GL(x, y);
00105 img.data[y * img.width + x][2] = get_channel(2).get_GL(x, y);
00106 }
00107
00108 return *this;
00109 }
00110
00111 vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameCache24& img)
00112 {
00113 INFO("vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameCache24& img) [pushing data]")
00114
00115 if ( get_dimx() == 0 || get_dimy() == 0 )
00116 throw "Cannot do that with empty image (no size)";
00117
00118 if ( (unsigned int)get_dimx() != img.width || (unsigned int)get_dimy() != img.height)
00119 {
00120 img.width = (unsigned int)get_dimx();
00121 img.height = (unsigned int)get_dimy();
00122 if ( img.data != NULL )
00123 delete [] img.data;
00124 img.data = new PixelRGB24[img.width*img.height];
00125 }
00126
00127 for (unsigned int y = 0; y < img.height; y++)
00128 for (unsigned int x = 0; x < img.width; x++)
00129 {
00130 img.data[y * img.width + x][0] = (unsigned char)get_channel(0).get_GL(x, y);
00131 img.data[y * img.width + x][1] = (unsigned char)get_channel(1).get_GL(x, y);
00132 img.data[y * img.width + x][2] = (unsigned char)get_channel(2).get_GL(x, y);
00133 }
00134
00135 return *this;
00136 }
00137
00138 vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameRGB& img)
00139 {
00140
00141 vetFrameCache tmp;
00142 *this >> tmp;
00143 img << tmp;
00144
00145 return *this;
00146 }
00147
00148 vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameGrey& img)
00149 {
00150 INFO("vetFrameRGBETI& vetFrameRGBETI::operator >> (vetFrameGrey& img) [pushing data]")
00151
00152 if ( get_dimx() == 0 || get_dimy() == 0 )
00153 throw "Cannot do that with empty image (no size)";
00154
00155 if ( (unsigned int)get_dimx() != img.getWidth() || (unsigned int)get_dimy() != img.getHeight())
00156 throw "Cannot do that with different sized image";
00157
00158 for (unsigned int y = 0; y < img.getHeight(); y++)
00159 for (unsigned int x = 0; x < img.getWidth(); x++)
00160 {
00161 img.setPixel(x, y, (PixelGrey) ( get_channel(0).get_GL(x, y) * RED_COEF +
00162 get_channel(1).get_GL(x, y) * GREEN_COEF +
00163 get_channel(2).get_GL(x, y) * BLUE_COEF )
00164 );
00165 }
00166
00167 return *this;
00168 }
00169
00170
00171
00172 void vetFrameRGBETI::operator << (vetFrameCache& img)
00173 {
00174 INFO("void vetFrameRGBETI::operator << (const vetFrameCache& img) [loading data]")
00175
00176
00177
00178
00179 printf("res: %d\n", inflatesize(img.width, img.height, 32, 3));
00180 printf("w: %d =? %d\n", get_dimx(), img.width);
00181 printf("h: %d =? %d\n", get_dimy(), img.height);
00182
00183 if ( get_dimy() == 0 || get_dimx() == 0 )
00184 throw "Cannot do that with empty image (no size)";
00185
00186 for (unsigned int y = 0; y < img.height; y++)
00187 for (unsigned int x = 0; x < img.width; x++)
00188 {
00189 get_channel(0).put_GL(x, y, img.data[y * img.width + x][0] ) ;
00190 get_channel(1).put_GL(x, y, img.data[y * img.width + x][1] ) ;
00191 get_channel(2).put_GL(x, y, img.data[y * img.width + x][2] ) ;
00192 }
00193
00194 }
00195
00196 void vetFrameRGBETI::operator << (vetFrameCache24& img)
00197 {
00198 INFO("void vetFrameRGBETI::operator << (const vetFrameCache24& img) [loading data]")
00199
00200 if ( (unsigned int)get_dimx() != img.width || (unsigned int)get_dimy() != img.height)
00201 inflatesize(img.width, img.height, 32, 3);
00202
00203 if ( get_dimy() == 0 || get_dimx() == 0 )
00204 throw "Cannot do that with empty image (no size)";
00205
00206 for (unsigned int y = 0; y < img.height; y++)
00207 for (unsigned int x = 0; x < img.width; x++)
00208 {
00209 get_channel(0).put_GL(x, y, (int)img.data[y * img.width + x][0] ) ;
00210 get_channel(1).put_GL(x, y, (int)img.data[y * img.width + x][1] ) ;
00211 get_channel(2).put_GL(x, y, (int)img.data[y * img.width + x][2] ) ;
00212 }
00213
00214 }
00215
00216
00217 void vetFrameRGBETI::operator << (vetFrameRGB& img)
00218 {
00219 INFO("void vetFrameRGBETI::operator << (const vetFrameRGB& img) [loading data]")
00220
00221 vetFrameCache tmp;
00222 img >> tmp;
00223 *this << tmp;
00224
00225 }
00226
00227 void vetFrameRGBETI::operator << (vetFrameGrey& img)
00228 {
00229 INFO("void vetFrameRGBETI::operator << (const vetFrameGrey& img) [loading data]")
00230
00231 vetFrameCache tmp;
00232 img >> tmp;
00233 *this << tmp;
00234
00235 }
00236
00237