barnson / miniz

Automatically exported from code.google.com/p/miniz
1 stars 1 forks source link

Suggestion: Filter parameter for tdefl_write_image_to_png_file_in_memory() #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The simple PNG writer sets all of the rows to unfiltered '0' 
I've made a low-profile change to the method in miniz.c in my own code to 
accept a pre-filtered input image. It simply passes an array of filter types to 
the function, and places them in the image data to be compressed.

tdefl_write_image_to_png_file_in_memory_ex()
line 2802 : Add parameter "mz_uint8* filters"
line 2813 : Replace second parameter of the first call to 
tdefl_compress_buffer() [&z] 
            with (filters == NULL ? &t : filters+(flip ? (h - 1 - y) : y))

tdefl_write_image_to_png_file_in_memory()
line 2831 : Add parameter "mz_uint8* filters"
line 2834 : Pass filters to tdefl_write_image_to_png_file_in_memory_ex()

Alternatively, set the parameter to NULL on line 2834 to reduce the impact on 
the API 

I'm using t (mz_uint8) instead of z (int), because the function is passing a 
byte of data. In face, z should probably also be mz_uint8 for its use in 
writing the header. 

Original issue reported on code.google.com by Lok...@gmail.com on 25 Jan 2014 at 6:35