Closed MrJohnBarker closed 7 years ago
This should work:
unsigned CustomPNGDeflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
const LodePNGCompressSettings* settings) {
int compression_level = 12;
struct libdeflate_compressor* compressor;
compressor = libdeflate_alloc_compressor(compression_level);
size_t allocsize = libdeflate_deflate_compress_bound(compressor, insize);
(*out) = (unsigned char*)malloc(allocsize);
(*outsize) = libdeflate_deflate_compress(compressor, in, insize, *out, allocsize);
libdeflate_free_compressor(compressor);
return 0;
}
By the way, if you're interested in achieving better/faster image compression than with lodepng, you should check out my image optimizer fhanau/Efficient-Compression-Tool
Thank you very much @fhanau I was happy to add your code to ZopfliPNG but finally I tried your fhanau/Efficient-Compression-Tool first. That's exactly what I was looking for actually, it's faster+better than ZopfliPNG. Very impressive!
Hi Lode, It's probably out of the scope noob question and maybe not an real issue about the lodepng itself. I'm trying to add This library as deflate compressor in ZopfliPNG instead of Zopfli. I don't even know if I'm doing this in the right way:
This compile well, but ZopfliPNG is corrupting all images (full black pixels) probably because it's not used as it should be. Any help will be appreciated !