Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

About skiasharp scale

$
0
0

I have a question about skiasharp's scale, but what does "canvas.Scale(2);" double?

For example, if the whole is 256x256, does "canvas.Scale(2);" result in 512x512?

Also, I don't clearly understand the difference between SKCanvasView and SKCanvas.

List<SKBitmap> bitmaps = new List<SKBitmap>();
private async void Pic()
{

    for (int i = 1; i <= 10; i++)
    {
        string url = "";

        url = "https://c.tile.openstreetmap.org/" + 18 + "/" + (233891 + i) + "/" + 100481 + ".png";


        try
        {
            var httpClient = new HttpClient();
            using (Stream stream = await httpClient.GetStreamAsync(url))
            using (MemoryStream memStream = new MemoryStream())
            {
                await stream.CopyToAsync(memStream);
                memStream.Seek(0, SeekOrigin.Begin);
                //helloBitmap = SKBitmap.Decode(memStream);
                bitmaps.Add(SKBitmap.Decode(memStream));
            }
        }
        catch(Exception e)
        {
        }
    }

    SKCanvasView canvasView = new SKCanvasView();
    canvasView.PaintSurface += OnCanvasViewPaintSurface;
    Content = new ScrollView { Content = canvasView, Orientation = ScrollOrientation.Horizontal };
}

private void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{

    SKImageInfo info = args.Info;
    SKSurface surface = args.Surface;
    SKCanvas canvas = surface.Canvas;

    canvas.Scale(2);

    using (surface = SKSurface.Create(new SKImageInfo(1000, 1000)))
    {
        for (int i = 0; i < bitmaps.Count; i++)
        {
            canvas.DrawBitmap(bitmaps[i], 256 * i, 0, null);
        }
    }
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>