Save multiple images from local system to canvas

8 views
Skip to first unread message

Binumon George

unread,
Sep 22, 2022, 7:01:58 AM (2 days ago) Sep 22
to skia-discuss
Hi All,
       I want to attach image to SKBitmap from my local system. If i want to attcah more than what i want to do? I am trying to attach same attachmen more than one.
But its attaching to canvas only one. Below is my code. pls let me know where i am doing wrong?

 SkiaSharp.SKBitmap oBmp = new SKBitmap(100, 50 * 5);
           
            using (SKCanvas g = new SKCanvas(oBmp))
            {
                g.Clear(SKColor.Parse("#FF0000"));

                SKBitmap oImage = SKBitmap.Decode(File.OpenRead(@"C:\inetpub\wwwroot\cDevWorkflow\images\ftpgetfile.png"));

                SKRect oSrcRect = new SKRect(0, 0, oImage.Width, oImage.Height);

                var paint = new SKPaint { FilterQuality = SKFilterQuality.High };

                int x = 0;
                for (int i = 0; i < 5; i++)
                {
                    SKRect oDstRect = new SKRect(0, x, 40, 200);
                    g.DrawBitmap(oImage, oSrcRect, oDstRect, paint);
                    x += 50;
                }
                g.Save();

                using (SKData data = oBmp.Encode(SKEncodedImageFormat.Png, 200))
                using (var stream = File.OpenWrite(@"c:\temp\dwski-67.png"))
                {
                    // save the data to a stream
                    data.SaveTo(stream);
                }











Reply all
Reply to author
Forward
0 new messages