@@ -25,6 +25,7 @@ limitations under the License.
2525// provokes a compile error. We instead let png.h include what is needed.
2626
2727#include " absl/base/casts.h"
28+ #include " png.h" // from @png
2829#include " tensorflow/core/lib/png/png_io.h"
2930#include " tensorflow/core/platform/byte_order.h"
3031#include " tensorflow/core/platform/logging.h"
@@ -77,7 +78,7 @@ static void Convert8to16(const uint8* p8, int num_comps, int p8_row_bytes,
7778
7879void ErrorHandler (png_structp png_ptr, png_const_charp msg) {
7980 DecodeContext* const ctx =
80- absl::bit_cast<DecodeContext*>(png_get_io_ptr (png_ptr));
81+ absl::bit_cast<DecodeContext*>(png_get_error_ptr (png_ptr));
8182 ctx->error_condition = true ;
8283 // To prevent log spam, errors are logged as VLOG(1) instead of ERROR.
8384 VLOG (1 ) << " PNG error: " << msg;
@@ -354,8 +355,9 @@ bool WriteImageToBuffer(
354355
355356 png_string->resize (0 );
356357 png_infop info_ptr = nullptr ;
357- png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, nullptr ,
358- ErrorHandler, WarningHandler);
358+ DecodeContext decode_context;
359+ png_structp png_ptr = png_create_write_struct (
360+ PNG_LIBPNG_VER_STRING, &decode_context, ErrorHandler, WarningHandler);
359361 if (png_ptr == nullptr ) return false ;
360362 if (setjmp (png_jmpbuf (png_ptr))) {
361363 png_destroy_write_struct (&png_ptr, info_ptr ? &info_ptr : nullptr );
0 commit comments