openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] Writing out to file : one tile at a time


From: Michel Lerenard
Subject: Re: [Openexr-devel] Writing out to file : one tile at a time
Date: Mon, 02 Jun 2014 09:38:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130809 Thunderbird/17.0.8

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
address@hidden
https://lists.nongnu.org/mailman/listinfo/openexr-devel


reply via email to

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