| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkBitmapRegionSampler.h" | |
| 9 #include "SkCodecPriv.h" | |
| 10 | |
| 11 SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width,
| |
| 12 int height) | |
| 13 : INHERITED(width, height) | |
| 14 , fDecoder(decoder) | |
| 15 {} | |
| 16 | |
| 17 bool SkBitmapRegionSampler::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator*
allocator, | |
| 18 const SkIRect& desiredSubset, int sampleSize, SkColorType colorType, boo
l requireUnpremul) { | |
| 19 fDecoder->setDitherImage(true); | |
| 20 fDecoder->setPreferQualityOverSpeed(false); | |
| 21 fDecoder->setRequireUnpremultipliedColors(false); | |
| 22 fDecoder->setSampleSize(sampleSize); | |
| 23 fDecoder->setAllocator(allocator); | |
| 24 | |
| 25 // kAlpha8 is the legacy representation of kGray8 used by SkImageDecoder | |
| 26 if (kGray_8_SkColorType == colorType) { | |
| 27 colorType = kAlpha_8_SkColorType; | |
| 28 } | |
| 29 | |
| 30 bool result = fDecoder->decodeSubset(bitmap, desiredSubset, colorType); | |
| 31 fDecoder->setAllocator(nullptr); | |
| 32 return result; | |
| 33 } | |
| OLD | NEW |