Open philipag opened 1 year ago
SkiaBitmapExportContext is part of maui graphics so the bug is there.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
This has been outstanding for some time now, is there any hope that it will be resolved? Alternatively, has anyone found a workaround?
Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0. Can repro on android with sample project. skiaBug.zip
The cause of this issue is that code in SkiaCanvas.DrawImage
used by MySkiaBitmapExportContext
,
which tries to convert the IImage
into a SkiaImage
.
But most of the time IImage
is a PlatformImage
, not a SkiaImage
.
The above conversion results becomes null
, and the whole call is a noop.
A simple fix would be to replace the cast by SkiaImage
into a cast by PlatformImage
.
A temporary workaround:
#if ANDROID
using SkiaSharp.Views.Android;
#elif IOS
using SkiaSharp.Views.iOS;
#endif
if (image is not SkiaImage && image is PlatformImage platformImage)
{
var platformRepresentation = platformImage.PlatformRepresentation;
var newImage = new SkiaImage(SKBitmap.FromImage(platformRepresentation.ToSKImage()));
image.Dispose();
image = newImage;
}
Description
When using SKCanvasView, one can use canvas.DrawImage and image is displayed. However, when using SkiaBitmapExportContext.Canvas.DrawImage, nothing is rendered into the canvas.
Please see the attached sample for details. It saves the file badOutputWithoutImage.png which should contain the Android robot image but does not. It only shows the white background which was rendered into the canvas.
skiaBug.zip
Steps to Reproduce
Link to public reproduction project repository
attached
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 12
Did you find any workaround?
no
Relevant log output
No response