我有一个 Xamarin 表单视图,我可以根据触摸事件更改图像
<StackLayout >
<skia:SKCanvasView x:Name="canvasView"
PaintSurface="ImageCanvas_PaintSurface"
EnableTouchEvents="True"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
IgnorePixelScaling="True"// not sure if i need this??
Touch="OnTouch" />
<Button Text="Generate Image" Clicked="CreateButton_Clicked"/>
</StackLayout>
我需要根据在表面上绘制的内容生成正好 1060 x 550 的图像
void ImageCanvas_PaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
var surface = args.Surface;
var canvas = surface.Canvas;
/// paint bitmaps/text on canvas etc
// Save the image to local storage
ViewModel.SaveImage(surface.Snapshot());
}
据我所知,如果我可以将从 surface.Snapshot() 返回的 SKImage 转换为 SKBitmap,我可以使用 Resize() 函数。我该怎么做呢?
谢谢!