4
我创建的图像与此代码应用放大/缩小到原产地形象WPF
OpenFileDialog dlg = new OpenFileDialog();
dlg.FileName = ""; // Default file name
myImage = new Image();
try
{
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string sUri = @dlg.FileName;
Uri src = new Uri(sUri, UriKind.RelativeOrAbsolute);
BitmapImage bmp = new BitmapImage(src);
myImage.Source = bmp;
myImage.Width = 100;
myImage.Height = 100;
}
}
我可以放大/缩小这个图像
public void Scale(int i, Point center)
{
Matrix m = myImage.RenderTransform.Value;
if (i > 0)
m.ScaleAtPrepend(1.1, 1.1, center.X, center.Y);
else
m.ScaleAtPrepend(1/1.1, 1/1.1, center.X, center.Y);
myImage.RenderTransform = new MatrixTransform(m);
}
上,但是当我拿到ActualWidth的或Width或ActualHeight/Height返回数字100.这意味着这些更改不适用于原始图像(myImage)。 现在如何将更改(缩放或任何更改)应用于原始图像?
Tanx all;