WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换
1 WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换
2012-12-18 17:27:04| 分类: Windows Phone 8|字号 订阅
,WriteableBitmap与BitmapImage转换
1.1 BitmapImage to WriteableBitmap
BitmapImage bitmapImage=new BitmapImage(new Uri(“http://...”,UriKind.Revelate));
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
1.2 WriteableBitmap to BitmapImage
MemoryStream stream = new MemoryStream();
writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth,
writeableBitmap.PixelHeight,0,100);
BitmapImage temp = new BitmapImage();
temp.SetSource(stream);
,WriteableBitmap/BitmapImage to byte[]
2.1 WriteableBitmap to byte[]
MemoryStream stream = new MemoryStream();
writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth,
writeableBitmap.PixelHeight,0,100);
byte[]rgbBytes = stream.ToArray();
2.2 byte[] to WriteableBitmap
byte[]rgbBytes;
MemoryStream stream = new MemoryStream(rgbBytes);
WriteableBitmap writeableBitmap = new WriteableBitmap(width,height);
writeableBitmap.LoadJpeg(stream);
2.3 BitmapImage to byte[]
BitmapImage bitmapImage=new BitmapImage(new Uri(“http://...”,UriKind.Revelate));
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
MemoryStream stream = new MemoryStream();
writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth,
writeableBitmap.PixelHeight,0,100);
byte[]rgbBytes = stream.ToArray();
2.4 byte[] to BitmapImage
byte[]rgbBytes;
MemoryStream stream = new MemoryStream(rgbBytes);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);
,WriteableBitmap/BitmapImage to stream
3.1 WriteableBitmap to stream
MemoryStream stream = new MemoryStream();
writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth,
writeableBitmap.PixelHeight,0,100);
3.2 MemoryStream to WriteableBitmap
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(memoryStream);
WriteableBitmap writeableBitmap = new WriteableBitmap (bitmapImage);
3.3 BitmapImage to MemoryStream
BitmapImage bitmapImage;
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
MemoryStream stream = new MemoryStream();
writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight,0,100);
3.4 MemoryStream to BitmapImage
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);
WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换的更多相关文章
- Silverlight中将WriteableBitmap互转byte数组
//WriteableBitmap to ARGB ; , result, , len); , bmp.Pixels, , buffer.Length); }
- dword word byte 相互转换 .xml
pre{ line-height:1; color:#800080; background-color:#d2c39b; font-size:16px;}.sysFunc{color:#627cf6; ...
- C#中string和byte[]相互转换问题解决
本来想讲string转换为byte数组,通过在VS上打 ‘str. “来找,结果半天没发现跳出来的函数中有想要的,哭瞎 /(ㄒoㄒ)/~~ 这回将两种情况都记下来了.... string ---> ...
- java 中 image 和 byte[] 相互转换
java 中 image 和 byte[] 相互转换可恶的…………其实也挺好的 只是把好不容易写出来的东西记下来,怕忘了…… 下面,我来介绍一个简单的 byte[] to image, 我们只需要 ...
- [uwp]ImageSource和byte[]相互转换
最近做一个小app遇到一个问题,到目前还没有比较好的解决方法(可能是我查的资料不够多) 需求如下: 1.把一个Image中的图像保存到字节数组: 2.把字节数组转换为ImageSource,通过Ima ...
- C#图像处理:Stream 与 byte[] 相互转换,byte[]与string,Stream 与 File 相互转换等
C# Stream 和 byte[] 之间的转换 一. 二进制转换成图片 MemoryStream ms = new MemoryStream(bytes); ms.Position = 0; Ima ...
- C# 文件、byte相互转换
文件转byte数组: /// <summary> /// 将文件转换为byte数组 /// </summary> /// <param name="path&q ...
- 图片与byte相互转换
一.图片转byte public byte[] ImageToByte() { string imagefile = @"http://192.168.0.212/pass/T-1.jpg& ...
- String 与 byte[]相互转换
1. 从byte[]转换成string string result = System.Text.Encoding.UTF8.GetString(byteArray); 2.从string 转换成byt ...
随机推荐
- Fastjson是一个Java语言编写的高性能功能完善的JSON库。
简介 Fastjson是一个Java语言编写的高性能功能完善的JSON库. 高性能 fastjson采用独创的算法,将parse的速度提升到极致,超过所有json库,包括曾经号称最快的jackson. ...
- Fiddler高级用法-抓取手机app数据包
在上一篇中介绍了Fiddler的基本使用方法.通过上一篇的操作我们可以直接抓取浏览器的数据包.但在APP测试中,我们需要抓取手机APP上的数据包,应该怎么操作呢? Andriod配置方法 1)确保手机 ...
- [转]SpringMVC中使用Interceptor拦截器
SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那 ...
- python标准库介绍——31 threading 模块详解
threading 模块 (可选) ``threading`` 模块为线程提供了一个高级接口, 如 [Example 3-1 #eg-3-1] 所示. 它源自 Java 的线程实现. 和低级的 ``t ...
- jmeter maven自动移动jar包windows 批处理命令
jmeter项目maven文件下面放这.bat 工具,可以把必要的jar包移动到jmeter响应的文件夹下面 rem 本文件放在jmeter 脚本maven项目根目录下面,和pom.xml在同一个文件 ...
- highlightjs 详解
起源: 最近想做一个代码高亮的功能.发现开源社区已经有了这类的项目.比如说highlightjs. 第一步:下载highlightjs 官网:https://highlightjs.org 可以看到它 ...
- kibana显示报错
"status": 500, "reason": "ElasticsearchException[org.elasticsear ...
- ELK 的插件安装(head)
这里我装了一个head插件和kopf的插件 ./plugin install mobz/elasticsearch-head ./plugin install lmenezes/elasticsear ...
- Vue(一):简介和安装
概况 Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的渐进式框架. Vue 只关注视图层, 采用自底向上增量开发的设计. Vue 的目标是通过尽可能简单的 API 实现响应 ...
- 负载均衡层次结构:LVS Nginx DNS CDN
文章地址:http://blog.csdn.net/mindfloating/article/details/51020767 作为后端应用的开发者,我们经常开发.调试.测试完我们的应用并发布到生产环 ...