c# 联合halcon Bitmap快速转Hobject

 public HObject Bitmap2Hobject(Bitmap bitmap)
 {
      Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
      BitmapData bitmapData = bitmap.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
      IntPtr intPtr = bitmapData.Scan0;
      HObject hObject;

      HOperatorSet.GenEmptyObj(out hObject);

      hObject.Dispose();
      HOperatorSet.GenImageInterleaved(out hObject, intPtr, "bgrx", bitmap.Width, bitmap.Height, -1, "byte", 0, 0, 0, 0, -1, 0);
      bitmap.UnlockBits(bitmapData);

      return hObject;
  }

你可能感兴趣的:(C#,winfrom)