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[]相互转换的更多相关文章

  1. Silverlight中将WriteableBitmap互转byte数组

    //WriteableBitmap to ARGB ;    , result, , len);    , bmp.Pixels, , buffer.Length); }

  2. dword word byte 相互转换 .xml

    pre{ line-height:1; color:#800080; background-color:#d2c39b; font-size:16px;}.sysFunc{color:#627cf6; ...

  3. C#中string和byte[]相互转换问题解决

    本来想讲string转换为byte数组,通过在VS上打 ‘str. “来找,结果半天没发现跳出来的函数中有想要的,哭瞎 /(ㄒoㄒ)/~~ 这回将两种情况都记下来了.... string ---> ...

  4. java 中 image 和 byte[] 相互转换

      java 中 image 和 byte[] 相互转换可恶的…………其实也挺好的 只是把好不容易写出来的东西记下来,怕忘了…… 下面,我来介绍一个简单的 byte[] to image, 我们只需要 ...

  5. [uwp]ImageSource和byte[]相互转换

    最近做一个小app遇到一个问题,到目前还没有比较好的解决方法(可能是我查的资料不够多) 需求如下: 1.把一个Image中的图像保存到字节数组: 2.把字节数组转换为ImageSource,通过Ima ...

  6. C#图像处理:Stream 与 byte[] 相互转换,byte[]与string,Stream 与 File 相互转换等

    C# Stream 和 byte[] 之间的转换 一. 二进制转换成图片 MemoryStream ms = new MemoryStream(bytes); ms.Position = 0; Ima ...

  7. C# 文件、byte相互转换

    文件转byte数组: /// <summary> /// 将文件转换为byte数组 /// </summary> /// <param name="path&q ...

  8. 图片与byte相互转换

    一.图片转byte public byte[] ImageToByte() { string imagefile = @"http://192.168.0.212/pass/T-1.jpg& ...

  9. String 与 byte[]相互转换

    1. 从byte[]转换成string string result = System.Text.Encoding.UTF8.GetString(byteArray); 2.从string 转换成byt ...

随机推荐

  1. 【Java】解析Java对XML的操作

    目录结构: contents structure [+] 什么是XML 解析XML 使用DOM解析 使用SAX解析 使用PULL解析 使用dom4j解析xml dom4j的部分API 打印一个XML文 ...

  2. Git 配置(分布式版本控制系统)

    1.Mac Git 配置文件 既然已经在系统上安装了 Git,你会想要做几件事来定制你的 Git 环境.每台计算机上只需要配置一次,程序升级时会保留配置信息.你可以在任何时候再次通过运行命令来修改它们 ...

  3. 【struts2】值栈(前篇)

    1 值栈是什么? 简单的说:值栈是对应每一个请求对象的轻量级的内存数据中心. Struts2中一个很激动人心的特性就是引入了值栈,在这里统一管理着数据,供Action.Result.Intercept ...

  4. numpy.linspace()等差数列函数

    在numpy中的linspace()函数类似与arange().range()函数: arange() .range() 可以通过指定开始值.终值和步长创建一维等差数组,但其数组中不包含终值 通过   ...

  5. 《JAVA与模式》之单例模式(转载)

    原文地址:http://blog.csdn.net/jason0539/article/details/23297037 概念: java中单例模式是一种常见的设计模式,单例模式分三种:懒汉式单例.饿 ...

  6. RecyclerView的滚动事件OnScrollListener研究

      (1)滚动事件分类 列表的滚动一般分为两种: 1.手指按下 -> 手指拖拽列表移动 -> 手指停止拖拽 -> 抬起手指 2.手指按下 -> 手指快速拖拽后抬起手指 -> ...

  7. 还没被玩坏的robobrowser(3)——简单的spider

    背景 做一个简单的spider用来获取python selenium实战教程的一些基本信息.因为python selenium每年滚动开课,所以做这样一个爬虫随时更新最新的开课信息是很有必要的. 预备 ...

  8. nginx根据http_user_agent防DDOS

    前端squid反向代理到nginx nginx根据http_user_agent防DDOS 首先查看访问日志,找出可疑访问 找到http_user_agent 的特征,然后再作过滤 "Moz ...

  9. (面试题)两个对象值相同 (x.equals(y) == true) ,但却可有不同的 hash code ,这 句话对不对

    答:不对,有相同的 hash code这是java语言的定义:1) 对象相等则hashCode一定相等:2) hashCode相等对象未必相等 1.如果是基本变量,没有hashcode和equals方 ...

  10. SqlExcel使用文档及源码

    昨天帮朋友做了个小工具,以完成多表连接处理一些数据.今天下班后又做了份使用文档,不知友能看懂否?现将使用文档及源码发布如下,以供有同样需求的朋友下载. 使用文档 一.增.改.查.删 1.增(向shee ...