From 6c16fff219e8f733ea14ed7df9edda9c037d4b71 Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 14 Aug 2013 14:13:54 -0700 Subject: Fixes for libpng 1.6 png_set_filler() now fails if the color type doesn't support a filler (such as RGB_ALPHA) png_set_unknown_chunk location bug was fixed and now enforces proper location setting Change-Id: If3834e3744d9618c308cc442e66d85e9cffcea38 --- tools/aapt/Images.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tools/aapt/Images.cpp') diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index a842553f943c..b2cbf49843af 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -1075,18 +1075,19 @@ static void write_png(const char* imageName, unknowns[b_index].size = chunk_size; } + for (int i = 0; i < chunk_count; i++) { + unknowns[i].location = PNG_HAVE_PLTE; + } png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, chunk_names, chunk_count); png_set_unknown_chunks(write_ptr, write_info, unknowns, chunk_count); - // XXX I can't get this to work without forcibly changing - // the location to what I want... which apparently is supposed - // to be a private API, but everything else I have tried results - // in the location being set to what I -last- wrote so I never - // get written. :p +#if PNG_LIBPNG_VER < 10600 + /* Deal with unknown chunk location bug in 1.5.x and earlier */ png_set_unknown_chunk_location(write_ptr, write_info, 0, PNG_HAVE_PLTE); if (imageInfo.haveLayoutBounds) { png_set_unknown_chunk_location(write_ptr, write_info, 1, PNG_HAVE_PLTE); } +#endif } @@ -1094,7 +1095,9 @@ static void write_png(const char* imageName, png_bytepp rows; if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - png_set_filler(write_ptr, 0, PNG_FILLER_AFTER); + if (color_type == PNG_COLOR_TYPE_RGB) { + png_set_filler(write_ptr, 0, PNG_FILLER_AFTER); + } rows = imageInfo.rows; } else { rows = outRows; -- cgit v1.2.3-59-g8ed1b