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. 【Oracle】详解Oracle中NLS_LANG变量的使用

    目录结构: contents structure [+] 关于NLS_LANG参数 NSL_LANG常用的值 在MS-DOS模式和Batch模式中设置NLS_LANG 注册表中NLS_LANG和系统环 ...

  2. 1 时间戳 2 C# 如何生成一个时间戳 3 js 时间加一分钟... 4 js string->date 5 js 取得当天0点 / 23:59:59 时间

    var str = 'Jan 23, 2019 10:25:47 AM';var strnow = new Date(str); 时间戳(timestamp),一个能表示一份数据在某个特定时间之前已经 ...

  3. 【转】TeXmacs:一个真正“所见即所得”的排版系统

    TeXmacs:一个真正“所见即所得”的排版系统 好久没有推荐过自己喜欢的软件了,现在推荐一款我在美国做数学作业的私家法宝:TeXmacs.我恐怕不可能跟以前那么有闲心写个长篇的 TeXmacs 说明 ...

  4. SpringBoot多跨域请求的支持(JSONP)

    在我们做项目的过程中,有可能会遇到跨域请求,所以需要我们自己组装支持跨域请求的JSONP数据,而在4.1版本以后的SpringMVC中,为我们提供了一个AbstractJsonpResponseBod ...

  5. Sql 查询当天、本周、本月记录

    --查询当天: select * from info where DateDiff(dd,datetime,getdate())=0 --查询24小时内的: select * from info wh ...

  6. 搭建MVC及WEB API项目框架时碰到的问题集合

    前言 刚开始创建MVC与Web API的混合项目时,碰到好多问题,今天拿出来跟大家一起分享下.有朋友私信我问项目的分层及文件夹结构在我的第一篇博客中没说清楚,那么接下来我就准备从这些文件怎么分文件夹说 ...

  7. spring中InitializingBean接口使用理解(转)

    InitializingBean接口为bean提供了初始化方法的方式,它只包括afterPropertiesSet方法,凡是继承该接口的类,在初始化bean的时候会执行该方法. 测试程序如下: imp ...

  8. debian linux 下设置开机自启动

    懒得写了,一张图简单明了.其实很简单,一开始没有加上nohup有点问题.现在问题已解决.

  9. 怎么部署 .NET Core Web项目 到linux

    .NET Core is free, open source, cross platform and runs basically everywhere. STEP 0 - GET A CHEAP H ...

  10. 服务器保存所有用户的操作指令(history)

    参考地址:https://helpcdn.aliyun.com/knowledge_detail/41210.html #!/bin/bash LOGIP=`who -u am i 2>/dev ...