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

Side by Side Diff: src/codec/SkPngCodec.cpp

Issue 2212563003: Modify SkPngCodec to recognize 565 images from the sBIT chunk (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up test Created 4 years, 4 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
OLDNEW
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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 color = SkEncodedInfo::kRGBA_Color; 699 color = SkEncodedInfo::kRGBA_Color;
700 alpha = SkEncodedInfo::kUnpremul_Alpha; 700 alpha = SkEncodedInfo::kUnpremul_Alpha;
701 break; 701 break;
702 default: 702 default:
703 // All the color types have been covered above. 703 // All the color types have been covered above.
704 SkASSERT(false); 704 SkASSERT(false);
705 color = SkEncodedInfo::kRGBA_Color; 705 color = SkEncodedInfo::kRGBA_Color;
706 alpha = SkEncodedInfo::kUnpremul_Alpha; 706 alpha = SkEncodedInfo::kUnpremul_Alpha;
707 } 707 }
708 708
709 // Add a special check for 565.
710 if (SkEncodedInfo::kOpaque_Alpha == alpha) {
711 png_color_8p sigBits;
712 if (png_get_sBIT(png_ptr, info_ptr, &sigBits)) {
713 if (5 == sigBits->red && 6 == sigBits->green && 5 == sigBits->blue) {
714 color = SkEncodedInfo::k565_Color;
715 }
716 }
717 }
718
709 int numberPasses = png_set_interlace_handling(png_ptr); 719 int numberPasses = png_set_interlace_handling(png_ptr);
710 720
711 autoClean.release(); 721 autoClean.release();
712 if (png_ptrp) { 722 if (png_ptrp) {
713 *png_ptrp = png_ptr; 723 *png_ptrp = png_ptr;
714 } 724 }
715 if (info_ptrp) { 725 if (info_ptrp) {
716 *info_ptrp = info_ptr; 726 *info_ptrp = info_ptr;
717 } 727 }
718 728
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 SkCodec* outCodec; 889 SkCodec* outCodec;
880 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { 890 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) {
881 // Codec has taken ownership of the stream. 891 // Codec has taken ownership of the stream.
882 SkASSERT(outCodec); 892 SkASSERT(outCodec);
883 streamDeleter.release(); 893 streamDeleter.release();
884 return outCodec; 894 return outCodec;
885 } 895 }
886 896
887 return nullptr; 897 return nullptr;
888 } 898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698