Index: src/images/SkImageDecoder.cpp |
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp |
index fe61906357d43bd88bb52299dbeb903a4d60f90e..8447ed46f71abc0e39492e5aeb47a6c614257da9 100644 |
--- a/src/images/SkImageDecoder.cpp |
+++ b/src/images/SkImageDecoder.cpp |
@@ -22,6 +22,7 @@ SkImageDecoder::SkImageDecoder() |
, fAllocator(NULL) |
, fSampleSize(1) |
, fDefaultPref(kUnknown_SkColorType) |
+ , fPreserveSrcDepth(false) |
, fDitherImage(true) |
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG |
, fUsePrefTable(false) |
@@ -156,7 +157,6 @@ void SkImageDecoder::setPrefConfigTable(const PrefConfigTable& prefTable) { |
SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha) const { |
SkColorType ct = fDefaultPref; |
#ifdef SK_SUPPORT_LEGACY_BITMAP_CONFIG |
- |
if (fUsePrefTable) { |
// Until we kill or change the PrefTable, we have to go into Config land for a moment. |
SkBitmap::Config config = SkBitmap::kNo_Config; |
@@ -177,6 +177,19 @@ SkColorType SkImageDecoder::getPrefColorType(SrcDepth srcDepth, bool srcHasAlpha |
ct = SkBitmapConfigToColorType(config); |
} |
#endif |
+ if (fPreserveSrcDepth) { |
+ switch (srcDepth) { |
+ case kIndex_SrcDepth: |
+ ct = kIndex_8_SkColorType; |
+ break; |
+ case k8BitGray_SrcDepth: |
+ ct = kN32_SkColorType; |
+ break; |
+ case k32Bit_SrcDepth: |
+ ct = kN32_SkColorType; |
+ break; |
+ } |
+ } |
return ct; |
} |