Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: third_party/libpng/pngrtran.c

Issue 1372313004: Update to libpng 1.2.52 (rollup change only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libpng/pngread.c ('k') | third_party/libpng/pngrutil.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* pngrtran.c - transforms the data in a row for PNG readers 2 /* pngrtran.c - transforms the data in a row for PNG readers
3 * 3 *
4 * Last changed in libpng 1.2.45 [July 7, 2011] 4 * Last changed in libpng 1.2.51 [February 6, 2014]
5 * Copyright (c) 1998-2011 Glenn Randers-Pehrson 5 * Copyright (c) 1998-2014 Glenn Randers-Pehrson
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8 * 8 *
9 * This code is released under the libpng license. 9 * This code is released under the libpng license.
10 * For conditions of distribution and use, see the disclaimer 10 * For conditions of distribution and use, see the disclaimer
11 * and license in png.h 11 * and license in png.h
12 * 12 *
13 * This file contains functions optionally called by an application 13 * This file contains functions optionally called by an application
14 * in order to tell libpng how to handle data when reading a PNG. 14 * in order to tell libpng how to handle data when reading a PNG.
15 * Transformations that are used in both reading and writing are 15 * Transformations that are used in both reading and writing are
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 910
911 if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) 911 if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0)
912 && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) 912 && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0)
913 < PNG_GAMMA_THRESHOLD)) 913 < PNG_GAMMA_THRESHOLD))
914 { 914 {
915 int i, k; 915 int i, k;
916 k=0; 916 k=0;
917 for (i=0; i<png_ptr->num_trans; i++) 917 for (i=0; i<png_ptr->num_trans; i++)
918 { 918 {
919 if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) 919 if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff)
920 {
920 k=1; /* Partial transparency is present */ 921 k=1; /* Partial transparency is present */
922 break;
923 }
921 } 924 }
922 if (k == 0) 925 if (k == 0)
923 png_ptr->transformations &= ~PNG_GAMMA; 926 png_ptr->transformations &= ~PNG_GAMMA;
924 } 927 }
925 928
926 if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && 929 if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
927 png_ptr->gamma != 0.0) 930 png_ptr->gamma != 0.0)
928 { 931 {
929 png_build_gamma_table(png_ptr); 932 png_build_gamma_table(png_ptr);
930 933
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 } 1159 }
1157 1160
1158 /* Handled alpha, still need to strip the channel. */ 1161 /* Handled alpha, still need to strip the channel. */
1159 png_ptr->transformations &= ~PNG_BACKGROUND; 1162 png_ptr->transformations &= ~PNG_BACKGROUND;
1160 png_ptr->transformations |= PNG_STRIP_ALPHA; 1163 png_ptr->transformations |= PNG_STRIP_ALPHA;
1161 } 1164 }
1162 #endif /* PNG_READ_BACKGROUND_SUPPORTED */ 1165 #endif /* PNG_READ_BACKGROUND_SUPPORTED */
1163 1166
1164 #ifdef PNG_READ_SHIFT_SUPPORTED 1167 #ifdef PNG_READ_SHIFT_SUPPORTED
1165 if ((png_ptr->transformations & PNG_SHIFT) && 1168 if ((png_ptr->transformations & PNG_SHIFT) &&
1169 !(png_ptr->transformations & PNG_EXPAND) &&
1166 (color_type == PNG_COLOR_TYPE_PALETTE)) 1170 (color_type == PNG_COLOR_TYPE_PALETTE))
1167 { 1171 {
1168 png_uint_16 i; 1172 png_uint_16 i;
1169 png_uint_16 istop = png_ptr->num_palette; 1173 png_uint_16 istop = png_ptr->num_palette;
1170 int sr = 8 - png_ptr->sig_bit.red; 1174 int sr = 8 - png_ptr->sig_bit.red;
1171 int sg = 8 - png_ptr->sig_bit.green; 1175 int sg = 8 - png_ptr->sig_bit.green;
1172 int sb = 8 - png_ptr->sig_bit.blue; 1176 int sb = 8 - png_ptr->sig_bit.blue;
1173 1177
1174 if (sr < 0 || sr > 8) 1178 if (sr < 0 || sr > 8)
1175 sr = 0; 1179 sr = 0;
1176 if (sg < 0 || sg > 8) 1180 if (sg < 0 || sg > 8)
1177 sg = 0; 1181 sg = 0;
1178 if (sb < 0 || sb > 8) 1182 if (sb < 0 || sb > 8)
1179 sb = 0; 1183 sb = 0;
1180 for (i = 0; i < istop; i++) 1184 for (i = 0; i < istop; i++)
1181 { 1185 {
1182 png_ptr->palette[i].red >>= sr; 1186 png_ptr->palette[i].red >>= sr;
1183 png_ptr->palette[i].green >>= sg; 1187 png_ptr->palette[i].green >>= sg;
1184 png_ptr->palette[i].blue >>= sb; 1188 png_ptr->palette[i].blue >>= sb;
1185 } 1189 }
1190
1191 png_ptr->transformations &= ~PNG_SHIFT;
1186 } 1192 }
1187 #endif /* PNG_READ_SHIFT_SUPPORTED */ 1193 #endif /* PNG_READ_SHIFT_SUPPORTED */
1188 } 1194 }
1189 #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ 1195 #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
1190 && !defined(PNG_READ_BACKGROUND_SUPPORTED) 1196 && !defined(PNG_READ_BACKGROUND_SUPPORTED)
1191 if (png_ptr) 1197 if (png_ptr)
1192 return; 1198 return;
1193 #endif 1199 #endif
1194 } 1200 }
1195 1201
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 #else 1372 #else
1367 png_warning(png_ptr, "Uninitialized row"); 1373 png_warning(png_ptr, "Uninitialized row");
1368 #endif 1374 #endif
1369 #endif 1375 #endif
1370 1376
1371 #ifdef PNG_READ_EXPAND_SUPPORTED 1377 #ifdef PNG_READ_EXPAND_SUPPORTED
1372 if (png_ptr->transformations & PNG_EXPAND) 1378 if (png_ptr->transformations & PNG_EXPAND)
1373 { 1379 {
1374 if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) 1380 if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE)
1375 { 1381 {
1382 if (png_ptr->palette == NULL)
1383 png_error (png_ptr, "Palette is NULL in indexed image");
1384
1376 png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, 1385 png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1,
1377 png_ptr->palette, png_ptr->trans, png_ptr->num_trans); 1386 png_ptr->palette, png_ptr->trans, png_ptr->num_trans);
1378 } 1387 }
1379 else 1388 else
1380 { 1389 {
1381 if (png_ptr->num_trans && 1390 if (png_ptr->num_trans &&
1382 (png_ptr->transformations & PNG_EXPAND_tRNS)) 1391 (png_ptr->transformations & PNG_EXPAND_tRNS))
1383 png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, 1392 png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
1384 &(png_ptr->trans_values)); 1393 &(png_ptr->trans_values));
1385 else 1394 else
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after
4458 *(rp ) = (png_byte)((red >> 8) & 0xff); 4467 *(rp ) = (png_byte)((red >> 8) & 0xff);
4459 *(rp+1) = (png_byte)(red & 0xff); 4468 *(rp+1) = (png_byte)(red & 0xff);
4460 *(rp+4) = (png_byte)((blue >> 8) & 0xff); 4469 *(rp+4) = (png_byte)((blue >> 8) & 0xff);
4461 *(rp+5) = (png_byte)(blue & 0xff); 4470 *(rp+5) = (png_byte)(blue & 0xff);
4462 } 4471 }
4463 } 4472 }
4464 } 4473 }
4465 } 4474 }
4466 #endif /* PNG_MNG_FEATURES_SUPPORTED */ 4475 #endif /* PNG_MNG_FEATURES_SUPPORTED */
4467 #endif /* PNG_READ_SUPPORTED */ 4476 #endif /* PNG_READ_SUPPORTED */
OLDNEW
« no previous file with comments | « third_party/libpng/pngread.c ('k') | third_party/libpng/pngrutil.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698