[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Openexr-devel] Problems reading image data - I'm sure it must be someth
From: |
Hugh Macdonald |
Subject: |
[Openexr-devel] Problems reading image data - I'm sure it must be something obvious.... |
Date: |
Wed, 28 Mar 2007 11:29:45 +0100 |
Hi all,
I'm kinda new to OpenEXR development - I've been trying a few things
in the past couple of days, but am a little stuck on one thing at the
moment...
I need to look at each pixel in an image, so I'm reading the image
into an Array2D<Rgba> using:
-----------------------------------------------------
const Box2i dataWindow = inFileHeader.dataWindow();
int dataWidth = dataWindow.max.x - dataWindow.min.x + 1;
int dataHeight = dataWindow.max.y - dataWindow.min.y + 1;
Array2D<Rgba> pixels (dataHeight, dataWidth);
inFile.setFrameBuffer (&pixels[0][0] - dataWindow.min.x -
dataWindow.min.y * dataWidth, 1, dataWidth);
inFile.readPixels (dataWindow.min.y, dataWindow.max.y);
-----------------------------------------------------
I then (and I think that this is where I'm getting confused) look
through the pixels with:
-----------------------------------------------------
for(x = 0; x < pixelsWidth; x++)
{
for(y = 0; y < pixelsHeight; y++)
{
int pixelAddr = y + (x * pixelsHeight);
const Rgba *thisPixel = pixels[pixelAddr];
cout << "At: " << x << "," << y << " (addr: " << pixelAddr << ") :
"
<< thisPixel->r << "," << thisPixel->g << "," << thisPixel->b << ","
<< thisPixel->a << endl;
}
}
-----------------------------------------------------
The image I'm testing this on is a grad, and looking at the printout
of the colour values, I can tell that the addressing is going in y,
starting from the top left. However, when it gets to the bottom left
of the image, I get some erroneous pixel values before the whole
program seg faults.
Any ideas? Please tell me I'm being an idiot somewhere along the line....
Any suggestions more than welcome!
--
Hugh Macdonald
Rainmaker London
- [Openexr-devel] Problems reading image data - I'm sure it must be something obvious....,
Hugh Macdonald <=