Convert SKSurface to a image of a specific size on different device sizes

I have a xamarin forms view where based on touch events i can alter the image etc...

    <StackLayout > 
        <skia:SKCanvasView x:Name="canvasView"
                           HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                           IgnorePixelScaling="True"// not sure if i need this??
                           Touch="OnTouch" />
        <Button Text="Generate Image" Clicked="CreateButton_Clicked"/>

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

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. Is this possible? And is this even the correct approach for generating accurate images of a specific size across different device sizes?


Sign In or Register to comment.