summaryrefslogtreecommitdiff
path: root/tools/aapt/Images.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2013-09-05 16:26:04 -0700
committer Adam Lesinski <adamlesinski@google.com> 2014-01-27 10:31:05 -0800
commit859e19f97d481bf07c768087d8eb3031fac77aad (patch)
tree08c0eed6328b3f2f5c7622744dae85d8137c60ed /tools/aapt/Images.cpp
parent19acfb8e873a04d42619d222c43eda95d259d0a5 (diff)
libpng usage tweaks
Bug: 10447005 Call png_set_interlace_handling explicitly instead of relying on implicit handling that logs warnings Include filename when printing warnings Change-Id: Ia343427f5522dc8ab1010f8d7017e86f389caf99
Diffstat (limited to 'tools/aapt/Images.cpp')
-rw-r--r--tools/aapt/Images.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index b2cbf49843af..89475970d196 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -70,6 +70,12 @@ struct image_info
png_bytepp allocRows;
};
+static void log_warning(png_structp png_ptr, png_const_charp warning_message)
+{
+ const char* imageName = (const char*) png_get_error_ptr(png_ptr);
+ fprintf(stderr, "%s: libpng warning: %s\n", imageName, warning_message);
+}
+
static void read_png(const char* imageName,
png_structp read_ptr, png_infop read_info,
image_info* outImageInfo)
@@ -78,6 +84,8 @@ static void read_png(const char* imageName,
int bit_depth, interlace_type, compression_type;
int i;
+ png_set_error_fn(read_ptr, const_cast<char*>(imageName),
+ NULL /* use default errorfn */, log_warning);
png_read_info(read_ptr, read_info);
png_get_IHDR(read_ptr, read_info, &outImageInfo->width,
@@ -108,6 +116,8 @@ static void read_png(const char* imageName,
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(read_ptr);
+ png_set_interlace_handling(read_ptr);
+
png_read_update_info(read_ptr, read_info);
outImageInfo->rows = (png_bytepp)malloc(