On Feb 20, 2013, at 10:12 AM, Ostap Pochtarenko wrote:

> Hello
> 
> Corresponds more how to read tiles using "ImageBuf"? Because I don't 
> understand how correctly read (records) images which recorded tiles.
> 


I'm not sure I understand your question.  But I'm going to take a stab at it 
anyway.

There are three easy ways to read a tiled image with OpenImageIO:

1. Read the whole image into your own buffer:
        // Allocate and read into a big float buffer
        ImageInput *in = ImageInput::open (filename);
        std::vector<float> buf (in->spec().image_pixels() * 
in->spec().nchannels);
        in->read_image (&buf[0], TypeDesc::FLOAT);
        in->close ();
        delete in;

2. Use an ImageBuf:
        ImageBuf ib (filename);
        ib.read ();
        // now you may access the pixels using ib.getpixel(x,y,&myfloatpixel) 
        //   or ImageBuf::Iterator traversal 
        //   or copy to your own buffer using ib.get_pixels(...)

3. Use ImageCache:
        ImageCache *ic = ImageCache::create ();  // just do this once
        ... set up your buffer to the right size ...
        ic->get_pixels (ustring(filename), ..., &mybuffer);


All of these work identically for tiled and scanline files.

There's one more option: Like #1, but instead of read_image(), you could call 
read_tile() repeatedly to read individual tiles.  But that ONLY works for tiled 
files, and there is no advantage to doing this versus #1 if you need the whole 
image at once -- reading individual tiles is only helpful if your application 
needs the individual tiles one-by-one.


--
Larry Gritz
[email protected]


_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to