SkBitmap targetBitmap; if (!targetBitmap.tryAllocPixels(
SkImageInfo::Make(bitmap.GetSizePixel().getWidth(), bitmap.GetSizePixel().getHeight(),
kRGBA_8888_SkColorType, kPremul_SkAlphaType))) return nullptr;
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc); // set as is
SkMatrix matrix; // The image is needed upside-down.
matrix.preTranslate(0, targetBitmap.height());
matrix.setConcat(matrix, SkMatrix::Scale(1, -1));
if (!bitmapEx.IsAlpha())
{
SkCanvas canvas(targetBitmap);
canvas.concat(matrix);
canvas.drawImage(skiaBitmap->GetSkImage(), 0, 0, SkSamplingOptions(), &paint);
} else
{
AlphaMask alpha(bitmapEx.GetAlphaMask()); // tdf#156854 invert alpha mask for macOS native menu item images // At the time of this change, only the AquaSalMenu class calls this // function so it should be safe to invert the alpha mask here.
alpha.Invert();
Bitmap alphaBitmap(alpha.GetBitmap());
assert(dynamic_cast<SkiaSalBitmap*>(alphaBitmap.ImplGetSalBitmap().get()) != nullptr);
SkiaSalBitmap* skiaAlpha
= static_cast<SkiaSalBitmap*>(alphaBitmap.ImplGetSalBitmap().get()); #if0 // Drawing to a bitmap using a shader from a GPU-backed image fails silently. // https://bugs.chromium.org/p/skia/issues/detail?id=12685
paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut,
skiaBitmap->GetSkShader(SkSamplingOptions()),
skiaAlpha->GetAlphaSkShader(SkSamplingOptions()))); #else
sk_sp<SkImage> imB = skiaBitmap->GetSkImage()->makeNonTextureImage();
sk_sp<SkImage> imA = skiaAlpha->GetAlphaSkImage()->makeNonTextureImage();
paint.setShader(SkShaders::Blend(SkBlendMode::kDstOut, imB->makeShader(SkSamplingOptions()),
imA->makeShader(SkSamplingOptions()))); #endif
SkCanvas canvas(targetBitmap);
canvas.concat(matrix);
canvas.drawPaint(paint);
}
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.