Save canvas from windows store app as image file

后端 未结 3 938
渐次进展
渐次进展 2021-01-14 07:19

I\'m looking for way to save canvas from windows store app, I have found:

private void CreateSaveBitmap(Canvas canvas, string filename)
     {
       Render         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 07:51

    I came across this reply and although it looked exactly what I was looking for it didn't work. Adding an error handler revealed:

    Value does not fall within the expected range.

    Finally I found that:

    (uint)canvas.Width, (uint)canvas.Height,
    

    were both 0. After replacing it with:

    (uint)canvas.ActualWidth, (uint)canvas.ActualHeight,
    

    it worked. No idea why it worked for Carlos28 and not for me, but with this change it worked for me too and so I thank Xyriod for the answer

提交回复
热议问题