本文整理汇总了C++中SkAutoTDelete::decode方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTDelete::decode方法的具体用法?C++ SkAutoTDelete::decode怎么用?C++ SkAutoTDelete::decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTDelete
的用法示例。
在下文中一共展示了SkAutoTDelete::decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onGetPixels
virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
const Options&,
SkPMColor ctableEntries[], int* ctableCount) override {
SkMemoryStream stream(fData->data(), fData->size(), false);
SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
(info, pixels, rowBytes)));
fDecoder->setAllocator(allocator);
fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType());
SkBitmap bm;
const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
SkImageDecoder::kDecodePixels_Mode);
if (SkImageDecoder::kFailure == result) {
return kInvalidInput;
}
SkASSERT(info.colorType() == bm.info().colorType());
if (kIndex_8_SkColorType == info.colorType()) {
SkASSERT(ctableEntries);
SkColorTable* ctable = bm.getColorTable();
if (NULL == ctable) {
return kInvalidConversion;
}
const int count = ctable->count();
memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
*ctableCount = count;
}
if (SkImageDecoder::kPartialSuccess == result) {
return kIncompleteInput;
}
return kSuccess;
}
示例2: onDraw
void DecodingBench::onDraw(const int n, SkCanvas* canvas) {
SkBitmap bitmap;
// Declare the allocator before the decoder, so it will outlive the
// decoder, which will unref it.
UseExistingAllocator allocator(fBitmap.pixelRef());
SkAutoTDelete<SkImageDecoder> decoder;
SkAutoTDelete<SkStreamRewindable> stream;
for (int i = 0; i < n; i++) {
// create a new stream and a new decoder to mimic the behavior of
// CodecBench.
stream.reset(new SkMemoryStream(fData));
decoder.reset(SkImageDecoder::Factory(stream));
decoder->setAllocator(&allocator);
decoder->decode(stream, &bitmap, fColorType,
SkImageDecoder::kDecodePixels_Mode);
}
}