开发者

How can I convert WriteableBitmap to BitmapImage?

开发者 https://www.devze.com 2023-01-21 20:46 出处:网络
BitmapImage bitmapImage = new BitmapImage(new Uri(\"arka_projects_as_logo.png\", UriKind.Relative)); Image uiElement = new Image() { Source = bitmapImage };
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 = ne开发者_StackOverflow社区w WriteableBitmap(uiElement,t);

I want to insert the result of this conversions (writeableBitmap) into System.Windows.Controls.Image. When I do this:

Image arkaImage = new Image() { Source = writeableBitmap };

arkaImage isn't shown at all. What can be done to make it work?


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);
}


Why don't you just apply the ScaleTransform to the UIElement as well?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号