Saving a WPF canvas as an image

前端 未结 4 545
天命终不由人
天命终不由人 2020-12-16 00:34

I was following this article and I got my canvas to be saved, however, I want to extend the code\'s functionality and save a particular part of my canvas as an image, rather

4条回答
  •  庸人自扰
    2020-12-16 01:35

    See if this solution works for you.

    Size size = new Size(width, height);
    canvas.Measure(size);
    canvas.Arrange(new Rect(X, Y, width, height));
    
    //Save Image
    ...  
    ...
    
    // Revert old position
    canvas.Measure(new Size());
    

提交回复
热议问题