本文整理汇总了C++中SkImageInfo::makeWH方法的典型用法代码示例。如果您正苦于以下问题:C++ SkImageInfo::makeWH方法的具体用法?C++ SkImageInfo::makeWH怎么用?C++ SkImageInfo::makeWH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkImageInfo
的用法示例。
在下文中一共展示了SkImageInfo::makeWH方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillIncompleteImage
void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t rowBytes,
ZeroInitialized zeroInit, int linesRequested, int linesDecoded) {
void* fillDst;
const uint32_t fillValue = this->getFillValue(info.colorType(), info.alphaType());
const int linesRemaining = linesRequested - linesDecoded;
SkSampler* sampler = this->getSampler(false);
switch (this->getScanlineOrder()) {
case kTopDown_SkScanlineOrder:
case kNone_SkScanlineOrder: {
const SkImageInfo fillInfo = info.makeWH(info.width(), linesRemaining);
fillDst = SkTAddOffset<void>(dst, linesDecoded * rowBytes);
fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
break;
}
case kBottomUp_SkScanlineOrder: {
fillDst = dst;
const SkImageInfo fillInfo = info.makeWH(info.width(), linesRemaining);
fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
break;
}
case kOutOfOrder_SkScanlineOrder: {
SkASSERT(1 == linesRequested || this->getInfo().height() == linesRequested);
const SkImageInfo fillInfo = info.makeWH(info.width(), 1);
for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * rowBytes);
fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, sampler);
}
break;
}
}
}
示例2: readPixels
bool SkPixmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB,
int x, int y) const {
if (kUnknown_SkColorType == requestedDstInfo.colorType()) {
return false;
}
if (nullptr == dstPixels || dstRB < requestedDstInfo.minRowBytes()) {
return false;
}
if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) {
return false;
}
SkIRect srcR = SkIRect::MakeXYWH(x, y, requestedDstInfo.width(), requestedDstInfo.height());
if (!srcR.intersect(0, 0, this->width(), this->height())) {
return false;
}
// the intersect may have shrunk info's logical size
const SkImageInfo dstInfo = requestedDstInfo.makeWH(srcR.width(), srcR.height());
// if x or y are negative, then we have to adjust pixels
if (x > 0) {
x = 0;
}
if (y > 0) {
y = 0;
}
// here x,y are either 0 or negative
dstPixels = ((char*)dstPixels - y * dstRB - x * dstInfo.bytesPerPixel());
const SkImageInfo srcInfo = this->info().makeWH(dstInfo.width(), dstInfo.height());
const void* srcPixels = this->addr(srcR.x(), srcR.y());
return SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRB,
srcInfo, srcPixels, this->rowBytes(), this->ctable());
}
示例3: decodeRows
/*
* Performs the decoding
*/
int SkBmpMaskCodec::decodeRows(const SkImageInfo& dstInfo,
void* dst, size_t dstRowBytes,
const Options& opts) {
// Iterate over rows of the image
uint8_t* srcRow = fSrcBuffer.get();
const int height = dstInfo.height();
for (int y = 0; y < height; y++) {
// Read a row of the input
if (this->stream()->read(srcRow, this->srcRowBytes()) != this->srcRowBytes()) {
SkCodecPrintf("Warning: incomplete input stream.\n");
return y;
}
// Decode the row in destination format
uint32_t row = this->getDstRow(y, height);
void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes);
if (this->colorXform()) {
SkImageInfo xformInfo = dstInfo.makeWH(fMaskSwizzler->swizzleWidth(), dstInfo.height());
fMaskSwizzler->swizzle(this->xformBuffer(), srcRow);
this->applyColorXform(xformInfo, dstRow, this->xformBuffer());
} else {
fMaskSwizzler->swizzle(dstRow, srcRow);
}
}
// Finished decoding the entire image
return height;
}
示例4: sizeof
// Much of readPixels is exercised by copyTo testing, since readPixels is the backend for that
// method. Here we explicitly test subset copies.
//
DEF_TEST(BitmapReadPixels, reporter) {
const int W = 4;
const int H = 4;
const size_t rowBytes = W * sizeof(SkPMColor);
const SkImageInfo srcInfo = SkImageInfo::MakeN32Premul(W, H);
SkPMColor srcPixels[16];
fill_4x4_pixels(srcPixels);
SkBitmap srcBM;
srcBM.installPixels(srcInfo, srcPixels, rowBytes);
SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(W, H);
SkPMColor dstPixels[16];
const struct {
bool fExpectedSuccess;
SkIPoint fRequestedSrcLoc;
SkISize fRequestedDstSize;
// If fExpectedSuccess, check these, otherwise ignore
SkIPoint fExpectedDstLoc;
SkIRect fExpectedSrcR;
} gRec[] = {
{ true, { 0, 0 }, { 4, 4 }, { 0, 0 }, { 0, 0, 4, 4 } },
{ true, { 1, 1 }, { 2, 2 }, { 0, 0 }, { 1, 1, 3, 3 } },
{ true, { 2, 2 }, { 4, 4 }, { 0, 0 }, { 2, 2, 4, 4 } },
{ true, {-1,-1 }, { 2, 2 }, { 1, 1 }, { 0, 0, 1, 1 } },
{ false, {-1,-1 }, { 1, 1 }, { 0, 0 }, { 0, 0, 0, 0 } },
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
clear_4x4_pixels(dstPixels);
dstInfo = dstInfo.makeWH(gRec[i].fRequestedDstSize.width(),
gRec[i].fRequestedDstSize.height());
bool success = srcBM.readPixels(dstInfo, dstPixels, rowBytes,
gRec[i].fRequestedSrcLoc.x(), gRec[i].fRequestedSrcLoc.y());
REPORTER_ASSERT(reporter, gRec[i].fExpectedSuccess == success);
if (success) {
const SkIRect srcR = gRec[i].fExpectedSrcR;
const int dstX = gRec[i].fExpectedDstLoc.x();
const int dstY = gRec[i].fExpectedDstLoc.y();
// Walk the dst pixels, and check if we got what we expected
for (int y = 0; y < H; ++y) {
for (int x = 0; x < W; ++x) {
SkPMColor dstC = dstPixels[y*4+x];
// get into src coordinates
int sx = x - dstX + srcR.x();
int sy = y - dstY + srcR.y();
if (srcR.contains(sx, sy)) {
REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy));
} else {
REPORTER_ASSERT(reporter, 0 == dstC);
}
}
}
}
}
}
示例5: test_newraster
static void test_newraster(skiatest::Reporter* reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
const size_t minRowBytes = info.minRowBytes();
const size_t size = info.getSafeSize(minRowBytes);
SkAutoMalloc storage(size);
SkPMColor* baseAddr = static_cast<SkPMColor*>(storage.get());
sk_bzero(baseAddr, size);
SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
SkImageInfo info2;
size_t rowBytes;
const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowBytes);
REPORTER_ASSERT(reporter, addr);
REPORTER_ASSERT(reporter, info == info2);
REPORTER_ASSERT(reporter, minRowBytes == rowBytes);
for (int y = 0; y < info.height(); ++y) {
for (int x = 0; x < info.width(); ++x) {
REPORTER_ASSERT(reporter, 0 == addr[x]);
}
addr = (const SkPMColor*)((const char*)addr + rowBytes);
}
SkDELETE(canvas);
// now try a deliberately bad info
info = info.makeWH(-1, info.height());
REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// too big
info = info.makeWH(1 << 30, 1 << 30);
REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// not a valid pixel type
info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType());
REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes));
// We should succeed with a zero-sized valid info
info = SkImageInfo::MakeN32Premul(0, 0);
canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
SkDELETE(canvas);
}
示例6: check_fill
static void check_fill(skiatest::Reporter* r,
const SkImageInfo& imageInfo,
uint32_t startRow,
uint32_t endRow,
size_t rowBytes,
uint32_t offset,
uint32_t colorOrIndex) {
// Calculate the total size of the image in bytes. Use the smallest possible size.
// The offset value tells us to adjust the pointer from the memory we allocate in order
// to test on different memory alignments. If offset is nonzero, we need to increase the
// size of the memory we allocate in order to make sure that we have enough. We are
// still allocating the smallest possible size.
const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset;
// Create fake image data where every byte has a value of 0
SkAutoTDeleteArray<uint8_t> storage(new uint8_t[totalBytes]);
memset(storage.get(), 0, totalBytes);
// Adjust the pointer in order to test on different memory alignments
uint8_t* imageData = storage.get() + offset;
uint8_t* imageStart = imageData + rowBytes * startRow;
const SkImageInfo fillInfo = imageInfo.makeWH(imageInfo.width(), endRow - startRow + 1);
SkSampler::Fill(fillInfo, imageStart, rowBytes, colorOrIndex, SkCodec::kNo_ZeroInitialized);
// Ensure that the pixels are filled properly
// The bots should catch any memory corruption
uint8_t* indexPtr = imageData + startRow * rowBytes;
uint8_t* grayPtr = indexPtr;
uint32_t* colorPtr = (uint32_t*) indexPtr;
uint16_t* color565Ptr = (uint16_t*) indexPtr;
for (uint32_t y = startRow; y <= endRow; y++) {
for (int32_t x = 0; x < imageInfo.width(); x++) {
switch (imageInfo.colorType()) {
case kIndex_8_SkColorType:
REPORTER_ASSERT(r, kFillIndex == indexPtr[x]);
break;
case kN32_SkColorType:
REPORTER_ASSERT(r, kFillColor == colorPtr[x]);
break;
case kGray_8_SkColorType:
REPORTER_ASSERT(r, kFillGray == grayPtr[x]);
break;
case kRGB_565_SkColorType:
REPORTER_ASSERT(r, kFill565 == color565Ptr[x]);
break;
default:
REPORTER_ASSERT(r, false);
break;
}
}
indexPtr += rowBytes;
colorPtr = (uint32_t*) indexPtr;
}
}
示例7: test_newraster
static void test_newraster(skiatest::Reporter* reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
const size_t minRowBytes = info.minRowBytes();
const size_t size = info.getSafeSize(minRowBytes);
SkAutoTMalloc<SkPMColor> storage(size);
SkPMColor* baseAddr = storage.get();
sk_bzero(baseAddr, size);
std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
SkPixmap pmap;
const SkPMColor* addr = canvas->peekPixels(&pmap) ? pmap.addr32() : nullptr;
REPORTER_ASSERT(reporter, addr);
REPORTER_ASSERT(reporter, info == pmap.info());
REPORTER_ASSERT(reporter, minRowBytes == pmap.rowBytes());
for (int y = 0; y < info.height(); ++y) {
for (int x = 0; x < info.width(); ++x) {
REPORTER_ASSERT(reporter, 0 == addr[x]);
}
addr = (const SkPMColor*)((const char*)addr + pmap.rowBytes());
}
// now try a deliberately bad info
info = info.makeWH(-1, info.height());
REPORTER_ASSERT(reporter, nullptr == SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes));
// too big
info = info.makeWH(1 << 30, 1 << 30);
REPORTER_ASSERT(reporter, nullptr == SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes));
// not a valid pixel type
info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType());
REPORTER_ASSERT(reporter, nullptr == SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes));
// We should succeed with a zero-sized valid info
info = SkImageInfo::MakeN32Premul(0, 0);
canvas = SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes);
REPORTER_ASSERT(reporter, canvas);
}
示例8: setWHZ
void setWHZ(int width, int height, int zoom) {
fZoom = zoom;
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
fShader.reset(sk_tool_utils::create_checkerboard_shader(
0xFFCCCCCC, 0xFFFFFFFF, zoom));
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
fMinSurface.reset(SkSurface::NewRaster(info));
info = info.makeWH(width * zoom, height * zoom);
fMaxSurface.reset(SkSurface::NewRaster(info));
}
示例9: getBitmapDeprecated
bool getBitmapDeprecated(SkBitmap* result) const override {
const SkImageInfo info = GrMakeInfoFromTexture(fTexture,
this->width(), this->height(),
this->isOpaque());
if (!result->setInfo(info)) {
return false;
}
const SkImageInfo prInfo = info.makeWH(fTexture->width(), fTexture->height());
SkAutoTUnref<SkGrPixelRef> pixelRef(new SkGrPixelRef(prInfo, fTexture));
result->setPixelRef(pixelRef, this->subset().fLeft, this->subset().fTop);
return true;
}
示例10: onGetPixels
/*
* Initiates the gif decode
*/
SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
void* dst, size_t dstRowBytes,
const Options& opts,
SkPMColor* inputColorPtr,
int* inputColorCount,
int* rowsDecoded) {
Result result = this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, opts);
if (kSuccess != result) {
return result;
}
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
return gif_error("Scaling not supported.\n", kInvalidScale);
}
// Initialize the swizzler
if (fFrameIsSubset) {
const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height());
if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts)) {
return gif_error("Could not initialize swizzler.\n", kUnimplemented);
}
// Fill the background
SkSampler::Fill(dstInfo, dst, dstRowBytes,
this->getFillValue(dstInfo.colorType(), dstInfo.alphaType()),
opts.fZeroInitialized);
// Modify the dst pointer
const int32_t dstBytesPerPixel = SkColorTypeBytesPerPixel(dstInfo.colorType());
dst = SkTAddOffset<void*>(dst, dstRowBytes * fFrameRect.top() +
dstBytesPerPixel * fFrameRect.left());
} else {
if (kSuccess != this->initializeSwizzler(dstInfo, opts)) {
return gif_error("Could not initialize swizzler.\n", kUnimplemented);
}
}
// Iterate over rows of the input
uint32_t height = fFrameRect.height();
for (uint32_t y = 0; y < height; y++) {
if (!this->readRow()) {
*rowsDecoded = y;
return gif_error("Could not decode line.\n", kIncompleteInput);
}
void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanline(y));
fSwizzler->swizzle(dstRow, fSrcBuffer.get());
}
return kSuccess;
}
示例11: setWHZ
void setWHZ(int width, int height, int zoom) {
fW = width;
fH = height;
fZoom = zoom;
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
fShader0 = sk_tool_utils::create_checkerboard_shader(0xFFDDDDDD, 0xFFFFFFFF, zoom);
fShader1 = SkShader::MakeColorShader(SK_ColorWHITE);
fShader = fShader0;
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
fMinSurface = SkSurface::MakeRaster(info);
info = info.makeWH(width * zoom, height * zoom);
fMaxSurface = SkSurface::MakeRaster(info);
}
示例12: SkInstallDiscardablePixelRef
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, const SkIRect* subset, SkBitmap* dst,
SkDiscardableMemory::Factory* factory) {
SkAutoTDelete<SkImageGenerator> autoGenerator(generator);
if (NULL == autoGenerator.get()) {
return false;
}
SkImageInfo prInfo = autoGenerator->getInfo();
if (prInfo.isEmpty()) {
return false;
}
SkIPoint origin = SkIPoint::Make(0, 0);
SkImageInfo bmInfo = prInfo;
if (subset) {
const SkIRect prBounds = SkIRect::MakeWH(prInfo.width(), prInfo.height());
if (subset->isEmpty() || !prBounds.contains(*subset)) {
return false;
}
bmInfo = prInfo.makeWH(subset->width(), subset->height());
origin.set(subset->x(), subset->y());
}
// must compute our desired rowBytes w.r.t. the pixelRef's dimensions, not ours, which may be
// smaller.
if (!dst->setInfo(bmInfo, prInfo.minRowBytes())) {
return false;
}
// Since dst->setInfo() may have changed/fixed-up info, we check from the bitmap
SkASSERT(dst->info().colorType() != kUnknown_SkColorType);
if (dst->empty()) { // Use a normal pixelref.
return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBytes(), factory));
dst->setPixelRef(ref, origin.x(), origin.y());
return true;
}
示例13: onStartScanlineDecode
SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColorCount) {
Result result = this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, this->options());
if (kSuccess != result) {
return result;
}
// Initialize the swizzler
if (fFrameIsSubset) {
const SkImageInfo subsetDstInfo = dstInfo.makeWH(fFrameRect.width(), fFrameRect.height());
if (kSuccess != this->initializeSwizzler(subsetDstInfo, opts)) {
return gif_error("Could not initialize swizzler.\n", kUnimplemented);
}
} else {
if (kSuccess != this->initializeSwizzler(dstInfo, opts)) {
return gif_error("Could not initialize swizzler.\n", kUnimplemented);
}
}
return kSuccess;
}
示例14: onDraw
void SubsetSingleBench::onDraw(const int n, SkCanvas* canvas) {
// When the color type is kIndex8, we will need to store the color table. If it is
// used, it will be initialized by the codec.
int colorCount;
SkPMColor colors[256];
if (fUseCodec) {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate()));
const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes()));
SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder(
info, NULL, colors, &colorCount);
SkBitmap bitmap;
bitmap.allocPixels(info.makeWH(fSubsetWidth, fSubsetHeight));
scanlineDecoder->skipScanlines(fOffsetTop);
uint32_t bpp = info.bytesPerPixel();
for (uint32_t y = 0; y < fSubsetHeight; y++) {
scanlineDecoder->getScanlines(row.get(), 1, 0);
memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp,
fSubsetWidth * bpp);
}
}
} else {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
int width, height;
decoder->buildTileIndex(fStream->duplicate(), &width, &height);
SkBitmap bitmap;
SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWidth,
fSubsetHeight);
decoder->decodeSubset(&bitmap, rect, fColorType);
}
}
}
示例15: onDraw
void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) {
// When the color type is kIndex8, we will need to store the color table. If it is
// used, it will be initialized by the codec.
int colorCount;
SkPMColor colors[256];
if (fUseCodec) {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(
SkScanlineDecoder::NewFromStream(fStream->duplicate()));
const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType);
SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
scanlineDecoder->start(info, nullptr, colors, &colorCount);
SkBitmap bitmap;
// Note that we use the same bitmap for all of the subsets.
// It might be larger than necessary for the end subsets.
SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
for (int x = 0; x < info.width(); x += fSubsetWidth) {
for (int y = 0; y < info.height(); y += fSubsetHeight) {
scanlineDecoder->skipScanlines(y);
const uint32_t currSubsetWidth =
x + (int) fSubsetWidth > info.width() ?
info.width() - x : fSubsetWidth;
const uint32_t currSubsetHeight =
y + (int) fSubsetHeight > info.height() ?
info.height() - y : fSubsetHeight;
const uint32_t bpp = info.bytesPerPixel();
for (uint32_t y = 0; y < currSubsetHeight; y++) {
scanlineDecoder->getScanlines(row.get(), 1, 0);
memcpy(bitmap.getAddr(0, y), row.get() + x * bpp,
currSubsetWidth * bpp);
}
}
}
}
} else {
// We create a color table here to satisfy allocPixels() when the output
// type is kIndex8. It's okay that this is uninitialized since we never
// use it.
SkColorTable* colorTable = new SkColorTable(colors, 0);
for (int count = 0; count < n; count++) {
int width, height;
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
decoder->buildTileIndex(fStream->duplicate(), &width, &height);
SkBitmap bitmap;
// Note that we use the same bitmap for all of the subsets.
// It might be larger than necessary for the end subsets.
// If we do not include this step, decodeSubset() would allocate space
// for the pixels automatically, but this would not allow us to reuse the
// same bitmap as the other subsets. We want to reuse the same bitmap
// because it gives a more fair comparison with SkCodec and is a common
// use case of BitmapRegionDecoder.
bitmap.allocPixels(SkImageInfo::Make(fSubsetWidth, fSubsetHeight,
fColorType, kOpaque_SkAlphaType), nullptr, colorTable);
for (int x = 0; x < width; x += fSubsetWidth) {
for (int y = 0; y < height; y += fSubsetHeight) {
const uint32_t currSubsetWidth = x + (int) fSubsetWidth > width ?
width - x : fSubsetWidth;
const uint32_t currSubsetHeight = y + (int) fSubsetHeight > height ?
height - y : fSubsetHeight;
SkIRect rect = SkIRect::MakeXYWH(x, y, currSubsetWidth,
currSubsetHeight);
decoder->decodeSubset(&bitmap, rect, fColorType);
}
}
}
}
}