OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 //SkASSERT(!*hasAlphap); | 528 //SkASSERT(!*hasAlphap); |
529 } | 529 } |
530 | 530 |
531 *configp = this->getPrefConfig(srcDepth, *hasAlphap); | 531 *configp = this->getPrefConfig(srcDepth, *hasAlphap); |
532 // now match the request against our capabilities | 532 // now match the request against our capabilities |
533 if (*hasAlphap) { | 533 if (*hasAlphap) { |
534 if (*configp != SkBitmap::kARGB_4444_Config) { | 534 if (*configp != SkBitmap::kARGB_4444_Config) { |
535 *configp = SkBitmap::kARGB_8888_Config; | 535 *configp = SkBitmap::kARGB_8888_Config; |
536 } | 536 } |
537 } else { | 537 } else { |
538 if (*configp != SkBitmap::kRGB_565_Config && | 538 if (SkBitmap::kA8_Config == *configp) { |
539 *configp != SkBitmap::kARGB_4444_Config && | 539 if (k8BitGray_SrcDepth != srcDepth) { |
540 *configp != SkBitmap::kA8_Config) { | 540 // Converting a non grayscale image to A8 is not currently s
upported. |
| 541 *configp = SkBitmap::kARGB_8888_Config; |
| 542 } |
| 543 } else if (*configp != SkBitmap::kRGB_565_Config && |
| 544 *configp != SkBitmap::kARGB_4444_Config) { |
541 *configp = SkBitmap::kARGB_8888_Config; | 545 *configp = SkBitmap::kARGB_8888_Config; |
542 } | 546 } |
543 } | 547 } |
544 } | 548 } |
545 | 549 |
546 // sanity check for size | 550 // sanity check for size |
547 { | 551 { |
548 Sk64 size; | 552 Sk64 size; |
549 size.setMul(origWidth, origHeight); | 553 size.setMul(origWidth, origHeight); |
550 if (size.isNeg() || !size.is32()) { | 554 if (size.isNeg() || !size.is32()) { |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 return SkImageDecoder::kUnknown_Format; | 1201 return SkImageDecoder::kUnknown_Format; |
1198 } | 1202 } |
1199 | 1203 |
1200 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1204 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1201 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1205 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1202 } | 1206 } |
1203 | 1207 |
1204 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1208 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1205 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1209 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1206 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1210 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |