123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
diff -rup optipng-0.7.5/src/libpng/pngstruct.h cryoptipng-0.7.5/src/libpng/pngstruct.h
--- optipng-0.7.5/src/libpng/pngstruct.h 2014-03-06 18:35:01.000000000 +0000
+++ cryoptipng-0.7.5/src/libpng/pngstruct.h 2014-04-28 22:49:36.000000000 +0000
@@ -487,3 +487,13 @@ struct png_struct_def
#endif
};
#endif /* PNGSTRUCT_H */
+fop row_info,
+ png_bytep row, png_const_bytep prev_row);
+
+#ifdef PNG_READ_SUPPORTED
+#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
+ png_colorspace colorspace;
+#endif
+#endif
+};
+#endif /* PNGSTRUCT_H */
diff -rup optipng-0.7.5/src/libpng/pngwrite.c cryoptipng-0.7.5/src/libpng/pngwrite.c
--- optipng-0.7.5/src/libpng/pngwrite.c 2014-03-06 18:35:01.000000000 +0000
+++ cryoptipng-0.7.5/src/libpng/pngwrite.c 2014-04-28 23:06:53.000000000 +0000
@@ -2434,3 +2434,36 @@ png_image_write_to_file(png_imagep image
#endif /* PNG_STDIO_SUPPORTED */
#endif /* SIMPLIFIED_WRITE */
#endif /* PNG_WRITE_SUPPORTED */
+ * set the error (because the original write succeeded).
+ */
+ return png_image_error(image, strerror(error));
+ }
+
+ else
+ {
+ /* Clean up: just the opened file. */
+ (void)fclose(fp);
+ (void)remove(file_name);
+ return 0;
+ }
+ }
+
+ else
+ return png_image_error(image, strerror(errno));
+ }
+
+ else
+ return png_image_error(image,
+ "png_image_write_to_file: invalid argument");
+ }
+
+ else if (image != NULL)
+ return png_image_error(image,
+ "png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
+
+ else
+ return 0;
+}
+#endif /* PNG_STDIO_SUPPORTED */
+#endif /* SIMPLIFIED_WRITE */
+#endif /* PNG_WRITE_SUPPORTED */
diff -rup optipng-0.7.5/src/libpng/pngwutil.c cryoptipng-0.7.5/src/libpng/pngwutil.c
--- optipng-0.7.5/src/libpng/pngwutil.c 2014-03-06 18:35:01.000000000 +0000
+++ cryoptipng-0.7.5/src/libpng/pngwutil.c 2014-04-28 23:52:50.000000000 +0000
@@ -3022,3 +3022,88 @@ png_write_filtered_row(png_structrp png_
#endif
}
#endif /* PNG_WRITE_SUPPORTED */
+)
+ {
+ }
+ else
+ {
+ if ((int)*rp == 0)
+ {
+ rp = rp-3;
+ pp = pp-3;
+ *rp++ = (png_byte)(*pp++);
+ *rp++ = (png_byte)(*pp++);
+ *rp++ = (png_byte)(*pp++);
+ }
+ }
+
+ }
+
+
+ }
+
+ if ((best_row[0] == PNG_FILTER_VALUE_AVG) && (rp_is_dirty & 0x08))
+ {
+ png_bytep rp, dp;
+ png_uint_32 i;
+ for (i = 0, rp = row_buf + 1, dp = png_ptr->dirty_row + 1; i < row_bytes; i++)
+ {
+ *rp++ = *dp++;
+ }
+ }
+
+ if ((best_row[0] == PNG_FILTER_VALUE_PAETH) && (rp_is_dirty & 0x10))
+ {
+ png_bytep rp, dp;
+ png_uint_32 i;
+ for (i = 0, rp = row_buf + 1, dp = png_ptr->dirtz_row + 1; i < row_bytes; i++)
+ {
+ *rp++ = *dp++;
+ }
+ }
+
+ rp_is_dirty = 0;
+ }
+
+#endif /* PNG_WRITE_FILTER_SUPPORTED */
+ /* Do the actual writing of the filtered row data from the chosen filter. */
+
+ png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
+}
+
+
+/* Do the actual writing of a previously filtered row. */
+static void
+png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
+ png_size_t full_row_length/*includes filter byte*/)
+{
+ png_debug(1, "in png_write_filtered_row");
+
+ png_debug1(2, "filter = %d", filtered_row[0]);
+
+ png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
+
+ /* Swap the current and previous rows */
+ if (png_ptr->prev_row != NULL)
+ {
+ png_bytep tptr;
+
+ tptr = png_ptr->prev_row;
+ png_ptr->prev_row = png_ptr->row_buf;
+ png_ptr->row_buf = tptr;
+ }
+
+ /* Finish row - updates counters and flushes zlib if last row */
+ png_write_finish_row(png_ptr);
+
+#ifdef PNG_WRITE_FLUSH_SUPPORTED
+ png_ptr->flush_rows++;
+
+ if (png_ptr->flush_dist > 0 &&
+ png_ptr->flush_rows >= png_ptr->flush_dist)
+ {
+ png_write_flush(png_ptr);
+ }
+#endif
+}
+#endif /* PNG_WRITE_SUPPORTED */
diff -rup optipng-0.7.5/src/optipng/optim.c cryoptipng-0.7.5/src/optipng/optim.c
--- optipng-0.7.5/src/optipng/optim.c 2014-02-23 16:37:00.000000000 +0000
+++ cryoptipng-0.7.5/src/optipng/optim.c 2014-04-28 22:33:19.000000000 +0000
@@ -1904,3 +1904,22 @@ opng_finalize(void)
engine.started = 0;
return 0;
}
+ if (summary.snip_count > 0)
+ {
+ usr_printf("%u multi-image file(s) have been snipped.\n",
+ summary.snip_count);
+ }
+ if (summary.err_count > 0)
+ {
+ usr_printf("%u error(s) have been encountered.\n",
+ summary.err_count);
+ if (summary.fix_count > 0)
+ usr_printf("%u erroneous file(s) have been fixed.\n",
+ summary.fix_count);
+ }
+ }
+
+ /* Stop the engine. */
+ engine.started = 0;
+ return 0;
+}
diff -rup optipng-0.7.5/src/optipng/optipng.c cryoptipng-0.7.5/src/optipng/optipng.c
--- optipng-0.7.5/src/optipng/optipng.c 2014-02-23 16:37:00.000000000 +0000
+++ cryoptipng-0.7.5/src/optipng/optipng.c 2014-04-28 22:08:39.000000000 +0000
@@ -1007,3 +1007,7 @@ main(int argc, char *argv[])
app_finish();
return result;
}
+ Finalize the application. */
+ app_finish();
+ return result;
+}
diff -rup optipng-0.7.5/src/optipng/proginfo.h cryoptipng-0.7.5/src/optipng/proginfo.h
--- optipng-0.7.5/src/optipng/proginfo.h 2014-03-24 10:45:00.000000000 +0000
+++ cryoptipng-0.7.5/src/optipng/proginfo.h 2014-04-28 21:52:41.000000000 +0000
@@ -23,3 +23,5 @@
"http://optipng.sourceforge.net/"
#endif /* PROGINFO_H */
+
+#endif /* PROGINFO_H */