Writing out to file : one tile at a time

Nicholas Yue <[email protected]>
Newsgroups gmane.comp.video.openexr.devel
Message-ID <CADYXiJKknqxPGFEB4f=bBV_BX-N+NKhMetBH-ZaGk2mpPAHxKg@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.