reading a random tile

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

reading a random tile

Barnaby Robson
Could I get some help on reading a single random tile ?
 
The origin of the tile is (x,y)
I am setting up my variables like this. (inTiledFile is a pointer to an Imf::TiledRgbaInputFile)
 
    int dwWidth = inTiledFile->dataWindow().max.x - inTiledFile->dataWindow().min.x + 1;
    int dwHeight = inTiledFile->dataWindow().max.y - inTiledFile->dataWindow().min.y + 1;
 
    int dx = inTiledFile->dataWindow().min.x;
    int dy = inTiledFile->dataWindow().min.y;
 
    int xTile = x / inTiledFile->tileXSize();
    int yTile = y / inTiledFile->tileYSize();
 
I only want to assign enough memory for one tile.
 
    Imf::Array2D<Imf::Rgba> frameBuffer;
    frameBuffer.resizeErase(inTiledFile->tileYSize(), inTiledFile->tileXSize());
 
I am succesful in reading the first tile with this code.
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx], 1, inTiledFile->tileXSize());
    inTiledFile->readTile(0,0);
 
But I am not successful reading any other tiles with things like this
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx] - x - y * dwWidth, 1, inTiledFile->tileXSize());
    inTiledFile->readTile(0,0);
 
or things like this
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx], 1, inTiledFile->tileXSize());
    inTiledFile->readTile(yTile,xTile);
 
 
Does anyone know what the right thing to do is ?
 
Thanks
 
barnaby
 

_______________________________________________
Openexr-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/openexr-devel
Reply | Threaded
Open this post in threaded view
|

RE: reading a random tile

Eric Soulvie
copy and paste from my code
 

// tilePos is the x,y pos of the tile.  the level is for rip/mip maps

Box2i range = tiledFile->dataWindowForTile (node->m_tilePos[0], node->m_tilePos[1], node->m_level[0], node->m_level[1] );

tiledFile->setFrameBuffer (&m_pixels[0][0] - range.min.x - range.min.y * m_tileSizeV,

1, // xStride

m_tileSizeV); // yStride

tiledFile->readTile (node->m_tilePos[0], node->m_tilePos[1], node->m_level[0], node->m_level[1]);

  -Eric
    Blizzard Cinematics

From: openexr-devel-bounces+esoulvie=[hidden email] [mailto:openexr-devel-bounces+esoulvie=[hidden email]] On Behalf Of Barnaby Robson
Sent: Tuesday, October 25, 2005 12:43 PM
To: [hidden email]
Subject: [Openexr-devel] reading a random tile

Could I get some help on reading a single random tile ?
 
The origin of the tile is (x,y)
I am setting up my variables like this. (inTiledFile is a pointer to an Imf::TiledRgbaInputFile)
 
    int dwWidth = inTiledFile->dataWindow().max.x - inTiledFile->dataWindow().min.x + 1;
    int dwHeight = inTiledFile->dataWindow().max.y - inTiledFile->dataWindow().min.y + 1;
 
    int dx = inTiledFile->dataWindow().min.x;
    int dy = inTiledFile->dataWindow().min.y;
 
    int xTile = x / inTiledFile->tileXSize();
    int yTile = y / inTiledFile->tileYSize();
 
I only want to assign enough memory for one tile.
 
    Imf::Array2D<Imf::Rgba> frameBuffer;
    frameBuffer.resizeErase(inTiledFile->tileYSize(), inTiledFile->tileXSize());
 
I am succesful in reading the first tile with this code.
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx], 1, inTiledFile->tileXSize());
    inTiledFile->readTile(0,0);
 
But I am not successful reading any other tiles with things like this
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx] - x - y * dwWidth, 1, inTiledFile->tileXSize());
    inTiledFile->readTile(0,0);
 
or things like this
 
    inTiledFile->setFrameBuffer (&frameBuffer[-dy][-dx], 1, inTiledFile->tileXSize());
    inTiledFile->readTile(yTile,xTile);
 
 
Does anyone know what the right thing to do is ?
 
Thanks
 
barnaby
 

_______________________________________________
Openexr-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/openexr-devel