首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏码客

    WPF图片处理相关

    /BitmapImage 继承关系 ImageSource=>BitmapSource=>BitmapImage ImageSource ImageSource表示具有宽度、高度和 ImageMetadata BitmapSource BitmapSource 也是一个抽象类。 BitmapSource 是 Windows Presentation Foundation (WPF) 图像处理管道的基本构建基块,从概念上讲,以特定大小和分辨率指定一组固定的像素。 BitmapSource 可以是解码器提供的图像文件中的单个帧,也可以是操作自身 BitmapSource 的转换的结果。 BitmapSource 不用于表示多帧图像或动画。 = new WriteableBitmap(bitmapSource); sourceImage.Dispose(); sourceBmp.Dispose(); image.Source

    4.3K31发布于 2020-08-12
  • 来自专栏sofu456

    dotnet bitmap

    Marshal.Copy(image, 0, bmData.Scan0, image.Length); //bmpData.Scan0 = data; 不安全 bmImage.UnlockBits(bmpData); bitmapsource IntPtr ip = pic.GetHbitmap(); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap

    94420发布于 2020-01-14
  • 来自专栏sofu456

    dotnet bitmap(MemoryStream)

    Marshal.Copy(image, 0, bmData.Scan0, image.Length); //bmpData.Scan0 = data; 不安全 bmImage.UnlockBits(bmpData); bitmapsource IntPtr ip = pic.GetHbitmap(); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap

    51210编辑于 2022-05-06
  • 来自专栏.NET开发那点事

    使用Azure人脸API对图片进行人脸识别

    = new BitmapImage(); bitmapSource.BeginInit(); bitmapSource.CacheOption = BitmapCacheOption.None ; bitmapSource.UriSource = fileUri; bitmapSource.EndInit(); FacePhoto.Source = bitmapSource; // Detect any faces in the image. , new Rect(0, 0, bitmapSource.Width, bitmapSource.Height)); double bitmapSource = (BitmapSource)imageSource; var scale = FacePhoto.ActualWidth / (bitmapSource.PixelWidth

    2.6K20发布于 2020-08-11
  • 来自专栏码客

    WPF桌面端开发5-常用技巧

    的时候,DPI是96;这条语句的作用时获取缩放倍数 float factor = Graphics.FromHwnd(IntPtr.Zero).DpiX / 96; Bitmap/BitmapImage/BitmapSource BitmapSource是Imagesource的子类 WPF的Image控件中设置ImageSource image1.Source = new BitmapImage(new Uri(@"image bitmapImage.Freeze(); } return bitmapImage; } image1.Source = BitmapToBitmapImage(bitmap); Bitmap => BitmapSource BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty , BitmapSizeOptions.FromEmptyOptions()); BitmapSource => Bitmap BitmapSource m = (BitmapSource)image1

    1K10发布于 2020-05-09
  • 来自专栏web全栈之路

    调用打印机拍照的工具类

    false; IntPtr ip = Image.FromHbitmap(bitmap.GetHbitmap()).GetHbitmap(); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ip, BitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmapSource

    70310编辑于 2022-09-29
  • 来自专栏林德熙的博客

    dotnet 读 WPF 源代码笔记 了解 WPF 已知问题 后台线程创建 WriteableBitmap 锁住主线程

    在 WPF 中,如果在没有开启 Dispatcher 的后台线程里面创建 WriteableBitmap 对象,在 WriteableBitmap 构造函数传入在主线程创建的 BitmapSource { private void InitFromBitmapSource( BitmapSource source ) System.Windows.Media.Imaging.BitmapSource.UpdateResource(System.Windows.Media.Composition.DUCE.Channel System.Windows.Media.Imaging.BitmapSource.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel System.Windows.Media.Imaging.WriteableBitmap.WriteableBitmap(System.Windows.Media.Imaging.BitmapSource

    78120发布于 2021-04-19
  • 来自专栏林德熙的博客

    WPF 尝试使用 WinML 做一个简单的手写数字识别应用

    * bitmapSource.Format.BitsPerPixel / 8; var length = stride * bitmapSource.PixelHeight; , bitmapSource.PixelHeight); 拿到 SoftwareBitmap 之后即可创建 VideoFrame 对象,代码如下 VideoFrame inputImage ); var length = bitmapSource.PixelWidth * bitmapSource.PixelHeight * bitmapSource.Format.BitsPerPixel / 8; var byteArray = new byte[length]; var stride = bitmapSource.PixelWidth * bitmapSource.Format.BitsPerPixel , bitmapSource.PixelHeight); VideoFrame inputImage = VideoFrame.CreateWithSoftwareBitmap

    1K10编辑于 2023-12-11
  • 来自专栏林德熙的博客

    WPF 对接 Vortice 调用 D2D 使用 IWICBitmap 离屏渲染

    完成之后,将 IWICBitmap 封装为一个 BitmapSource 对象,扔给 WPF 层,当成图片接入 WPF 的渲染框架 创建 IWICBitmap 对象和挂上 D2D 以及绘制逻辑的细节,请参阅 例如本文就采用啥都顶不住的画 10 万个圆的方法 完成离屏渲染之后,需要将 IWICBitmap 的结果对接到 WPF 框架,对接方法是封装为一个 BitmapSource 对象。 { public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) : base The bitmapSource parameter comes from BitmapSource.CreateCachedBitmap // which already calculated WicSourceHandle = bitmapSource; _bitmapInit.EndInit(); UpdateCachedSettings()

    91910编辑于 2023-04-07
  • 来自专栏Kiba518

    C#开发学习人工智能的第一步

    FileHelper.FileToBytes(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "timg.jpg")); BitmapSource bitmapSource = ImageHelper.BytesToBitmapImage(bytes); var w = bitmapSource.Width; var h = bitmapSource.Height ; var stride = bitmapSource.Format.BitsPerPixel * (int)w / 8; //计算Stride byte[] byteList = new byte[(int)h * stride]; bitmapSource.CopyPixels(byteList, stride, 0); Affdex.Frame frame

    1.1K30发布于 2019-09-04
  • 来自专栏高级工程司

    WPF实现基础控件之托盘的示例代码分享

     bitmapSource)        {            byte[] imgByte = default;            if (! (bitmapSource is BitmapImage bitmapImage))            {                bitmapImage = new BitmapImage(  bitmapSource = bmp;                    //if (bitmapSource.Format ! = PixelFormats.Bgra32 && bitmapSource.Format ! = PixelFormats.Pbgra32)                    //    bitmapSource = new FormatConvertedBitmap(bitmapSource

    1.1K00编辑于 2022-11-06
  • 来自专栏林德熙的博客

    WPF 创建空白图片

    本文告诉大家如何在 WPF 创建空白图片,可以创建1像素图片 可以使用 BitmapSource 的 Create 方法创建空白图片 // 限制不能创建小于2x2的图片 const int width = 2; const int height = width; BitmapSource.Create dpi = 96; // R G B 三个像素 const int colorLength = 3; var image = BitmapSource.Create

    1.2K10发布于 2020-02-19
  • 来自专栏物联网知识

    摄像头拍照功能是怎样实现的?自己动手做一个!

    { if (videoSourcePlayer.IsRunning) { BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( PngBitmapEncoder pE = new PngBitmapEncoder(); pE.Frames.Add(BitmapFrame.Create(bitmapSource

    1.2K90发布于 2021-07-19
  • 来自专栏菩提树下的杨过

    silverlight中如何将BitmapImage转化为Stream或byte数组?

    上一篇"base64编码在silverlight中的使用"里已经提到WriteableBitmap对象可以借助FluxJpeg转化为base64字符串,而WriteableBitmap又能从BitmapSource freeware)http://www.CodeHighlighter.com/-->1 WriteableBitmap wb = new WriteableBitmap(img.Source as BitmapSource

    1.4K50发布于 2018-01-23
  • 来自专栏sofu456

    WPF中UI元素跨线程访问

    BitmapSource跨线程访问,可以调用Freeze设置元素为只读模式。 sender) return;//不匹配设备退出 IntPtr hBitmap = eventArgs.Frame.GetHbitmap(); BitmapSource null) return;//没有找到设备退出 IntPtr hBitmap = eventArgs.Frame.GetHbitmap(); BitmapSource

    1.5K20发布于 2019-07-09
  • 来自专栏dotNET编程大全

    c#验证两个QQ头像相似度(附源码)

    int countDifferent = 0; Image img = this.MyPicture.Image; Bitmap bitmapSource = new Bitmap(img); //Bitmap bitmapSource = BytesToBitmap(ResizeImage(mypicurl)); width = bitmapSource.Width; height = bitmapSource.Height; Bitmap bitmapTarget for (int j = 0; j < bitmapTarget.Height; j++) { if (bitmapSource.GetPixel

    77030编辑于 2022-04-19
  • 来自专栏叁金大数据

    C#中Image , Bitmap 和 BitmapData

    本篇文章他就是来打酱油的,这里提供一个Bitmap转成BitmapSource的方法。 [DllImport("gdi32")] 2 static extern int DeleteObject(IntPtr o); 3 ///

    4 /// bitmap转换为bitmapsource image 5 /// 6 /// <param name="pic"></param> 7 /// <returns></returns> 8 public static BitmapSource GetMapSource(Bitmap pic) 9 { 10 IntPtr ip = pic.GetHbitmap(); 11 BitmapSource bitmapSource System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); 14 DeleteObject(ip); 15 return bitmapSource

    3.3K20发布于 2018-09-04
  • 来自专栏码客

    扫描仪对接(C#)

    return imagepath; } 获取扫描的缩略图 private ImageSource GenerateThumbnail(DataTransferredEventArgs e) { BitmapSource Data is copied from the source so the windows handle can be saftely discarded /// even when the BitmapSource summary> /// <param name="dibHandle"></param> /// <returns>A copy of the image in a managed BitmapSource </returns> /// public static BitmapSource FormHDib(IntPtr dibHandle) { BitmapSource bs = BitmapSource.Create(width, height, xDpi, yDpi, pf, null, imageBytes, stride); } catch

    5.5K20编辑于 2022-09-19
  • 来自专栏逸鹏说道

    c# 温故而知新: 线程篇(一) 下

    /// WPF 多线程将图片分割 /// public partial class MainWindow : Window { BitmapSource /// <param name="para">Parameter</param> /// <returns>部分图片</returns> private BitmapSource para.OrginalImage.PixelFormat) as Bitmap; return ChangeBitmapToBitmapSource(bitmap2); } private BitmapSource ChangeBitmapToBitmapSource(Bitmap bmp) { BitmapSource returnSource;

    87360发布于 2018-04-10
  • 来自专栏林德熙的博客

    WPF 使用不安全代码快速从数组转 WriteableBitmap

    本文告诉大家一个快速的方法,直接把数组转 WriteableBitmap 先来说下以前的方法,以前使用的是 BitmapSource ,这个方法是大法官方提供的。 BitmapSource.Create(LogicalWidth, LogicalHeight, 96, 96, PixelFormats.Bgra32, null, 对比一下性能,这时原先的 BitmapSource 方法占用内存 ? 这是使用不安全代码占用内存 ? 实际跑一张 gif 图的性能 ?

    1.2K10发布于 2018-09-19
领券