Hi,

I would like to read exr files with linear color space. For that I'm using OIIO but my viewer(Qt's QGraphicsView) shows the picture with sRGB color space. How should I read log or linear color space inputs? Should I use OpenColorIO for that task or develop an algorithm that converts from sRGB to linear(lookup table)? I've copied the piece of code that it's reading the file. Could you tell me if I'm reading correctly the files?

QImage newQImage( spec.width, spec.height, QImage::Format_RGB32 );
int size = spec.width*spec.nchannels;
for (int y = 0; y < spec.height; y++) {
        unsigned char *pixels = new unsigned char[ size ];
        in->read_scanline( y+spec.y, 0+spec.z, TypeDesc::UINT8, pixels );
        for ( int x = 0; x < spec.width; x++ )
        {
            float r = 0;
            float g = 0;
            float b = 0;

            unsigned char *p = ( (unsigned char*) (pixels) );
            for(int i=0; i<spec.nchannels; ++i)
            {
                int mod = i%spec.nchannels;
                if(mod ==0)
                {
                    r = ((*p) & 0xff);
                }
                else if(mod ==1)
                {
                    g = ((*p) & 0xff);
                }
                else if(mod ==2)
                {
                    b = ((*p) & 0xff);
                }
                p++;
            }
           newQImage.setPixel( x, y, qRgb( r, g, b ) );
           pixels = p;
        }
    }

Thank you very much,

Jero

_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to