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()(这个只是网上看的,没实测)
随机推荐
- 利用canvas绘制序列帧动画
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Scala解码base64编码的URL提示Last unit does not have enough valid bits
问题描述 开始使用Base64.getMimeDecoder().decode(base_url).map(_.toChar).mkString去解码,部分数据也提示如题的错误 然后尝试使用Base6 ...
- jetty debug 启动 jettyconfig配置文件
jetty 代码启动 debug很简单 run----->>>debug as 代码启动配置文件 start 方法 @Test public void serverStrart( ...
- uboot之第一阶段
U-boot的启动一般分为两个阶段,现在我们先将第一阶段. 在此之前,我们先了解一下uboot的目录结构,各个文件夹是什么作用. 如果连各个文件夹是干什么的都不清楚就开始移植剪裁,势必会和我刚拿到开发 ...
- php连接oracle数据库
1.先安装一下oracle instant,把oci.dll所在的目录加入PATH环境变量里 或者直接安装oracle express php_pdo_oci 依赖于oracle 的oci.dll 2 ...
- [mount]linux 挂载时 mount: wrong fs type, bad option, bad superblock on /dev/sdb
原因:挂载时未格式化,使用的文件系统格式不对 解决方案:格式化 sudo mkfs -t ext4 /dev/sdb 再挂载 sudo mount /dev/sdb /xxx/ 用df -h检查,发现 ...
- 接口与virtual,override,new关键字
一,类继承接口 1,首先我们定义一个简单的ITeacher接口,并定义一个Professor类继承它. public interface ITeacher { void Print(); } publ ...
- RavenDb学习(三)静态索引
在静态索引这块,RavenDb其实的是lucene,所以里面有很多概念,其实都是lucene本身的. .定义静态Indexes documentStore.DatabaseCommands.PutIn ...
- tabs 标签样式
http://www.jq22.com/jquery-info17973 http://www.jq22.com/demo/elementTab201801262311/ 插件描述:基于element ...
- Gojs简单例子
前台代码: <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> ...