// TODO: this could be improved to decode and make use of the mipmap // levels potentially present in the compressed data. For now, any // mipmap levels are discarded.
sk_sp<SkImage> RasterFromCompressedTextureData(sk_sp<SkData> data, int width, int height,
SkTextureCompressionType type) {
size_t expectedSize = SkCompressedFormatDataSize(type, {width, height}, false); if (!data || data->size() < expectedSize) { return nullptr;
}
SkAlphaType at =
SkTextureCompressionTypeIsOpaque(type) ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo ii = SkImageInfo::MakeN32(width, height, at);
if (!valid_args(ii, ii.minRowBytes(), nullptr)) { return nullptr;
}
SkBitmap bitmap; if (!bitmap.tryAllocPixels(ii)) { return nullptr;
}
if (!SkDecompress(std::move(data), {width, height}, type, &bitmap)) { return nullptr;
}
// Here we actually make a copy of the caller's pixel data
sk_sp<SkData> data(SkData::MakeWithCopy(pmap.addr(), size)); return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), id);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.