libjpeg can read JPEG data from a FILE* or a buffer. My data is coming from a std::istream. I could read the entire std::istream into a buffer to use with libjpeg, but I’d rather have libjpeg read directly from the std::istream if possible. How can this be done?
libjpeg can read JPEG data from a FILE* or a buffer. My data is
Share
You just need to provide wrappers around your istream. Define a struct, for instance
Then you need four methods to operate on the stream:
and one method to bind them to the JPEG decompression info structure:
After calling
jpeg_create_decompress, call yourmake_streamfunction.