Lines Matching refs:rgbe
44 #include "rgbe.hpp"
52 // This file contains code to read and write four byte rgbe file format
53 // developed by Greg Ward. It handles the conversions between rgbe and
90 CV_Error(cv::Error::StsError, "RGBE read error");
93 CV_Error(cv::Error::StsError, "RGBE write error");
96 CV_Error(cv::Error::StsError, cv::String("RGBE bad file format: ") +
101 CV_Error(cv::Error::StsError, cv::String("RGBE error: \n") +
107 /* standard conversion from float pixels to rgbe pixels */
110 float2rgbe(unsigned char rgbe[4], float red, float green, float blue)
119 rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
123 rgbe[0] = (unsigned char) (red * v);
124 rgbe[1] = (unsigned char) (green * v);
125 rgbe[2] = (unsigned char) (blue * v);
126 rgbe[3] = (unsigned char) (e + 128);
130 /* standard conversion from rgbe to float pixels */
134 rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4])
138 if (rgbe[3]) { /*nonzero pixel*/
139 f = static_cast<float>(ldexp(1.0,rgbe[3]-(int)(128+8)));
140 *red = rgbe[0] * f;
141 *green = rgbe[1] * f;
142 *blue = rgbe[2] * f;
151 const char *programtype = "RGBE";
235 unsigned char rgbe[4];
238 float2rgbe(rgbe,data[RGBE_DATA_RED],
241 if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1)
250 unsigned char rgbe[4];
253 if (fread(rgbe, sizeof(rgbe), 1, fp) < 1)
256 &data[RGBE_DATA_BLUE],rgbe);
322 unsigned char rgbe[4];
334 rgbe[0] = 2;
335 rgbe[1] = 2;
336 rgbe[2] = static_cast<unsigned char>(scanline_width >> 8);
337 rgbe[3] = scanline_width & 0xFF;
338 if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) {
343 float2rgbe(rgbe,data[RGBE_DATA_RED],
345 buffer[i] = rgbe[0];
346 buffer[i+scanline_width] = rgbe[1];
347 buffer[i+2*scanline_width] = rgbe[2];
348 buffer[i+3*scanline_width] = rgbe[3];
368 unsigned char rgbe[4], *scanline_buffer, *ptr, *ptr_end;
378 if (fread(rgbe,sizeof(rgbe),1,fp) < 1) {
382 if ((rgbe[0] != 2)||(rgbe[1] != 2)||(rgbe[2] & 0x80)) {
384 rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],&data[RGBE_DATA_BLUE],rgbe);
389 if ((((int)rgbe[2])<<8 | rgbe[3]) != scanline_width) {
438 rgbe[0] = scanline_buffer[i];
439 rgbe[1] = scanline_buffer[i+scanline_width];
440 rgbe[2] = scanline_buffer[i+2*scanline_width];
441 rgbe[3] = scanline_buffer[i+3*scanline_width];
443 &data[RGBE_DATA_BLUE],rgbe);