51 {
52
53
54 if (sampleSize < 1) {
55 sampleSize = 1;
56 }
57
58
59
60
61
62
63
64
65
66
67 int outX;
68 int outY;
72 return false;
73 }
74
75
76 if (!fCodec->getSupportedSubset(&subset)) {
78 return false;
79 }
80 SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset);
81
82
83 SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul);
85 SkImageInfo::Make(scaledSize, dstColorType, dstAlphaType, std::move(dstColorSpace));
86
87
88 int scaledOutX = 0;
89 int scaledOutY = 0;
90 int scaledOutWidth = scaledSize.
width();
91 int scaledOutHeight = scaledSize.
height();
93 scaledOutX = outX / sampleSize;
94 scaledOutY = outY / sampleSize;
95
98 const int scaledExtraX = extraX / sampleSize;
99 const int scaledExtraY = extraY / sampleSize;
100 scaledOutWidth += scaledOutX + scaledExtraX;
101 scaledOutHeight += scaledOutY + scaledExtraY;
102 }
105
106
107
108
110 }
112 if (!
bitmap->tryAllocPixels(allocator)) {
114 return false;
115 }
116
117
118
119
120
125 void* pixels =
bitmap->getPixels();
127 memset(pixels, 0, bytes);
128 }
129
130
132 options.fSampleSize = sampleSize;
134 options.fZeroInitialized = zeroInit;
135 void*
dst =
bitmap->getAddr(scaledOutX, scaledOutY);
136
143 return true;
144 default:
145 SkCodecPrintf(
"Error: Could not get pixels with message \"%s\".\n",
147 return false;
148 }
149}
@ 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 const char * ResultToString(Result)
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