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()(这个只是网上看的,没实测)
随机推荐
- webpack配置提取公共代码
公共代码提取功能是针对多入口文件的: 背景:在pageA.js和pageB.js中分别引用subPageA.js和subPageB.js webpack.config.js文件: var path = ...
- 在CentOS6.5上安装/启动PostgreSQL
CentOS install PostgreSQL yum install postgresql-server Start PostgreSQL service postgresql initdb # ...
- 玩转shell命令行
移动光标快捷键 ctrl+f 向前移动一个字符 ctrl+b 向后移动一个字符 ctrl+a 移动到当前行首home ctrl+e 移动到当前行尾end alt+f 向前移动一个单词 alt+b 向后 ...
- idea svn 使用问题
一开始死活提交不上 解决方式 : 勾上use command line client
- spring 过滤器
Spring的web包中中有很多过滤器,这些过滤器位于org.springframework.web.filter并且理所当然地实现了javax.servlet.Filter,不过实现的方式有以下几类 ...
- Linux nginx目录设置
上一节记录了nginx的安装,这里来试着修改下配置文件. #user nobody; worker_processes 1; #error_log logs/error.log; #error_log ...
- android App抓包工具的应用(转)
安装好 fiddler ,手头有一部Android 手机,同时 还要有无线网,手机和 电脑在同一个无线网络.这些条件具备,我们就可以 开始下面的步骤了. 正题 :Fiddler 主菜单 Tools - ...
- C语言 · 扶老奶奶过街
算法提高 扶老奶奶过街 时间限制:1.0s 内存限制:256.0MB 一共有5个红领巾,编号分别为A.B.C.D.E,老奶奶被他们其中一个扶过了马路. 五个红领巾各自说话: A :我 ...
- <[完整版]中国式价值投资>读书笔记
注重本金安全 股票价格的高级与股票的贵贱没有任何关系 同股同权的应该买便宜的 买未来有可能变得更大的优秀公司股票,只有他们的股价才有可能有持续向上的原动力 如果绝大多数投资者对股票高市盈率不是拒绝而是 ...
- 接口与virtual,override,new关键字
一,类继承接口 1,首先我们定义一个简单的ITeacher接口,并定义一个Professor类继承它. public interface ITeacher { void Print(); } publ ...