编程语言
首页 > 编程语言> > 将C#的bitmap格式转换为Halcon的图像格式

将C#的bitmap格式转换为Halcon的图像格式

作者:互联网

       /// <summary>
        /// Bitmap转HObject灰度图
        /// </summary>
        /// <param name="bmp">Bitmap图像</param>
        /// <param name="image">HObject图像</param>
        public static void Bitmap2HObjectBpp8(Bitmap bmp, out HObject image)
        {
            try
            {
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
 
                BitmapData srcBmpData = bmp.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);
 
                HOperatorSet.GenImage1(out image, "byte", bmp.Width, bmp.Height, srcBmpData.Scan0);
                bmp.UnlockBits(srcBmpData);
            }
            catch (Exception)
            {
                image = null;
            }
        }

 

标签:图像格式,C#,srcBmpData,image,bmp,Halcon,Width,HObject,Bitmap
来源: https://www.cnblogs.com/zxtang/p/14906430.html