15 #include <ImfRgbaFile.h>
16 #include <ImfStandardAttributes.h>
18 #include <ImfInputFile.h>
19 #include <ImfBoxAttribute.h>
20 #include <ImfChannelListAttribute.h>
21 #include <ImfCompressionAttribute.h>
22 #include <ImfFloatAttribute.h>
23 #include <ImfIntAttribute.h>
24 #include <ImfLineOrderAttribute.h>
25 #include <ImfStringAttribute.h>
26 #include <ImfVecAttribute.h>
28 #include <ImfConvert.h>
35 #include <tdeprocess.h>
36 #include <tdelocale.h>
37 #include <kgenericfactory.h>
41 #include <tqcstring.h>
43 #include <tqdatetime.h>
45 #include <tqvalidator.h>
56 TQRgb RgbaToQrgba(
struct Rgba imagePixel)
68 r = imagePixel.r * 5.55555;
69 g = imagePixel.g * 5.55555;
70 b = imagePixel.b * 5.55555;
71 a = imagePixel.a * 5.55555;
91 r = 1.0 + Imath::Math<float>::log ((r-1.0) * 0.184874 + 1) / 0.184874;
93 g = 1.0 + Imath::Math<float>::log ((g-1.0) * 0.184874 + 1) / 0.184874;
95 b = 1.0 + Imath::Math<float>::log ((b-1.0) * 0.184874 + 1) / 0.184874;
97 a = 1.0 + Imath::Math<float>::log ((a-1.0) * 0.184874 + 1) / 0.184874;
101 r = Imath::Math<float>::pow (r, 0.4545);
102 g = Imath::Math<float>::pow (g, 0.4545);
103 b = Imath::Math<float>::pow (b, 0.4545);
104 a = Imath::Math<float>::pow (a, 0.4545);
111 return tqRgba(
char (Imath::clamp ( r * 84.66f, 0.f, 255.f ) ),
112 char (Imath::clamp ( g * 84.66f, 0.f, 255.f ) ),
113 char (Imath::clamp ( b * 84.66f, 0.f, 255.f ) ),
114 char (Imath::clamp ( a * 84.66f, 0.f, 255.f ) ) );
117 TDE_EXPORT
void kimgio_exr_read( TQImageIO *io )
124 RgbaInputFile file (TQFile::encodeName(io->fileName()));
125 Imath::Box2i dw = file.dataWindow();
127 width = dw.max.x - dw.min.x + 1;
128 height = dw.max.y - dw.min.y + 1;
130 Array2D<Rgba> pixels;
131 pixels.resizeErase (height, width);
133 file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
134 file.readPixels (dw.min.y, dw.max.y);
136 TQImage image(width, height, 32, 0, TQImage::BigEndian);
141 for (
int y=0; y < height; y++ ) {
142 for (
int x=0; x < width; x++ ) {
144 image.setPixel( x, y, RgbaToQrgba( pixels[y][x] ) );
148 io->setImage( image );
151 catch (
const std::exception &exc)
153 kdDebug(399) << exc.what() << endl;
159 TDE_EXPORT
void kimgio_exr_write(TQImageIO *)