[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-devel] Writing scanline at a time
From: |
Florian Kainz |
Subject: |
Re: [Openexr-devel] Writing scanline at a time |
Date: |
Tue, 15 Apr 2003 09:08:51 -0700 |
Charles Henrich wrote:
>
> > for (int y = 0; y < height; ++y)
> > {
> > for (int x = 0; x < width; ++x)
> > {
> > g[x] = ...;
> > z[x] = ...;
> >
> > file.writePixels (height);
> > }
> > }
>
> Im thinking that file.writePixels(height) is meant to be in the outerloop
> yeah? This would be a good sample for the web pages!
>
> -Crh
>
> Charles Henrich address@hidden
>
> http://www.sigbus.com/~henrich
You are correct; writePixels should be in the outer loop. Also, the
argument to writePixels should be 1, not height. Looking at the example
just now, I noticed a few more errors (I was in a bit of a hurry yesterday).
Here's a corrected version:
void
writeImage (const char fileName[], int width, int height)
{
//
// Open an image file by creating an OutputFile object.
// The image file will contain two channels, G, of type
// HALF, and Z, of type FLOAT.
//
Header header (width, height);
header.channels().insert ("G", Channel (HALF));
header.channels().insert ("Z", Channel (FLOAT));
OutputFile file (fileName, header);
//
// Allocate memory to hold one scan line.
//
vector<half> gPixels (width);
vector<float> zPixels (width);
//
// Create a FrameBuffer object that tells the OutputFile
// where to find the pixels for our image. Note that yStride
// is 0, which means that all scan lines live at the same
// memory address.
//
FrameBuffer frameBuffer;
frameBuffer.insert ("G", // name
Slice (HALF, // type
(char *) &gPixels[0], // base
sizeof (gPixels[0]), // xStride
0)); // yStride
frameBuffer.insert ("Z", // name
Slice (FLOAT, // type
(char *) &zPixels[0], // base
sizeof (zPixels[0]), // xStride
0)); // yStride
file.setFrameBuffer (frameBuffer);
//
// Generate the image one scan line at a time,
// and store each scan line in the file immediately.
//
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
gPixels[x] = ...;
zPixels[x] = ...;
}
file.writePixels (1);
}
}
- [Openexr-devel] Writing scanline at a time, Charles Henrich, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Nafees Bin Zafar, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Nafees Bin Zafar, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Paul Schneider, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Nafees Bin Zafar, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Charles Henrich, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Paul Schneider, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Florian Kainz, 2003/04/14
- Re: [Openexr-devel] Writing scanline at a time, Charles Henrich, 2003/04/15
- Re: [Openexr-devel] Writing scanline at a time,
Florian Kainz <=
- [Openexr-devel] Origin?, Charles Henrich, 2003/04/15
- [Openexr-devel] Re: Origin?, Florian Kainz, 2003/04/15
- Re: [Openexr-devel] Writing scanline at a time, Charles Henrich, 2003/04/15