Hi, all!

I'm trying to achieve the following when reading an image:

  1.  Read the image into a non-interleaved buffer (so the order of the buffer 
values looks like RRRGGGBBB instead of RGBRGBRGB)
  2.  Flip the images vertically upon reading

I was able to attain a non-interleaved buffer following the read_image example 
in the documentation 
(https://openimageio.readthedocs.io/en/latest/imageinput.html#reading-channels-to-separate-buffers),
 but in order to also flip the image vertically, I need to provide a negative y 
stride. However, because the stride represents the distance between pixel rows 
in the buffer itself, it doesn't seem possible to specify a stride value that 
makes sense for a non-interleaved buffer. Is there a way to achieve both?

One approach I tried uses read_scanlines in a nested loop to iterate over each 
channel in the image in reverse scanline order:

for (int channel = 0; channel < numChannels; ++channel) {
    for (int y = 0; y < height; ++y) {
        image->read_scanlines(subimage,
                              miplevel,
                              height - y - 1, height - y, 0,
                              channel, channel + 1,
                              OIIO::TypeDesc::FLOAT,
                              &pixelBuffer[width * height * channel + (width * 
y)]);
    }
}

Although this works, it is too slow. Is there a more efficient approach?

Thanks,
Jesse
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to