From 492e67163e17767bc374f276ee8ca7e3ad3b7b9a Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 4 Aug 2013 14:03:44 -0500 Subject: [PATCH] [libpng16] Exit loop over tRNS array when a transparent entry is found (performance report by PoChun Chang) --- pngrtran.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pngrtran.c b/pngrtran.c index e378ceba4..1816ec34e 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.2 [April 25, 2013] + * Last changed in libpng 1.6.4 [(PENDING RELEASE)] * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -1116,12 +1116,18 @@ png_init_palette_transformations(png_structrp png_ptr) /* Ignore if all the entries are opaque (unlikely!) */ for (i=0; inum_trans; ++i) + { if (png_ptr->trans_alpha[i] == 255) continue; else if (png_ptr->trans_alpha[i] == 0) input_has_transparency = 1; else + { + input_has_transparency = 1; input_has_alpha = 1; + break; + } + } } /* If no alpha we can optimize. */