Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How To Change Deflate (not really an issue) #53

Closed
MrJohnBarker opened this issue Apr 20, 2017 · 2 comments
Closed

How To Change Deflate (not really an issue) #53

MrJohnBarker opened this issue Apr 20, 2017 · 2 comments

Comments

@MrJohnBarker
Copy link

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:

   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);
   libdeflate_deflate_compress(compressor, in, insize, out, *outsize);
   libdeflate_free_compressor(compressor);
   return 0;
}

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 !

@fhanau
Copy link

fhanau commented Apr 20, 2017

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

@MrJohnBarker
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants