/// <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; } }
原文:https://www.cnblogs.com/zxtang/p/14906430.html