本文整理汇总了C++中SkAutoTDelete::transferBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTDelete::transferBuffer方法的具体用法?C++ SkAutoTDelete::transferBuffer怎么用?C++ SkAutoTDelete::transferBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTDelete
的用法示例。
在下文中一共展示了SkAutoTDelete::transferBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewFromStream
/*
* Tries to handle the image with PIEX. If PIEX returns kOk and finds the preview image, create a
* SkJpegCodec. If PIEX returns kFail, then the file is invalid, return nullptr. In other cases,
* fallback to create SkRawCodec for DNG images.
*/
SkCodec* SkRawCodec::NewFromStream(SkStream* stream) {
SkAutoTDelete<SkRawStream> rawStream;
if (is_asset_stream(*stream)) {
rawStream.reset(new SkRawAssetStream(stream));
} else {
rawStream.reset(new SkRawBufferedStream(stream));
}
// Does not take the ownership of rawStream.
SkPiexStream piexStream(rawStream.get());
::piex::PreviewImageData imageData;
if (::piex::IsRaw(&piexStream)) {
::piex::Error error = ::piex::GetPreviewImageData(&piexStream, &imageData);
if (error == ::piex::Error::kOk && imageData.preview.length > 0) {
// transferBuffer() is destructive to the rawStream. Abandon the rawStream after this
// function call.
// FIXME: one may avoid the copy of memoryStream and use the buffered rawStream.
SkMemoryStream* memoryStream =
rawStream->transferBuffer(imageData.preview.offset, imageData.preview.length);
return memoryStream ? SkJpegCodec::NewFromStream(memoryStream) : nullptr;
} else if (error == ::piex::Error::kFail) {
return nullptr;
}
}
// Takes the ownership of the rawStream.
SkAutoTDelete<SkDngImage> dngImage(SkDngImage::NewFromStream(rawStream.release()));
if (!dngImage) {
return nullptr;
}
return new SkRawCodec(dngImage.release());
}