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

Side by Side Diff: Source/platform/image-decoders/png/PNGImageDecoder.cpp

Issue 765223002: Ignore PNG gamma chunk when PNG images have a color profile (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 | « LayoutTests/fast/images/resources/png-color-profile-and-gamma-chunk.png ('k') | no next file » | 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 * Copyright (C) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Portions are Copyright (C) 2001 mozilla.org 5 * Portions are Copyright (C) 2001 mozilla.org
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Stuart Parmenter <stuart@mozilla.com> 8 * Stuart Parmenter <stuart@mozilla.com>
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // the color profile or we'd need to decode into a gray-scale image buff er and 364 // the color profile or we'd need to decode into a gray-scale image buff er and
365 // hand that to CoreGraphics. 365 // hand that to CoreGraphics.
366 ColorProfile colorProfile; 366 ColorProfile colorProfile;
367 readColorProfile(png, info, colorProfile); 367 readColorProfile(png, info, colorProfile);
368 bool decodedImageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCo unt; 368 bool decodedImageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCo unt;
369 m_reader->createColorTransform(colorProfile, decodedImageHasAlpha); 369 m_reader->createColorTransform(colorProfile, decodedImageHasAlpha);
370 m_hasColorProfile = !!m_reader->colorTransform(); 370 m_hasColorProfile = !!m_reader->colorTransform();
371 } 371 }
372 #endif 372 #endif
373 373
374 // Deal with gamma and keep it under our control. 374 if (!m_hasColorProfile) {
375 double gamma; 375 // Deal with gamma and keep it under our control.
376 if (!m_ignoreGammaAndColorProfile && png_get_gAMA(png, info, &gamma)) { 376 double gamma;
377 if ((gamma <= 0.0) || (gamma > cMaxGamma)) { 377 if (!m_ignoreGammaAndColorProfile && png_get_gAMA(png, info, &gamma)) {
378 gamma = cInverseGamma; 378 if ((gamma <= 0.0) || (gamma > cMaxGamma)) {
379 png_set_gAMA(png, info, gamma); 379 gamma = cInverseGamma;
380 png_set_gAMA(png, info, gamma);
381 }
382 png_set_gamma(png, cDefaultGamma, gamma);
383 } else {
384 png_set_gamma(png, cDefaultGamma, cInverseGamma);
380 } 385 }
381 png_set_gamma(png, cDefaultGamma, gamma); 386 }
382 } else
383 png_set_gamma(png, cDefaultGamma, cInverseGamma);
384 387
385 // Tell libpng to send us rows for interlaced pngs. 388 // Tell libpng to send us rows for interlaced pngs.
386 if (interlaceType == PNG_INTERLACE_ADAM7) 389 if (interlaceType == PNG_INTERLACE_ADAM7)
387 png_set_interlace_handling(png); 390 png_set_interlace_handling(png);
388 391
389 // Update our info now. 392 // Update our info now.
390 png_read_update_info(png, info); 393 png_read_update_info(png, info);
391 channels = png_get_channels(png, info); 394 channels = png_get_channels(png, info);
392 ASSERT(channels == 3 || channels == 4); 395 ASSERT(channels == 3 || channels == 4);
393 396
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // has failed. 552 // has failed.
550 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 553 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
551 setFailed(); 554 setFailed();
552 // If we're done decoding the image, we don't need the PNGImageReader 555 // If we're done decoding the image, we don't need the PNGImageReader
553 // anymore. (If we failed, |m_reader| has already been cleared.) 556 // anymore. (If we failed, |m_reader| has already been cleared.)
554 else if (isComplete()) 557 else if (isComplete())
555 m_reader.clear(); 558 m_reader.clear();
556 } 559 }
557 560
558 } // namespace blink 561 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/images/resources/png-color-profile-and-gamma-chunk.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698