35e5d1b449
The result SkBitmap, the pixel allocator, and the alpha preference need to be communicated from the client to the region decoder. BUG=skia: Review URL: https://codereview.chromium.org/1418093006
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
/*
|
|
* Copyright 2015 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkBitmapRegionSampler.h"
|
|
#include "SkCodecPriv.h"
|
|
|
|
SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width,
|
|
int height)
|
|
: INHERITED(width, height)
|
|
, fDecoder(decoder)
|
|
{}
|
|
|
|
bool SkBitmapRegionSampler::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* allocator,
|
|
const SkIRect& desiredSubset, int sampleSize, SkColorType colorType, bool requireUnpremul) {
|
|
fDecoder->setDitherImage(true);
|
|
fDecoder->setPreferQualityOverSpeed(false);
|
|
fDecoder->setRequireUnpremultipliedColors(false);
|
|
fDecoder->setSampleSize(sampleSize);
|
|
fDecoder->setAllocator(allocator);
|
|
|
|
// kAlpha8 is the legacy representation of kGray8 used by SkImageDecoder
|
|
if (kGray_8_SkColorType == colorType) {
|
|
colorType = kAlpha_8_SkColorType;
|
|
}
|
|
|
|
bool result = fDecoder->decodeSubset(bitmap, desiredSubset, colorType);
|
|
fDecoder->setAllocator(nullptr);
|
|
return result;
|
|
}
|