[FEATURE REQUEST] Access binary data of file without decoding
std::vector<unsigned char> pixels (xres*yres*channels);
in->read_image (TypeDesc::UINT8, &pixels[0]);
in->close ();
The basic example for reading or writing a file using oiio offers a read or write method that returns the decoded binary image. For certain image processing, it may be necessary to access the encoded binary data inside the jpeg or png.
A read_binary() and write_binary() method can be offered that will extract just the binary data in a buffer and write it back. Of course, the size of the binary buffer using read_binary() and write_binary() must be exactly the same.
It will be easy to do this within oiio as the library already is aware of the header and data sections due to the read and write functionality.
Alternatively, a data_offset() method can return the number of bytes in the header. And the user can modify the binary data on their own. Combined with the ability to write jpeg to memory, this will be quite useful.
I'm embarrassed that there was no reply to this right away.
I agree in principle -- there is a case to be made that ImageInput/ImageOutput should have ways to read tiles/scanlines/stripes of raw compressed data. I can think of at least two important use cases:
- Times when you want to copy a file (to the same file format type) with only changes in metadata. This shouldn't require a full decompress/recompress cycle.
- Future cases where we want to do decompression on GPUs.
If somebody wants to take this on, the first thing this would need is a detailed proposal for how the ImageInput and ImageOutput APIs ought to be modified to accommodate this.