19 if (
nullptr == codec) {
24 switch (codec->getEncodedFormat()) {
37BitmapRegionDecoder::BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec)
38 : fCodec(
std::move(codec))
42 return fCodec->getInfo().width();
46 return fCodec->getInfo().height();
76 if (!fCodec->getSupportedSubset(&subset)) {
80 SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset);
83 SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul);
85 SkImageInfo::Make(scaledSize, dstColorType, dstAlphaType, std::move(dstColorSpace));
90 int scaledOutWidth = scaledSize.
width();
91 int scaledOutHeight = scaledSize.
height();
93 scaledOutX = outX / sampleSize;
94 scaledOutY = outY / sampleSize;
98 const int scaledExtraX = extraX / sampleSize;
99 const int scaledExtraY = extraY / sampleSize;
100 scaledOutWidth += scaledOutX + scaledExtraX;
101 scaledOutHeight += scaledOutY + scaledExtraY;
112 if (!
bitmap->tryAllocPixels(allocator)) {
125 void* pixels =
bitmap->getPixels();
127 memset(pixels, 0, bytes);
132 options.fSampleSize = sampleSize;
134 options.fZeroInitialized = zeroInit;
135 void*
dst =
bitmap->getAddr(scaledOutX, scaledOutY);
145 SkCodecPrintf(
"Error: Could not get pixels with message \"%s\".\n",
@ kPartiallyInside_SubsetType
SubsetType adjust_subset_rect(const SkISize &imageDims, SkIRect *subset, int *outX, int *outY)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkCodecPrintf(...)
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
static const char * ResultToString(Result)
virtual SkCodec::ZeroInitialized zeroInit() const =0
bool decodeRegion(SkBitmap *bitmap, BRDAllocator *allocator, const SkIRect &desiredSubset, int sampleSize, SkColorType colorType, bool requireUnpremul, sk_sp< SkColorSpace > prefColorSpace)
static std::unique_ptr< BitmapRegionDecoder > Make(sk_sp< SkData > data)
static float max(float r, float g, float b)
constexpr int32_t height() const
constexpr int32_t width() const
constexpr int32_t width() const
constexpr int32_t height() const
SkImageInfo makeWH(int newWidth, int newHeight) const
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
size_t computeByteSize(size_t rowBytes) const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkImageInfo makeColorType(SkColorType newColorType) const
std::shared_ptr< const fml::Mapping > data