如何在inkcanvas之外显示图像

发布于 2024-10-11 22:52:20 字数 1440 浏览 3 评论 0原文

我有一个名为“drawCanvas”的画布,用于显示名为“CanvasContainInkCanvas”的画布中包含的图像和 inkcanvas。我可以使用 MatrixTransform 进行缩小。

//Get the image that's being manipulation.
Canvas element = (Canvas)e.Source;
 //Ues the matrix of the transform to manipulation the element's appearance.
Matrix matrix = ((MatrixTransform)drawCanvas.RenderTransform).Matrix;
//Get the ManipulationDelta object.
ManipulationDelta deltaManipulation = e.DeltaManipulation;
//Find the old center, and apply any previous manipulations.
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
//Apply new move manipulation (if it exists).
center = matrix.Transform(center);
 //Apply new zoom manipulation (if it exists).
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
//Translation (pan) 
matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
//Set the final matrix.
((MatrixTransform)drawCanvas.RenderTransform).Matrix = matrix;
// set the matrix of canvas that contain inkcanvas
((MatrixTransform)CanvasContainInkCanvas.RenderTransform).Matrix = matrix;

如果缩小,我可以看到画布外的图像。 alt text

我想将图像从画布复制到 inkcanvas 以使用选择。 我的问题是图像无法在 inkcanvas 之外显示。

alt text

如何在 inkcanvas 之外显示图像?

谢谢

更新:我如何在 inkcanvas 之外使用选择?

I have canvas called "drawCanvas" to show images and inkcanvas that is contained in the canvas called "CanvasContainInkCanvas". I can zoom out by using MatrixTransform.

//Get the image that's being manipulation.
Canvas element = (Canvas)e.Source;
 //Ues the matrix of the transform to manipulation the element's appearance.
Matrix matrix = ((MatrixTransform)drawCanvas.RenderTransform).Matrix;
//Get the ManipulationDelta object.
ManipulationDelta deltaManipulation = e.DeltaManipulation;
//Find the old center, and apply any previous manipulations.
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
//Apply new move manipulation (if it exists).
center = matrix.Transform(center);
 //Apply new zoom manipulation (if it exists).
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
//Translation (pan) 
matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
//Set the final matrix.
((MatrixTransform)drawCanvas.RenderTransform).Matrix = matrix;
// set the matrix of canvas that contain inkcanvas
((MatrixTransform)CanvasContainInkCanvas.RenderTransform).Matrix = matrix;

If I zoom out, I can see images outside canvas.
alt text

I want to copy images from canvas to inkcanvas to use selection.
My problem is that the images cannot be shown outside inkcanvas.

alt text

How do I show images outside inkcanvas?

Thanks

Update: How do I use selection outside inkcanvas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征﹌骨岁月お 2024-10-18 22:52:20

在该 InkCanvas 上设置 ClipToBounds="False"。默认情况下,它设置为True

Set ClipToBounds="False" on that InkCanvas. By default it's set to True.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文