[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: |
Mon, 14 Apr 2003 19:45:07 -0700 |
Charles Henrich wrote:
>
> So do I need to have a frame buffer for each slice (for this scanline) I wish
> to write inserted before calling write pixels, or can I just iterativly create
> a single slice single line frame buffer and cal writePixels on it? Does
> writePixels take the scanline to write, or the number of scanlines to write?
> Assuming its number of scanlines, that means I must preallocate a single
> scanline of pixels for all channels I wish to write an then blast them all at
> once. Is that correct? Ideally I could just write a single scanline per
> channel without having to pack all the framebuffers in advance :)
>
> -Crh
>
> > It's more complicated than that if you don't want to have all of the pixels
> > in memory at once - you have to reset the baseAddress each time you change
> > the current scanline. Check out Florian's tutorial at www.openexr.com.
> >
> > - Paul
>
> Charles Henrich address@hidden
>
> http://www.sigbus.com/~henrich
>
> _______________________________________________
> Openexr-devel mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/openexr-devel
The argument to writePixels() is the number of scan lines to write,
not the y coordinate of a scan line (see header file ImfOutputFile.h,
or http://www.openexr.com/api.html).
You have to generate the whole scan line (all channels) before you
can store it in the file.
Here's some sample code; maybe it helps answering your questions:
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;
vector<float> zPixels;
//
// 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]) * 1, // 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)
{
g[x] = ...;
z[x] = ...;
file.writePixels (height);
}
}
}
- [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 <=
- Re: [Openexr-devel] Writing scanline at a time, Charles Henrich, 2003/04/15
- Re: [Openexr-devel] Writing scanline at a time, Florian Kainz, 2003/04/15
- [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