Re: Writing out to file : one tile at a time
Michel Lerenard <[email protected]>
| Newsgroups | gmane.comp.video.openexr.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
i've been there a few weeks back, the thing to understand if that the
FrameBuffer and the Imf image will always work as if the data buffer was
covering the whole image. You can't restrict a Framebuffer to work on a
part of the image by, for example, giving it a size.
What you'll need to do to write one tile is to configure the FrameBuffer
with a pointer pointing to the address at which you buffer would start
if it was covering the whole image. The rest is all pointer arithmetic.
Typically if you're willing to write a tile that covers the region
256/128 : 287/163 ( a 32*32 tile starting at 256/128 ), and your data
buffer contains data for the current tile only, call:
out.setFrameBuffer (mybuffer - 256 * 128 * pixelSize , pixelSize,
tileWidth * pixelSize);
where mybuffer is a char*, pixelSize gives the memory size of an item.
(char = 1, half= 2, float = 4)
On 05/28/2014 07:36 PM, Nicholas Yue wrote:
> Hi,
>
> I am writing out a checker image to better understand setFramebuffer
> and writeTile
>
> The current version I have stores the "entire" width+height black
> and white pixel data and choose from there.
>
> I am hoping to find a way, possibly in setFramebuffer, where I can
> supply a tile size pixel data (one black, one white) to choose from
> rather than an entire width/height version which defeats the purpose
> of being able to handle/process pixels on a tile by tile basis.
>
> 8<--------------------------------------------
> void writeChecker (const char fileName[],
> int width, int height,
> int tileWidth, int tileHeight)
> {
> Imf::TiledRgbaOutputFile out (fileName,
> width, height, // image size
> tileWidth, tileHeight, // tile size
> Imf::ONE_LEVEL, // level mode
> Imf::ROUND_DOWN, // rounding mode
> Imf::WRITE_RGBA); // channels in
> file // 1
> int xTileCount = out.numXTiles();
> int yTileCount = out.numYTiles();
>
> RgbaArray whitePixels;
> whitePixels.resize(boost::extents[width][height]);
>
> for (RgbaArray::index h=0;h<height;h++)
> for (RgbaArray::index w=0;w<width;w++)
> {
> whitePixels[w][h] = whitePixel;
> }
>
> RgbaArray blackPixels;
> blackPixels.resize(boost::extents[width][height]);
>
> for (RgbaArray::index h=0;h<height;h++)
> for (RgbaArray::index w=0;w<width;w++)
> {
> blackPixels[w][h] = blackPixel;
> }
>
> for (int y=0;y<yTileCount;y++)
> for (int x=0;x<xTileCount;x++)
> {
> bool isWhite = checkeredWhite(x,y);
>
> if (isWhite)
> out.setFrameBuffer (whitePixels.data(), 1, tileWidth);
> else
> out.setFrameBuffer (blackPixels.data(), 1, tileWidth);
> out.writeTile (x,y);
> }
> }
> 8<--------------------------------------------
> Cheers
> --
> Nicholas Yue
> Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
> Custom Dev - C++ porting, OSX, Linux, Windows
> http://au.linkedin.com/in/nicholasyue
> https://vimeo.com/channels/naiadtools
>
>
> _______________________________________________
> Openexr-devel mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/openexr-devel
_______________________________________________
Openexr-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/openexr-devel