openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] Writing a tiled Rgba image file with tiles given


From: Florian Kainz
Subject: Re: [Openexr-devel] Writing a tiled Rgba image file with tiles given
Date: Tue, 03 Mar 2009 15:07:14 -0800
User-agent: Mozilla Thunderbird 1.0 (X11/20041207)

Hi Werner,

Thank you for your mail.

Class TiledRgbaOutputFile can already be used with a single-tile
buffer.  The base pointer in setFrameBuffer always points to the
memory location where pixel (0,0) would be if it existed.  If your
buffer contains only a single tile, and that tile does not include
pixel (0,0), then the base pointer just points outside the buffer.
This may seem weird, but it works.  For a more detailed explanation
please see section 2.2, Writing a Cropped Image, of this document:

    http://www.openexr.com/ReadingAndWritingImageFiles.pdf

Still, your library patch would make it possible to reduce the
number of setFrameBuffer calls when a file is read or written using
a single-tile frame buffer.

In its current form the patch is incomplete: the new flag has no
effect on YA (gray-scale + alpha) files.  Also, in order to be more
useful in conjunction with writeTiles (as opposed to writeTile),
setFrameBuffer should have separate "tile-relative coordinates"
flags for x and y.

Florian



Werner Benger wrote:
Greetings,

I found a limitation in the class TiledRgbaOutputFile as provided in the IlmImf library, in that it seems to not allow writing a tile from a buffer that only contains this tile. By default it assumes that the provided pointer is relative to an absolute buffer that contains the entire image. However, the underlying
class "Slice" already supports such relative data, and it's straightforward
to just pass this parameter to the creation of such slices.

Here are the modifications I made to the library, as I did not find another
way to achieve the same. These changes seem to be simple and don't break any
existing code while it just works for me then.

Best regards,

    Werner


==========================
In file ImgTiledRgbaFile.h : 170

    void        setFrameBuffer (const Rgba *base,
                    size_t xStride,
                    size_t yStride,
                    bool   relativeBase = false);



========================
In file ImgTiledRgbaFile.cpp : 374

void
TiledRgbaOutputFile::setFrameBuffer (const Rgba *base,
                     size_t xStride,
                     size_t yStride,
                     bool   relativeBase)
{
  ...

fb.insert ("R", Slice (HALF, (char *) &base[0].r, xs, ys, 1,1, 0.0, relativeBase, relativeBase) ); fb.insert ("G", Slice (HALF, (char *) &base[0].g, xs, ys, 1,1, 0.0, relativeBase, relativeBase) ); fb.insert ("B", Slice (HALF, (char *) &base[0].b, xs, ys, 1,1, 0.0, relativeBase, relativeBase) ); fb.insert ("A", Slice (HALF, (char *) &base[0].a, xs, ys, 1,1, 0.0, relativeBase, relativeBase) );
...
}

========================







reply via email to

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