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 ...
随机推荐
- linux 下 pip 安装教程
方法一: 下载文件 wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate 执行安装 python get-pip.py 这就 ...
- java多线程学习--java.util.concurrent (转载)
题记:util和concurrent 包是后续重点先看的和学习的模块 原文地址:http://www.cnblogs.com/sunhan/p/3817806.html CountDownLatch, ...
- Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)
Purpose This article provides steps for extending the root partition residing in a logical volume cr ...
- Ilist<object>转换成I<实体> 如何转换
ml = objects.Cast<menu>().ToList(); //需要 using System.Linq;
- Android面试之HashMap的实现原理
1.HashMap与HashTable的区别 HashMap允许key和value为null: HashMap是非同步的,线程不安全,也可以通过Collections.synchronizedMap( ...
- tomcat服务器配置字符集为utf-8-彻底解决中文乱码问题
<Connector port="8070" protocol="HTTP/1.1" connectionTimeout="20000" ...
- [转]JVM参数设置、分析
不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断,正确的选择不同的GC策略,调整JVM.GC的参数,可以极大的减少由于GC工作,而导致的程序运行中断方面的问题,进而适当的提高Java ...
- 在windows 上统计git 代码量
1 需要系统安装 git + gawk git 安装自行百度 gawk 到官网下载 http://gnuwin32.sourceforge.net/packages/gawk.htm 1.2 下载好后 ...
- 在springboot 和 mybatis 项目中想要显示sql 语句进行调试
在springBoot+Mybatis日志显示SQL的执行情况的最简单方法就是在properties新增: logging.level.com.dy.springboot.server.mapper= ...
- [LintCode] N-Queens
N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no tw ...