我怎么能转换为WriteableBitmap的BitmapImage的? [英] How can I convert WriteableBitmap to BitmapImage?

查看:562
本文介绍了我怎么能转换为WriteableBitmap的BitmapImage的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 的BitmapImage BitmapImage的=新的BitmapImage(新的URI(arka_projects_as_logo.png,UriKind.Relative)); 
图像的UIElement =新的图像(){源=的BitmapImage};
ScaleTransform T =新ScaleTransform(){的ScaleX = 0.2,的scaleY = 0.2};
WriteableBitmap的WriteableBitmap的=新WriteableBitmap的(的UIElement,T);



我要插入此转换(WriteableBitmap的)的结果为System.Windows.Controls.Image。当我这样做:

 图像arkaImage =新的图像(){源= WriteableBitmap的}; 



arkaImage 没有显示在所有。有什么可以做,使工作?


解决方案

  WriteableBitmap的WB = .. 
使用(MemoryStream的毫秒=新的MemoryStream())
{
wb.SaveJpeg(毫秒,(INT)image1.Width,(INT)image1.Height,0,100);
的BitmapImage BMP =新的BitmapImage();
bmp.SetSource(毫秒);
}


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

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

这篇关于我怎么能转换为WriteableBitmap的BitmapImage的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆