コード例 #1
0
 public void LoadImage(IJFImage jImage)
 {
     if (!Created)
     {
         return;
     }
     if (InvokeRequired)
     {
         Invoke(new dgLoadImage(LoadImage), new object[] { jImage });
         return;
     }
     //if (jImage != jFImage)
     //{
     //    if (null != jFImage)
     //    {
     //        jFImage.Dispose();
     //        jFImage = null;
     //    }
     //}
     jFImage = jImage;
     if (null != bitImage)
     {
         bitImage.Dispose();
         bitImage = null;
     }
     if (null != jFImage)
     {
         int iRet = jFImage.GenBmp(out bitImage);
         if (0 == iRet)
         {
             DrawImage();
         }
         else
         {
             string errorInfo = jFImage.GetErrorInfo(iRet);
             this.labErrorInfo.Text = errorInfo;
         }
     }
     else
     {
         labErrorInfo.Text = "Image = null";
     }
 }
コード例 #2
0
ファイル: UcCmr.cs プロジェクト: xhyangxianjun/ASMZZZ
        void ShowImg(IJFImage img)
        {
            if (InvokeRequired)
            {
                Invoke(new dgShowImg(ShowImg), new object[] { img });
                return;
            }
            int err = 0;

            if (_imgShowMode == ImgShowMode.sdk) // 使用SDK内部自带的图片显示功能
            {
                picWnd = picBox.Handle;
                err    = img.DisplayTo(picWnd);
                if (err != 0)
                {
                    if (!chkContinueGrab.Checked)
                    {
                        MessageBox.Show("SDK显示图像失败,错误信息:" + _currImage.GetErrorInfo(err) + " " + DateTime.Now.ToString("HH:mm:ss:ms"));
                    }
                    else
                    {
                        ShowTips("SDK显示图像失败,错误信息:" + _currImage.GetErrorInfo(err) + " " + DateTime.Now.ToString("HH:mm:ss:ms"));
                    }
                }
                else
                {
                    ShowTips("SDK显示图像完成");
                }
            }
            else if (_imgShowMode == ImgShowMode.halcon) //Halcon显示图片
            {
                if (_currHo != null)
                {
                    _currHo.Dispose();
                    _currHo = null;
                }
                object hoImage = null;
                ShowTips("Halcon转换开始:" + DateTime.Now.ToString("HH:mm:ss:ms"));
                err = img.GenHalcon(out hoImage);
                if (err != 0)
                {
                    ShowTips("显示图片失败,未能将图片转化为Halcon对象,错误信息:" + img.GetErrorInfo(err));
                    if (!chkContinueGrab.Checked)
                    {
                        MessageBox.Show("显示图片失败,未能将图片转化为Halcon对象,错误信息:" + img.GetErrorInfo(err));
                    }
                    return;
                }
                ShowTips("Halcon转换完成:" + DateTime.Now.ToString("HH:mm:ss:ms"));
                ShowHalconImg((HObject)hoImage, img.PicWidth, img.PicHeight);
                _currHo = (HObject)hoImage;
                ShowTips("图像显示完成:" + DateTime.Now.ToString("HH:mm:ss:ms"));
            }
            else if (_imgShowMode == ImgShowMode.bitmap) //
            {
                ShowTips("Bitmap转换开始:" + DateTime.Now.ToString("HH:mm:ss:ms"));
                Bitmap bmp = null;
                err = img.GenBmp(out bmp);
                if (err != 0)
                {
                    ShowTips("显示图片失败,未能将图片转化为Bitmap对象,错误信息:" + _currImage.GetErrorInfo(err));
                    if (!chkContinueGrab.Checked)
                    {
                        MessageBox.Show("显示图片失败,未能将图片转化为Bitmap对象,错误信息:" + _currImage.GetErrorInfo(err));
                    }
                    return;
                }
                ShowTips("Bitmap转换完成:" + DateTime.Now.ToString("HH:mm:ss:ms"));
                ShowBitmap(bmp);////
                if (null != _currBmp)
                {
                    _currBmp.Dispose();
                    _currBmp = bmp;
                }
            }
            _currImage = img;
        }