openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] Reading EXR image with


From: Kugan Vivekanandarajah
Subject: [Openexr-devel] Reading EXR image with
Date: Tue, 24 Aug 2010 11:16:39 +0800

Hi All,

I am trying to read exr image as RGB into a buffer. However,it seems to be read into 
an offset instead of being coping at the beginning. Therefore, when i view the image, 
it starts at offset say x=180, y= 3 for an image with Width=610 and height = 406. 
I am using the images  provided in the  OpenEXR website.

I am using the following code fragment to read. when i use the RGBA interface to read, 
it seem to work fine. 

Imf::InputFile imfFile("file.exr");    
Box2i dw = imfFile.header().dataWindow();
int Width  = dw.max.x - dw.min.x + 1;
int Height = dw.max.y - dw.min.y + 1;
int bpc = sizeof(half);        
int bpp = 3 * sizeof(half);     
int bpr = bpp * Width;          

Imf::FrameBuffer fb;
fb.insert("R", Imf::Slice(Imf::HALF, p_Data + 0 * bpc - (dw.min.x + dw.min.y * Width) * bpp, bpp, bpr,1, 1, 0.0));
fb.insert("G", Imf::Slice(Imf::HALF, p_Data + 1 * bpc - (dw.min.x + dw.min.y * Width) * bpp, bpp, bpr, 1, 1, 0.0));
fb.insert("B", Imf::Slice(Imf::HALF, p_Data + 2 * bpc - (dw.min.x + dw.min.y * Width) * bpp, bpp, bpr, 1,1, 0.0));
imfFile.setFrameBuffer(fb);
imfFile.readPixels (dw.min.y, dw.max.y);


I must be doing something obviously wrong, but not able to spot it. any pointers reference highly appreciate it.

Kugan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]