BitmapImage bitmapImage = new BitmapImage(new Uri("arka_projects_as_logo.png", UriKind.Relative));
Image uiElement = new Image() { Source = bitmapImage };
ScaleTransform t = new ScaleTransform() { ScaleX = 0.2, ScaleY = 0.2 };
WriteableBitmap writeableBitmap = new WriteableBitmap(uiElement,t);
我想将此转换的结果(writeableBitmap)插入到System.Windows.Controls.Image中。当我这样做时:
Image arkaImage = new Image() { Source = writeableBitmap };
arkaImage
根本没有显示。有什么办法可以让它发挥作用?
答案 0 :(得分:11)
WriteableBitmap wb = ..
using (MemoryStream ms = new MemoryStream())
{
wb.SaveJpeg(ms, (int)image1.Width, (int)image1.Height, 0, 100);
BitmapImage bmp = new BitmapImage();
bmp.SetSource(ms);
}
答案 1 :(得分:2)
为什么不将ScaleTransform
同时应用于UIElement
?