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. WebSocket通信协议 API简介

    WebSocket是html5新增加的一种通信协议,目前流行的浏览器都支持这个协议,例如 Chrome,Safari,Firefox,Opera,IE等等,对该协议支持最早的应该是chrome,从ch ...

  2. Lintcode: First Bad Version 解题报告

    First Bad Version http://lintcode.com/en/problem/first-bad-version The code base version is an integ ...

  3. python版本坑:md5例子(python2与python3中md5区别)

    对于一些字符,python2和python3的md5加密出来是不一样的. Python2 和Python3MD5加密 # python2.7 pwd = "xxx" + chr(1 ...

  4. Django 批量保存图片文件 自定义上传方法

    1.前端通过formData的方式批量增加图片或文件 for (var i = 0; i < form_img_list.length; i++) { formData.append('imag ...

  5. JAVA-JSP内置对象

    相关资料:<21天学通Java Web开发> request 请求对象 类型javax.servlet.ServletRequest 作用域Requestresponse 响应对象 类型j ...

  6. Eigen教程(7)

    整理下Eigen库的教程,参考:http://eigen.tuxfamily.org/dox/index.html 归约.迭代器和广播 归约 在Eigen中,有些函数可以统计matrix/array的 ...

  7. C++连接Mysql数据库操作

    参考文章 http://www.cnblogs.com/justinzhang/archive/2011/09/23/2185963.html 写的很详细 http://blog.csdn.net/j ...

  8. java框架篇---struts开发

    1.Token Token主要是以一种指令牌的形式进行重复提交处理的,在很多情况下,如果用户对同一个表单进行了多次提交,则有可能造成数据的混乱,此时,WEB服务器必须可以对这种重复提交的行为做出处理, ...

  9. [转]JSP页面的动态包含和静态包含示例及介绍

    原文地址:http://www.jb51.net/article/53659.htm 一.静态包含 本文介绍JSP静态包含语句,即使用JSP的include指令来完成的包含操作.JSP中,有两种包含其 ...

  10. 【Web安全】越权操作——横向越权与纵向越权

    参考:http://blog.csdn.net/github_39104978/article/details/78265433 看了上面的文章,对越权操作的概念还是比较模糊,不明确实际场景. 横向越 ...