You already have the image data in memory? If the pixels are all contiguous, 
you can create an ImageBuf that "wraps" your buffer without allocating its own 
memory or doing any copying.

Let's say you have 8 bit pixels like this:

        unsigned char pixels[HEIGHT][WIDTH][CHANS];

Then wrap:

        ImageBuf buf (ImageSpec(WIDTH,HEIGHT,CHANS,TypeDesc::UINT8), pixels);

Then make the texture:

        ImageSpec config;   // read the docs to know what to do with this
        ImageBufAlgo::make_texture  (ImageBufAlgo::MakeTxTexture, buf, 
"texturename.tx", config);


On Apr 22, 2015, at 3:09 AM, Simon Smith <[email protected]> wrote:

> Hi,
> 
> I'm pretty sure I'm missing something simple here ...
> 
> I can happily convert from one file format to another by creating a suitable 
> ImageSpec and calling ImageBufAlgo::make_texture with the spec, input, and 
> output filenames.
> 
> I have an alternative scenario where I have the image data in memory (linear, 
> RGBA floating point data) and I want to get that into a similar renderman 
> compliant file on disk. It doesn't look like ImageBufAlgo can help me here as 
> they require either an existing file, or an ImageBuf object with such an 
> ImageSpec.
> 
> How do I go about creating such a file from what I have as input?
> I'm pretty sure I'm missing something obvious … how to craft arbitrary raw 
> image data with an ImageSpec into an ImageBuf in memory.
> 
> Any pointers welcome!
> 
> 
> Best Regards,
>    Simon
> 
> ---
> Simon C Smith
> Co-Founder & CTO
> www.hdrlightstudio.com
> 
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
[email protected]



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

Reply via email to