コード例 #1
0
ファイル: MVGather.cs プロジェクト: xuanximoming/PIC
 public unsafe bool initCard()
 {
     mv = new MicroView();
     // okLoadInitParam(m_hBoard,0);
     try
     {
         MicroView.MV_IMAGEINFO  BufInfo = new MicroView.MV_IMAGEINFO();
         MicroView.MV_IMAGEINFO *pBufInfo;                                                                                       //定义结构指针
         pBufInfo = &BufInfo;
         bool aa = MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.WORK_FIELD, MicroView.COLLECTION_FRAME); //设置按帧采集方式
         bool ss = MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.SET_GARBIMAGEINFO, (uint)pBufInfo);
         //MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_IN_HEIGHT, 576);//GARB_IN_HEIGHT			= 30,
         //MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_IN_WIDTH, 768);//GARB_IN_WIDTH			= 31,
         //MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_HEIGHT, 576);//GARB_HEIGHT				= 28,
         //MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_WIDTH, 768);//GARB_WIDTH				= 29,
         //MicroView.MV_SetDeviceParameter(m_hBoard, MicroView.MV_PARAMTER.ADJUST_LUMINANCE, 128);
         //MicroView.MV_SetDeviceParameter(m_hBoard, MicroView.MV_PARAMTER.ADJUST_SATURATION, 128);
         //MicroView.MV_SetDeviceParameter(m_hBoard, MicroView.MV_PARAMTER.ADJUST_HUE, 128);
         //MicroView.MV_SetDeviceParameter(m_hBoard, MicroView.MV_PARAMTER.ADJUST_CONTRAST, 128);
         //MicroView.MV_SetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_BITDESCRIBE, (uint)MicroView.DATA_aRGB8888);
         width  = MicroView.MV_GetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_WIDTH);
         height = MicroView.MV_GetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_HEIGHT);
         bits   = MicroView.MV_GetDeviceParameter(m_hBoard, (int)MicroView.MV_PARAMTER.GARB_BITDESCRIBE);
     }
     catch
     {
         MicroView.MV_GetLastError(true);
         return(false);
     }
     return(true);
 }
コード例 #2
0
ファイル: MVGather.cs プロジェクト: xuanximoming/PIC
        public bool seqprogress(IntPtr pData, ref MicroView.MV_IMAGEINFO pImageInfo, IntPtr pUserData, uint Index)
        {
            int stride = 0;

            switch (bits)
            {
            case MicroView.DATA_MONOCHOY8:
                stride = width;
                bm     = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, pData);
                //创建灰阶
                ColorPalette palette = bm.Palette;
                for (int i = 0; i < palette.Entries.Length; i++)
                {
                    palette.Entries[i] = Color.FromArgb(i, i, i);
                }
                bm.Palette = palette;
                break;

            case MicroView.DATA_aRGB8888:
                stride = 4 * width;
                bm     = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format32bppRgb, pData);
                break;

            case MicroView.DATA_CO_RGB24:
                stride = 3 * width;
                bm     = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, pData);
                break;

            case MicroView.DATA_CO_RGB565:
                stride = 2 * width;
                bm     = new Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format16bppRgb565, pData);
                break;

            default:
                MessageBox.Show("没找到卡!");
                CloseCard();
                break;
            }
            GetCallBackEventHandler temp = GetCallBack;

            if (temp != null)
            {
                temp(bm);
            }
            return(true);
        }