|
GenImage1Extern读取IntPtr转图像:
- private void button6_Click(object sender, EventArgs e)
- {
- HObject outputImage;
- ImagePath = @"D:\1.jpg";
- HOperatorSet.GenEmptyObj(out ho_Image);
- ho_Image.Dispose();
- HOperatorSet.ReadImage(out ho_Image, ImagePath);
- HOperatorSet.GetImageSize(ho_Image, out Width, out Height);
- HOperatorSet.CountChannels(ho_Image, out hv_channel);
- IntPtr p = Marshal.AllocHGlobal(Width.I * Height.I * hv_channel.I);
- HOperatorSet.GenImage1Extern(out outputImage, "byte", 12, 12, p, Marshal.GetFunctionPointerForDelegate(callback));
- }
- HalconDotNet.HalconAPI.HClearProcCallBack callback = __OnFreeCallBack;
- private static void __OnFreeCallBack(IntPtr pImg)
- {
- Marshal.FreeHGlobal(pImg);
- }
复制代码
参考:
【1】halcon c# 内存泄漏 图片存储格式转换
|
|