Stefan, see https://github.com/OpenImageIO/oiio/pull/266
This adds an ImageRec constructor from an ImageBuf. I think that will help you
along, and then what you'll want is something like this:
ImageBufRef histogram_R (ip_histogram_to_image (r, xres, yres));
ot.push (new ImageRec (histogram_R, false));
Much simpler, I think. And you don't have to worry about freeing histogram_R
this way, either.
-- lg
On Mar 27, 2012, at 9:35 AM, Larry Gritz wrote:
> It's hard to tell from this exactly what's going on, since I don't know
> exactly how you create the ImageBuf in ip_histogram_to_image.
>
> If you are returning an ImageBuf, then put it on the image stack (ot.push...)
> and used the -o command, there should be no reason for you to call save
> directly.
>
> Also, I'm presuming that the dimensions of the histogram image actually
> matches specR, otherwise you're going to really confuse it with the Rib =
> *histogram_R.
>
> It seems to me that what you really want is an ImageRec constructor that
> takes an ImageBuf*. Let me prepare a patch for you that will make this
> easier. Stay tuned.
>
>
>
>
> On Mar 27, 2012, at 3:22 AM, Stefan Stavrev wrote:
>
>> I create an ImageBuf and then try to save the image to a file:
>>
>> ImageBuf* histogram_R = ip_histogram_to_image (r, xres, yres);
>> histogram_R->save (path_R);
>>
>> The result is an image, which is not what it should be. It is
>> transparent, and it has some pixels here and there.
>>
>> I call my function from command line with argument -o output_filename
>> so what is left on stack will be saved. To check if histogram_R is ok
>> I did the following, which gave the proper result.
>>
>> ImageSpec specR (256, 256, 1, TypeDesc::FLOAT);
>> ot.push (new ImageRec ("irec", specR, ot.imagecache));
>> ImageBuf &Rib ((*ot.curimg)());
>> Rib = *histogram_R;
>>
>> Probably I am using "save" the wrong way?
>>
>> Thanks
>
> --
> Larry Gritz
> [email protected]
>
>
> _______________________________________________
> 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