openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] Writing scanline at a time


From: Paul Schneider
Subject: Re: [Openexr-devel] Writing scanline at a time
Date: Mon, 14 Apr 2003 19:28:39 -0700


Charles,

There appear to be two issues here: writing one channel at a time, and writing one scanline at a time. Slices are the way to go to split out the channel writing - I don't know that they'll help you split up the scanlines. From your original message, I thought you were concerned about writing without having all the scanlines in memory.

I think I can help with part of your problem. Here's some pseudo-code that writes out RGBA channels one scanline at a time, without having to have a big buffer containing all the scanlines at once.

Header                          header  (w,
                                                         h,
                                                         1,
                                                         Imath::V2f (0, 0),
                                                         1,
                                                         Imf::INCREASING_Y,
                                                         Imf::ZIP_COMPRESSION);

RgbaOutputFile          out             (path, header, WRITE_RGBA);
Array2D<Rgba>             p2              (1, h);

for (int y = 0; y < h; ++y)
{
        // fill buffer with one scanline
        
        fillBuffer (p2, y);     // magic function
                                                        
        
        // write scanline
        
        out.setFrameBuffer (&p2[-y][0], 1, h);
        out.writePixels (1);    
}

I believe that for general channel writing, you can either create a separate FrameBuffer for each channel, or interleave your channels into a single FrameBuffer. Either way, you set everything up, and then call writePixels() - I don't think you can write one channel, then insert another channel and write that. In other words, we don't insert channels into files on disk.

So, you're correct - you need buffers for each channel of the scanline you're going to write in memory, and then you call writePixels() once. It might help your organization, if not your memory requirements, to split the channels into separate FrameBuffers.

Hopefully, Florian or Drew will correct me if I got any of this wrong.

- Paul



On Monday, April 14, 2003, at 06:35 PM, 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





reply via email to

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