DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
211 stars 48 forks source link

Add PNG support. Add JPEG and PNG in memory buffer instead of file. #145

Closed crisluengo closed 3 months ago

crisluengo commented 4 months ago

libpng is rather obtuse to use, but libspng has a much simpler API and could be a good way to implement PNG support.

It would be useful if DIPlib could read from and write to memory buffers instead of a file for JPEG and PNG. For other file formats this might make less sense, but these two formats are quite popular for storage in a database or embedding in a data stream. All of libpng, libspng and libjpeg support memory buffers. We currently have a function dip::ImageReadJPEG(String const&) and a function dip::ImageWriteJPEG(Image const&, String const&, ...). We can easily add an overload where the String const& (file name) is replaced by a char* or void* (buffer pointer). Hopefully most of the internal code can be reused.

crisluengo commented 3 months ago

Completed with commits 2f8ba870 through bad77f37 (which, despite the commit ID, is not a bad commit at all).