So... the source image that you are cropping... is it starting out as a single multi-part exr (each "part" being what we call a "subimage")? And you are trying to crop each subimage to the same ROI?
I feel like the crucial bits might be right before or after the quoted code. Do you think you could boil it down to a complete program (or function) that shows all the steps you are performing, that I can try on this end? Also, you don't say what version of OIIO you are using. I want to make sure you aren't bumping into some long-ago-fixed bug. -- lg > On Apr 7, 2020, at 1:03 AM, Sven Steinbauer <s...@themill.com> wrote: > > Hello, > > I am working on adding multi-image support to our application and this is > going well so far. However I am looking to add in cropping to the multi-image > also. Originally the crop was done like this: > > ImageBuf src("src", spec, scratch); > > // Calculate the ROI here. > > // crop > ImageBuf full("full", spec); > ImageBufAlgo::crop(full, src, roi); > bool ok = full.write(filename.toStdString(), "exr"); > > When writing out the multi-image I am following the documentation > > for (int s = 0; s < orig_fb_count; s++) { > if (s > 0) { // Not needed for the first, which is already open > out->open (filename.toStdString(), specs[s], > ImageOutput::AppendSubimage); > } > out->write_image (TypeDesc::BASETYPE(specs[s].format.basetype), scratch + > xoffset); > xoffset += specs[s].image_bytes(); > } > > scratch is a char pointer to the image data, where the images are stored > contiguously. This part has worked fine. So I tried to crop the data like so: > > ImageBuf src("src", specs[s], scratch + xoffset); > // set spec roi to bbox > // crop > ImageBuf full("full", specs[s]); > ImageBufAlgo::crop(full, src, roi); > //full.get_pixels(ROIroi, TypeDescformat, void *result > if (s > 0) { // Not needed for the first, which is already open > out->open (filename.toStdString(), full.spec(), > ImageOutput::AppendSubimage); > } > out->write_image (TypeDesc::BASETYPE(full.spec().format.basetype), > full.localpixels()); > > Which compiles and runs, but doesn't give me the expected image (it's a mess > of pixels). > What would the correct approach be here to crop the images for a multi-image > EXR? > > The ROI seems to contain the expected width and height values, but when > checking the exrheaders, the data window values are still the full image > dimensions. I think this is what might be causing the issues. I've tried > manually setting width and height in the spec, but also without success. > > Thanks > > SVEN STEINBAUER​ > Senior R&D Engineer > T > +44 20 7287 4041 > <http://www.themill.com/> > THE MILL 11‑14 WINDMILL STREET, LONDON, W1T 2JG > FOLLOW @MILLCHANNEL | FACEBOOK <http://www.facebook.com/millchannel> > | TWITTER <https://twitter.com/millchannel> | INSTAGRAM > <https://www.instagram.com/millchannel> > | > THEMILL.COM <http://www.themill.com/> > > _______________________________________________ > Oiio-dev mailing list > Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org> > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> -- Larry Gritz l...@larrygritz.com
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org