OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 if (SkEncodedInfo::kOpaque_Alpha == alpha) { | 757 if (SkEncodedInfo::kOpaque_Alpha == alpha) { |
758 png_color_8p sigBits; | 758 png_color_8p sigBits; |
759 if (png_get_sBIT(png_ptr, info_ptr, &sigBits)) { | 759 if (png_get_sBIT(png_ptr, info_ptr, &sigBits)) { |
760 if (5 == sigBits->red && 6 == sigBits->green && 5 == sigBits->bl ue) { | 760 if (5 == sigBits->red && 6 == sigBits->green && 5 == sigBits->bl ue) { |
761 // Recommend a decode to 565 if the sBIT indicates 565. | 761 // Recommend a decode to 565 if the sBIT indicates 565. |
762 imageInfo = imageInfo.makeColorType(kRGB_565_SkColorType); | 762 imageInfo = imageInfo.makeColorType(kRGB_565_SkColorType); |
763 } | 763 } |
764 } | 764 } |
765 } | 765 } |
766 | 766 |
767 if (PNG_COLOR_TYPE_GRAY == encodedColorType) { | |
768 png_textp text; | |
769 if (png_get_text(png_ptr, info_ptr, &text, nullptr)) { | |
770 if (0 == strcmp("SkColorType", text->key) && 0 == strcmp("Alpha8 ", text->text)) { | |
msarett
2016/08/30 14:30:38
Ideally, we store these strings somewhere that is
| |
771 // Recommend a decode to Alpha8 if our custom encoder has ma rked | |
772 // the image as Alpha8. | |
773 imageInfo = imageInfo.makeColorType(kAlpha_8_SkColorType) | |
774 .makeAlphaType(kPremul_SkAlphaType); | |
775 } | |
776 } | |
777 } | |
778 | |
767 if (1 == numberPasses) { | 779 if (1 == numberPasses) { |
768 *outCodec = new SkPngNormalCodec(encodedInfo, imageInfo, stream, | 780 *outCodec = new SkPngNormalCodec(encodedInfo, imageInfo, stream, |
769 chunkReader, png_ptr, info_ptr, bitDepth); | 781 chunkReader, png_ptr, info_ptr, bitDepth); |
770 } else { | 782 } else { |
771 *outCodec = new SkPngInterlacedCodec(encodedInfo, imageInfo, stream, | 783 *outCodec = new SkPngInterlacedCodec(encodedInfo, imageInfo, stream, |
772 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses); | 784 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses); |
773 } | 785 } |
774 } | 786 } |
775 | 787 |
776 return true; | 788 return true; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 SkCodec* outCodec; | 938 SkCodec* outCodec; |
927 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { | 939 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { |
928 // Codec has taken ownership of the stream. | 940 // Codec has taken ownership of the stream. |
929 SkASSERT(outCodec); | 941 SkASSERT(outCodec); |
930 streamDeleter.release(); | 942 streamDeleter.release(); |
931 return outCodec; | 943 return outCodec; |
932 } | 944 } |
933 | 945 |
934 return nullptr; | 946 return nullptr; |
935 } | 947 } |
OLD | NEW |