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 ...
随机推荐
- 技术的正宗与野路子 c#, AOP动态代理实现动态权限控制(一) 探索基于.NET下实现一句话木马之asmx篇 asp.net core 系列 9 环境(Development、Staging 、Production)
黄衫女子的武功似乎与周芷若乃是一路,飘忽灵动,变幻无方,但举手抬足之间却是正而不邪,如说周芷若形似鬼魅,那黄衫女子便是态拟神仙. 这段描写出自<倚天屠龙记>第三十八回. “九阴神抓”本是& ...
- numpy 切片
numpy 中的切片与数组中的切片类似. 数组 [ 起始:终止:步长, 起始:终止:步长, ... ] 所有的切片操作(无论是步长为+的正序,还是步长为 - 的逆序)都是开始位置包含,结束位置不包含( ...
- 获取资源文件 r.drawable中的图片转换为drawable、bitmap
1. Resources resources = mContext.getResources(); Drawable drawable = resources.getDrawable(R.drawab ...
- 12C的审计模式
1.Mixed Auditing Policy 混合审计模式支持新的审计引擎和老的审计引擎一起工作数据库升级后,已有的审计设置不会受到影响.但是官方建议迁移到统一审计模式.数据库创建后,默认是使用混合 ...
- 题目要求:将a,b两个数的值进行交换,并且不使用任何的中间变量。
a = a+b; b = a-b; a = a-b;
- springboot 中文文档
springboot 中文文档https://qbgbook.gitbooks.io/spring-boot-reference-guide-zh/content/
- VB通用数据库操作方法
1.VB通用数据操作方法. 2.通用数据库查询方法. 3.通用数据库操作方法. 'ERP查询数据库 Public Function YZQuery(sqls As String, msgstring ...
- Android app启动activity并调用onCreate()方法时都默默地干了什么?
Android app启动activity并调用onCreate() 方法时都默默地干了什么? 在AndroidManifest.xml文件中的<intent-filter>元素中有这 ...
- 收集一些有意思的ASCII程序注释(持续收集中,希望大家踊跃贡献)
/** * * created by Mr.Simple, Aug 21, 20141:51:40 PM. * Copyright (c) 2014, hehonghui@umeng.com Al ...
- RAID简介[zz]
RAID 0 是指磁盘分段(Disk Striping)技术其实现方法为将数据分段,同时写到多个磁盘上.其优点是磁盘可以实现并行的输入和输出,提高磁盘读写速度,但是这种技术无容错性能:RAID 1是指 ...