I have a Xamarin forms view where based on touch events i can alter the image
<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>
I need to generate a image of exactly 1060 x 550 based on what is drawn on the surface
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());
}
As far i can see If i could convert the SKImage which is returned from the surface.Snapshot() into a SKBitmap, I could use the Resize() function. How do i do this?
Thanks!
You can take picture and save it as SKImage in device folder after that you get it as stream and resize it and re-save it again
You can ameliorate and optimize the code more as your needs.