本文整理汇总了C++中SkAutoTDelete::getEncodedFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTDelete::getEncodedFormat方法的具体用法?C++ SkAutoTDelete::getEncodedFormat怎么用?C++ SkAutoTDelete::getEncodedFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTDelete
的用法示例。
在下文中一共展示了SkAutoTDelete::getEncodedFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
SkStreamRewindable* stream, Strategy strategy) {
SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kCanvas_Strategy: {
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.detach()));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create decoder.\n");
return nullptr;
}
SkEncodedFormat format = codec->getEncodedFormat();
switch (format) {
case SkEncodedFormat::kJPEG_SkEncodedFormat:
case SkEncodedFormat::kPNG_SkEncodedFormat:
break;
default:
// FIXME: Support webp using a special case. Webp does not support
// scanline decoding.
return nullptr;
}
// If the image is a jpeg or a png, the scanline ordering should always be
// kTopDown or kNone. It is relevant to check because this implementation
// only supports these two scanline orderings.
SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrder() ||
SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder());
return new SkBitmapRegionCanvas(codec.detach());
}
case kAndroidCodec_Strategy: {
SkAutoTDelete<SkAndroidCodec> codec =
SkAndroidCodec::NewFromStream(streamDeleter.detach());
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return NULL;
}
SkEncodedFormat format = codec->getEncodedFormat();
switch (format) {
case SkEncodedFormat::kJPEG_SkEncodedFormat:
case SkEncodedFormat::kPNG_SkEncodedFormat:
case SkEncodedFormat::kWEBP_SkEncodedFormat:
break;
default:
return nullptr;
}
return new SkBitmapRegionCodec(codec.detach());
}
default:
SkASSERT(false);
return nullptr;
}
}