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方法的更多相关文章

  1. Bitmap转换成BitmapImage

    public BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap) { MemoryStream ms = new MemoryS ...

  2. GDI+ Bitmap与WPF BitmapImage的相互转换

    原文:GDI+ Bitmap与WPF BitmapImage的相互转换 using System.Windows.Interop; //... // Convert BitmapImage to Bi ...

  3. 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法

    在android sdk 1.6版本API帮助文档中,其中关于BitmapFactory.decodeFactory.decodeStream(InputStream is)的帮助文档是这么说明的: ...

  4. Android Bitmap OutOfMemory 解决的方法

    在Android应用里,最耗费内存的就是图片资源.并且在Android系统中.读取位图Bitmap时,分给虚拟机中的图片的堆栈大小仅仅有8M.假设超出了.就会出现OutOfMemory异常 E/And ...

  5. [Android Pro] 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法

    在android sdk 1.6版本API帮助文档中,其中关于BitmapFactory.decodeFactory.decodeStream(InputStream is)的帮助文档是这么说明的: ...

  6. 字符串转化为json方法

    1.function strToJson(str){ var json = eval('(' + str + ')'); return json; } 不过eval解析json有安全隐患! 现在大多数 ...

  7. Json序列化为对象方法

    /// <summary>/// json 序列化为对象/// </summary>/// <typeparam name="T">对象类型&l ...

  8. string转化为int方法

    int intA = 0; 1.intA =int.Parse(str); 2.int.TryParse(str, out intA); 3.intA = Convert.ToInt32(str);以 ...

  9. Python dict转化为string方法

    dict-->string: str() string-->dict eval()(这个只是网上看的,没实测)

随机推荐

  1. Windows 安装 setuptools 和 feedparser

    一.安装setuptools: 页面: https://pypi.python.org/pypi/setuptools#downloads 1.下载该zip文件,解压,例如:C:\setuptools ...

  2. spring util list

    spring 3.0 after <util:list/>元素 借助<list/>元素,开发者能够定义java.util.List集合.下面摘录了list.xml中的配置信息. ...

  3. stm32keilIDE遇到的bug

    最进项目中遇到keil中使用sscanf时,采取类正则表达 %*[^/]/%[^@]时不能正确得到的结果,同样的代码在gcc中运行通过.然后又遇到stm32 keil编译器printf带多个参数就卡死 ...

  4. python rabittmq 使用

    Reference: https://www.rabbitmq.com/tutorials/tutorial-three-python.html 1 "Hello World!" ...

  5. 07Vue.js快速入门-Vue路由详解

    对于前端来说,其实浏览器配合超级连接就很好的实现了路由功能.但是对于单页面应用来说,浏览器和超级连接的跳转方式已经不能适用, 所以各大框架纷纷给出了单页面应用的解决路由跳转的方案. Vue框架的兼容性 ...

  6. Vmware 注册服务 开机自启

    现在的服务器性能往往过剩,利用虚拟机可以提高服务器的利用效率.VMware是一款很好的虚拟机软件,但是其WorkSation版本并不支持开机自动启动,支持开机自启的Server又长年没有更新,已经无法 ...

  7. postgre与mysql区别

    SQL兼容性 PostgreSQL 9.5 兼容 SQL:2011 子集 http://www.postgresql.org/docs/9.5/static/features-sql-standard ...

  8. mybatis拦截器实现分页功能的示例讲解

    import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import jav ...

  9. 中断描述符表(Interrupt Descriptor Table,IDT)

    中断描述符表(Interrupt Descriptor Table,IDT)将每个异常或中断向量分别与它们的处理过程联系起来.与GDT和LDT表类似,IDT也是由8字节长描述符组成的一个数组. #pr ...

  10. Drupal 7 配置ckeditor和ckfinder编辑器实现图片上传--不用wysisyg

    注意: 1.这里的ckeditor编辑器是独立模块,不是那个wysiwyg模块. 2.这里的图片上传仅仅为文章内图片,非字段图片.   1.下载文件(1) http://drupal.org/proj ...