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. 【Linux】字符转换命令paste

    这个 paste 就要比join 简单多了!相对于 join 必须要比对两个文件的数据相关性, paste 就直接『将两行贴在一起,且中间以 [tab] 键隔开』而已!简单的使用方法: [root@w ...

  2. Percona XtraBackup介绍

    Percona XtraBackup开源的.免费的mysql热备软件,可以执行无阻塞备份InnoDB和XtraDB数据库. Percona XtraBackup有以下优点: ·备份快速.可靠 ·备份期 ...

  3. process credentials(一)

    一.介绍 当linux系统中的一个进程运行起来的时候,总是要访问系统的资源,访问文件或者向其他的进程发送信号.系统是否允许其进行这些操作?系统是根据什么来判断该进程的权限?这些问题是和进程信任状(pr ...

  4. WGAN (原理解析)

    在GAN的相关研究如火如荼甚至可以说是泛滥的今天,一篇新鲜出炉的arXiv论文<Wasserstein GAN>却在Reddit的Machine Learning频道火了,连Goodfel ...

  5. [转]一台电脑上的git同时使用两个github账户

    需求: 公司有github账号,自己有github账号,想在git上同时使用,两者互不干扰. 思路: 管理两个SHH key. 解决方案: 一.生成两个SSH key 为了举例方便,这里使用“one” ...

  6. 纯干货,Spring-data-jpa详解(转)

    本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...

  7. Django--middleware 详解

    面对的问题: 当我们的一个网站上线后有可能遇到一些恶意的访问.比如来自对手的web爬虫:我看过一些lowB的对手,它们IP地址都不换一个的,也不 在行为上做伪装. 1.可行方法一: 在每一个view中 ...

  8. mysql 主从同步遇到的问题(1032)

    event_scheduler对主从的影响: 1 对于已经存在的主从, 新建立events没有影响. 2 对于新建立的主从,如果有events ,那么需要在从库上把event_scheduler设置为 ...

  9. Tomcat7启动报Error listenerStart错误

    问题 Tomcat7在启动时报错,详细信息如下: 十一月 23, 2013 7:21:58 下午 org.apache.catalina.core.StandardContext startInter ...

  10. Android USB配件模式

    原文:http://android.eoe.cn/topic/android_sdk USB配件模式允许用户连接那些专门搭载Android设备的USB主机硬件.这些配件必须遵守Android配件开发工 ...