如何在inkcanvas外面显示图像

时间:2011-01-13 08:39:49

标签: c# wpf inkcanvas

我有一个名为“drawCanvas”的画布来显示画布中包含的名为“CanvasContainInkCanvas”的图像和墨迹。我可以使用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以使用选择。 我的问题是图像无法在墨迹外显示。

alt text

如何在inkcanvas外显示图像?

由于

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

1 个答案:

答案 0 :(得分:2)

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