C# Bitmap转化为BitmapImage方法
public BitmapImage BitmapToBitmapImage(Bitmap bitmap)
{
Bitmap bitmapSource = new Bitmap(bitmap.Width,bitmap.Height);
int i,j;
for(i=;i<bitmap.Width;i++)
for (j = ; j < bitmap.Height; j++)
{
Color pixelColor = bitmap.GetPixel(i, j);
Color newColor = Color.FromArgb(pixelColor.R, pixelColor.G, pixelColor.B);
bitmapSource.SetPixel(i, j, newColor);
}
MemoryStream ms = new MemoryStream();
bitmapSource.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = new MemoryStream(ms.ToArray());
bitmapImage.EndInit(); return bitmapImage;
}
Video.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.looooog.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
C# Bitmap转化为BitmapImage方法的更多相关文章
- Bitmap转换成BitmapImage
public BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap) { MemoryStream ms = new MemoryS ...
- GDI+ Bitmap与WPF BitmapImage的相互转换
原文:GDI+ Bitmap与WPF BitmapImage的相互转换 using System.Windows.Interop; //... // Convert BitmapImage to Bi ...
- 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法
在android sdk 1.6版本API帮助文档中,其中关于BitmapFactory.decodeFactory.decodeStream(InputStream is)的帮助文档是这么说明的: ...
- Android Bitmap OutOfMemory 解决的方法
在Android应用里,最耗费内存的就是图片资源.并且在Android系统中.读取位图Bitmap时,分给虚拟机中的图片的堆栈大小仅仅有8M.假设超出了.就会出现OutOfMemory异常 E/And ...
- [Android Pro] 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法
在android sdk 1.6版本API帮助文档中,其中关于BitmapFactory.decodeFactory.decodeStream(InputStream is)的帮助文档是这么说明的: ...
- 字符串转化为json方法
1.function strToJson(str){ var json = eval('(' + str + ')'); return json; } 不过eval解析json有安全隐患! 现在大多数 ...
- Json序列化为对象方法
/// <summary>/// json 序列化为对象/// </summary>/// <typeparam name="T">对象类型&l ...
- string转化为int方法
int intA = 0; 1.intA =int.Parse(str); 2.int.TryParse(str, out intA); 3.intA = Convert.ToInt32(str);以 ...
- Python dict转化为string方法
dict-->string: str() string-->dict eval()(这个只是网上看的,没实测)
随机推荐
- Python版求数组的最大连续区间
[本文出自天外归云的博客园] 题目:有一个数组,求他的最大(最长)连续区间(数字是连续的区间). 我的解法,如下: class Finder(object): ''' 判断两个相邻的数字是否连续,若连 ...
- fzu2158
http://acm.fzu.edu.cn/problem.php?pid=2158 在密室逃脱游戏中,大家被困在一个密室中,为了逃出密室,需要找到正确的数字密码,于是大家分头行动,分别找到了密码的子 ...
- Kafka vs RocketMQ——单机系统可靠性
引言 前几期的评测中,我们对比了Kafka和RocketMQ的吞吐量和稳定性,本期我们要引入一个新的评测标准——软件可靠性. 何为“可靠性”? 先看下面这种情况:有A,B两辆越野汽车,在城市的周边地区 ...
- git学习(五):git diff魔法
不同参数下git diff输出并不相同,理解了工作区,暂存区和版本库的关系之后就很容易理解diff了. 工作区.暂存区和版本库的目录树浏览 清除工作区中未被git管理的文件 git clean -fd ...
- C语言 · x的x次幂结果为10
如果x的x次幂结果为10(参见[图1.png]),你能计算出x的近似值吗? 显然,这个值是介于2和3之间的一个数字. 请把x的值计算到小数后6位(四舍五入),并填写这个小数值. 注意:只填写一个小数, ...
- Linux 系统位数以及 Linux 软件位数查看
一. Linux系统位数查看: getconf LONG_BIT uname -a 二. 软件位数查看: file ....txt  与 Linker 的 OutputFile 属性(,,,)不匹配. ...
- redis主从配置(docker实现)
一.docker新建两个redis服务端,并分别设置端口为6379和6380 命令如下: docker run -p : -d --name redis-server docker.io/redis: ...
- MySQL 入门教程
目录 一.MySQL的相关概念介绍 二.Windows下MySQL的配置 配置步骤 MySQL服务的启动.停止与卸载 三.MySQL脚本的基本组成 四.MySQL中的数据类型 五.使用MySQL数据库 ...
- CSS(三):引入样式和优先级
CSS的引入样式总共有三种:行内样式(内联样式表).内部样式表.外部样式表.下面分别来介绍这三种样式. 一.行内样式 行内样式也叫内联样式,使用style属性引入CSS样式.看下面的示例: <! ...