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: Peter Hillman
Subject: Re: [Openexr-devel] Writing out to file : one tile at a time
Date: Thu, 29 May 2014 17:58:02 +1200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

You may have to use the Imf::TiledOutputFile class instead of the TiledRgbaOutputFile class. Insert the RGBA channels into a header object and into the framebuffer yourself, setting "xTileCoords" and "yTileCoords" to 1. Then your whitePixels and blackPixels arrays need only be tileWidth*tileHeight pixels.
The ReadingAndWritingImageFiles pdf has an example of Using the "General Interface for Writing a Tiled Image File" which you could adapt to use tileCoords.

On 29/05/14 05:36, 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]