Thanks Larry,

We went with a variation on technique #2.

Cheers,

-Nicolas

On Thu, Jun 12, 2014 at 10:12 AM, Larry Gritz <[email protected]> wrote:

> There is a way to do this with plain ImageInput. One variety of
> ImageInput::open take a "configuration", which you can seed with an
> attribute called "oiio:UnassociatedAlpha" (set to 1) that instructs the TGA
> reader to not premultiply the RGB by the A.
>
> ImageSpec config;
> config.attribute ("oiio:UnassociatedAlpha", 1);
>         ImageInput *in = ImageInput::open (filename, &config);
>         const ImageSpec &spec = in->spec();
>         std::vector<unsigned char> pixels
> (spec.width*spec.height*spec.channels);
>         in->read_image (TypeDesc::UINT8, &pixels[0]);
>         in->close ();
>         delete in;
>
> There's not a very clean way to do this with an ImageBuf.
>
> I suppose one strategy is to create a blank ImageBuf, then read into it in
> a variation of the above. Instead of declaring that std::vector, you could
> do this:
>
> ImageSpec config;
> config.attribute ("oiio:UnassociatedAlpha", 1);
>         ImageInput *in = ImageInput::open (filename, &config);
>         const ImageSpec &spec = in->spec();
> * ImageBuf buf;*
> * buf.alloc (spec);  // size it based on the input image*
>         in->read_image (TypeDesc::UINT8, *buf.localpixels()*);
>         in->close ();
>         delete in;
>
> And then proceed to use the ImageBuf as you always would.
>
> I admit this is kind of clunky. It's probably better to add some kind of
> method to ImageBuf that lets you specify a "configuration" that will be
> applied when the file is opened and read.
>
>
>
> On Jun 9, 2014, at 8:56 PM, Nicolas Burtnyk <[email protected]>
> wrote:
>
> We're running into an issue with where we're using ImageBuf to read a TGA
> file which happens to have an alpha channel filled with zeros.  We want to
> grab the data in the red and green channels without an premultiplication
> (otherwise they're just all 0).  Is this currently possible with ImageBuf?
>
> Thanks!
>
> Nicolas
>
>
> --
> Larry Gritz
> [email protected]
>
>
>
>
>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
>
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to