WP8 中常用的 WriteableBitmap和BitmapImage相互转换
2014-09-14 16:21
621 查看
一、WriteableBitmap转为BitmapImage对象
var bi= new BitmapImage();
bi.SetSource(wb.ToImage().ToStream()); //其中wb是WriteableBitmap对象。
二、BitmapImage转为WriteableBitmap对象
三、将WriteableBitmap转为字节数组
四、将字节数组转为BitmapImage对象
MemoryStream ms = new MemoryStream(b); // b为byte[]
BitmapImage bi = new BitmapImage();
bi.SetSource(ms);
img.Source = bi; //这里img为XAML的Image对象
var bi= new BitmapImage();
bi.SetSource(wb.ToImage().ToStream()); //其中wb是WriteableBitmap对象。
二、BitmapImage转为WriteableBitmap对象
//这里就转换完成了 WriteableBitmap wb = new WriteableBitmap(bi.Source as BitmapSource);
三、将WriteableBitmap转为字节数组
byte[] b = Convert.FromBase64String(GetBase64Image(wb)); //这里通过base64间接处理,效率不是很高。
四、将字节数组转为BitmapImage对象
MemoryStream ms = new MemoryStream(b); // b为byte[]
BitmapImage bi = new BitmapImage();
bi.SetSource(ms);
img.Source = bi; //这里img为XAML的Image对象
相关文章推荐
- 有关WriteableBitmap和BitmapImage之间的相互转换
- 【WPF】WriteableBitmap和BitmapImage的相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- WPF中bitmapimage与byte[]格式相互转换
- bitmapimage与byte[]相互转换 --转
- Byte[]、Image、Bitmap 之间的相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换
- BitmapImage与byte[]相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- WPF Image控件 Source: Byte[] ,BitmapImage 相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- Byte[]、Image、Bitmap 之间的相互转换(转)
- Byte[]、Image、Bitmap 之间的相互转换
- 关于win8 metro 中BitmapImage类型转换为WriteableBitmap类型。
- [C#] Byte[]、Image、Bitmap 之间的相互转换
- Byte[]、Image、Bitmap 之间的相互转换
- c# Byte[]、Image、Bitmap 之间的相互转换