17 #include <ImfRgbaFile.h>
18 #include <ImfStandardAttributes.h>
20 #include <ImfInputFile.h>
21 #include <ImfBoxAttribute.h>
22 #include <ImfChannelListAttribute.h>
23 #include <ImfCompressionAttribute.h>
24 #include <ImfFloatAttribute.h>
25 #include <ImfIntAttribute.h>
26 #include <ImfLineOrderAttribute.h>
27 #include <ImfStringAttribute.h>
28 #include <ImfVecAttribute.h>
30 #include <ImfConvert.h>
39 #include <kgenericfactory.h>
43 #include <tqcstring.h>
45 #include <tqdatetime.h>
47 #include <tqvalidator.h>
58 QRgb RgbaToQrgba(
struct Rgba imagePixel)
70 r = imagePixel.r * 5.55555;
71 g = imagePixel.g * 5.55555;
72 b = imagePixel.b * 5.55555;
73 a = imagePixel.a * 5.55555;
93 r = 1.0 + Imath::Math<float>::log ((r-1.0) * 0.184874 + 1) / 0.184874;
95 g = 1.0 + Imath::Math<float>::log ((g-1.0) * 0.184874 + 1) / 0.184874;
97 b = 1.0 + Imath::Math<float>::log ((b-1.0) * 0.184874 + 1) / 0.184874;
99 a = 1.0 + Imath::Math<float>::log ((a-1.0) * 0.184874 + 1) / 0.184874;
103 r = Imath::Math<float>::pow (r, 0.4545);
104 g = Imath::Math<float>::pow (g, 0.4545);
105 b = Imath::Math<float>::pow (b, 0.4545);
106 a = Imath::Math<float>::pow (a, 0.4545);
113 return tqRgba(
char (Imath::clamp ( r * 84.66f, 0.f, 255.f ) ),
114 char (Imath::clamp ( g * 84.66f, 0.f, 255.f ) ),
115 char (Imath::clamp ( b * 84.66f, 0.f, 255.f ) ),
116 char (Imath::clamp ( a * 84.66f, 0.f, 255.f ) ) );
119 KDE_EXPORT
void kimgio_exr_read( TQImageIO *io )
126 RgbaInputFile file (TQFile::encodeName(io->fileName()));
127 Imath::Box2i dw = file.dataWindow();
129 width = dw.max.x - dw.min.x + 1;
130 height = dw.max.y - dw.min.y + 1;
132 Array2D<Rgba> pixels;
133 pixels.resizeErase (height, width);
135 file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
136 file.readPixels (dw.min.y, dw.max.y);
138 TQImage image(width, height, 32, 0, TQImage::BigEndian);
143 for (
int y=0; y < height; y++ ) {
144 for (
int x=0; x < width; x++ ) {
146 image.setPixel( x, y, RgbaToQrgba( pixels[y][x] ) );
150 io->setImage( image );
153 catch (
const std::exception &exc)
155 kdDebug(399) << exc.what() << endl;
161 KDE_EXPORT
void kimgio_exr_write(TQImageIO *)