C# halcon hobject 快速转Bitmap

 Bitmap Honject2Bitmap(HObject hObject)
        {
            //获取图像尺寸
            HOperatorSet.GetImageSize(hObject, out HTuple width0, out HTuple height0);

            HOperatorSet.GetImageSize(hObject, out width0, out height0);
            //创建交错格式图像
            HOperatorSet.InterleaveChannels(hObject, out HObject InterImage, "rgb", 4 * width0, 0);
            //获取交错格式图像指针
            HOperatorSet.GetImagePointer1(InterImage, out HTuple Pointer, out HTuple type, out HTuple width, out HTuple height);
            IntPtr ptr = Pointer;
            //构建新Bitmap图像
            Bitmap bitmap = new Bitmap(width / 4, height, width, PixelFormat.Format24bppRgb, ptr);
            return bitmap;
        }

 

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