本文整理汇总了C++中sk_sp::refEncoded方法的典型用法代码示例。如果您正苦于以下问题:C++ sk_sp::refEncoded方法的具体用法?C++ sk_sp::refEncoded怎么用?C++ sk_sp::refEncoded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sk_sp
的用法示例。
在下文中一共展示了sk_sp::refEncoded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkPDFCreateBitmapObject
sk_sp<SkPDFObject> SkPDFCreateBitmapObject(sk_sp<SkImage> image,
SkPixelSerializer* pixelSerializer) {
SkASSERT(image);
sk_sp<SkData> data(image->refEncoded());
SkJFIFInfo info;
if (data && SkIsJFIF(data.get(), &info) &&
(!pixelSerializer ||
pixelSerializer->useEncodedData(data->data(), data->size()))) {
// If there is a SkPixelSerializer, give it a chance to
// re-encode the JPEG with more compression by returning false
// from useEncodedData.
bool yuv = info.fType == SkJFIFInfo::kYCbCr;
if (info.fSize == image->dimensions()) { // Sanity check.
// hold on to data, not image.
#ifdef SK_PDF_IMAGE_STATS
gJpegImageObjects.fetch_add(1);
#endif
return sk_make_sp<PDFJpegBitmap>(info.fSize, data.get(), yuv);
}
}
if (pixelSerializer) {
SkBitmap bm;
SkAutoPixmapUnlock apu;
if (as_IB(image.get())->getROPixels(&bm) && bm.requestLock(&apu)) {
data.reset(pixelSerializer->encode(apu.pixmap()));
if (data && SkIsJFIF(data.get(), &info)) {
bool yuv = info.fType == SkJFIFInfo::kYCbCr;
if (info.fSize == image->dimensions()) { // Sanity check.
return sk_make_sp<PDFJpegBitmap>(info.fSize, data.get(), yuv);
}
}
}
}
sk_sp<SkPDFObject> smask;
if (!image_compute_is_opaque(image.get())) {
smask = sk_make_sp<PDFAlphaBitmap>(image);
}
#ifdef SK_PDF_IMAGE_STATS
gRegularImageObjects.fetch_add(1);
#endif
return sk_make_sp<PDFDefaultBitmap>(std::move(image), std::move(smask));
}