C# Bitmap转化为BitmapImage方法
2016-11-23 22:29
253 查看
public BitmapImage BitmapToBitmapImage(Bitmap bitmap) { Bitmap bitmapSource = new Bitmap(bitmap.Width,bitmap.Height); int i,j; for(i=0;i<bitmap.Width;i++) for (j = 0; 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# GDI+ Image.Save()或者Bitmap.Save()方法保存高质量图片
- Bitmap转化为BitmapImage方法
- c#中将bitmap或者image保存为清晰的gif --转载自http://tech.ddvip.com/2009-05/1243237863120924.html
- Silverlight - 将BitmapImage转化为Stream或byte数组
- C# 将Image转化为数据流
- 将ImageView对象转化为Bitmap对象总结--初步
- C#将PPT转化为XPS时遇到的“对COM组件的调用返回了错误HRESULT E_FAIL”错误的解决方法
- 转载:C#中,Image与Bitmap的区别?
- c# Graphics.DrawImage 方法
- (转)C#进行图像处理的几种方法(bitmap,bitmapData,IntPtr)
- [C#] Byte[]、Image、Bitmap 之间的相互转换
- [C#] int转化为字符串前面补零方法
- 将winform得到的bitmap格式的普片转化成wpf image格式的图片
- 解决在List中用Bitmap作Image的source时候无法正常显示的方法
- (转)C#进行图像处理的几种方法(bitmap,bitmapData,IntPtr)
- 方法:C#在WinForm中如何将Image存入SQL2000和取出显示
- 将Image对象转化成二进制流方法
- C# Bitmap类型与Byte[]类型相互转化
- C# 加载图片image --(C#)Image.FromFile 方法会锁住文件的原因及可能的解决方法
- 如何在C#中将yyyy/mm/dd转化为yyyy-mm-dd的方法总结