Exemple #1
0
        public bool GetPixelViewImage(Point pt, out Color color)
        {
            #region 通过物理坐标获取图像像素数据

            bool ret = false;
            color = Color.FromArgb(100, 100, 100);

            if (m_bmp != null)
            {
                if (_lockbmp == null)
                {
                    _lockbmp = new clsPointBitmap(m_bmp);
                    _lockbmp.lockBits();
                    m_bLock = true;
                }
                else if (!m_bLock)
                {
                    _lockbmp.lockBits();
                    m_bLock = true;
                }
                //PointBitmap _lockbmp = new PointBitmap(m_bmp);
                //_lockbmp.LockBits();
                pt = LpToVp(pt);
                if (pt.X >= 0 && pt.Y >= 0 && pt.X < _lockbmp.Width && pt.Y < _lockbmp.Height)
                {
                    color = _lockbmp.getPixel(pt.X, pt.Y);
                    ret   = true;
                }
                //_lockbmp.UnlockBits();
            }

            return(ret);

            #endregion
        }
Exemple #2
0
        public CameraView()
        {
            #region 默认参数

            m_iIndex       = 0;
            m_ptCenter     = new Point(0, 0);
            m_ptMarkOffset = new Point(0, 0);
            m_bmp          = null;
            imageView      = null;
            _lockbmp       = null;
            m_bLock        = false;

            #endregion
        }
Exemple #3
0
        public void Dispose()
        {
            #region 清空所占资源

            if (m_bmp != null)
            {
                if (_lockbmp != null)
                {
                    if (m_bLock)
                    {
                        _lockbmp.unlockBits();
                        m_bLock = false;
                    }
                    _lockbmp = null;
                }
                m_bmp.Dispose();
                m_bmp = null;
            }

            #endregion
        }
Exemple #4
0
        public bool GetPixelLiveImage(Point pt, out Color color)
        {
            #region 通过像素坐标获取图像像素数据

            bool ret = false;
            color = Color.FromArgb(100, 100, 100);

            if (m_bmp != null)
            {
                clsPointBitmap _lockbmp = new clsPointBitmap(m_bmp);
                _lockbmp.lockBits();
                if (pt.X < _lockbmp.Width && pt.Y < _lockbmp.Height)
                {
                    color = _lockbmp.getPixel(pt.X, pt.Y);
                    ret   = true;
                }
                _lockbmp.unlockBits();
            }

            return(ret);

            #endregion
        }
Exemple #5
0
        public Bitmap CreateBoardImageLarge()
        {
            #region 创建整版图

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            int            nWidth  = PCB.m_pPCB.m_uSizeX * 1000 / PCB.m_pPCB.m_uResolutionX / Board_Scale;
            int            nHeight = PCB.m_pPCB.m_uSizeY * 1000 / PCB.m_pPCB.m_uResolutionY / Board_Scale;
            Point          pt      = new Point(0, 0);
            Color          rgb;
            PixelFormat    format    = PixelFormat.Format8bppIndexed;
            Bitmap         m_bmpTemp = new Bitmap(nWidth, nHeight, format);
            clsPointBitmap _lockbmp  = new clsPointBitmap(m_bmpTemp);
            _lockbmp.lockBits();
            for (int j = 0; j < _lockbmp.Height; j++)
            {
                for (int i = 0; i < _lockbmp.Width; i++)
                {
                    if (PCB.m_pPCB.m_iCoordinateType == ConstData.LeftDown)
                    {
                        pt.X = i * Board_Scale * PCB.m_pPCB.m_uResolutionX / 1000;
                        pt.Y = -j * Board_Scale * PCB.m_pPCB.m_uResolutionY / 1000 + PCB.m_pPCB.m_uSizeY;
                    }
                    else if (PCB.m_pPCB.m_iCoordinateType == ConstData.LeftUp)
                    {
                        pt.X = i * Board_Scale * PCB.m_pPCB.m_uResolutionX / 1000;
                        pt.Y = j * Board_Scale * PCB.m_pPCB.m_uResolutionY / 1000;
                    }
                    else if (PCB.m_pPCB.m_iCoordinateType == ConstData.RightDown)
                    {
                        pt.X = -i * Board_Scale * PCB.m_pPCB.m_uResolutionX / 1000 + PCB.m_pPCB.m_uSizeX;
                        pt.Y = -j * Board_Scale * PCB.m_pPCB.m_uResolutionY / 1000 + PCB.m_pPCB.m_uSizeY;
                    }
                    else
                    {
                        pt.X = -i * Board_Scale * PCB.m_pPCB.m_uResolutionX / 1000 + PCB.m_pPCB.m_uSizeX;
                        pt.Y = j * Board_Scale * PCB.m_pPCB.m_uResolutionY / 1000;
                    }
                    pt.Offset(PCB.m_pPCB.m_ptOriginOffset);

                    try
                    {
                        if (GetPixelAreaImage(pt, out rgb))
                        {
                            _lockbmp.setPixel(i, j, rgb);
                        }
                        else
                        {
                            _lockbmp.setPixel(i, j, Color.FromArgb(100, 100, 100));
                        }
                    }
                    catch (Exception exc)
                    {
                        //Wells.WellsFramework.WellsMetroMessageBox.Show(null, exc.Message);
                    }
                }
            }
            _lockbmp.unlockBits();

            UnlockAreaImage();

            if (!m_bIsColor)
            {
                m_bmpTemp.Palette = PCB.m_pPCB.palette;
            }

            sw.Stop();
            //Wells.FrmType.frm_Log.Log("拼接耗时:" + sw.ElapsedMilliseconds.ToString() + " ms", 0, 0);

            return(m_bmpTemp);

            #endregion
        }
Exemple #6
0
        public bool CreateBoardImage()//速度太快,连续进入该函数会造成图片数据锁定冲突
        {
            #region 创建视图区图像

            if (1 == System.Threading.Interlocked.Read(ref LockedSign.l2ShowIsCreatingImage))
            {
                return(false);
            }
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            if (m_rcPCBImageArea.Width > 0 && m_rcPCBImageArea.Height > 0)
            {
                System.Threading.Interlocked.Exchange(ref LockedSign.l2ShowIsCreatingImage, 1);

                Point       pt = new Point(0, 0);
                Color       rgb;
                PixelFormat format = PixelFormat.Format8bppIndexed;
                m_bmpArea = new Bitmap(m_rcPCBImageArea.Width, m_rcPCBImageArea.Height, format);
                clsPointBitmap _lockbmp = new clsPointBitmap(m_bmpArea);
                _lockbmp.lockBits();
                for (int j = 0; j < _lockbmp.Height; j++)
                {
                    for (int i = 0; i < _lockbmp.Width; i++)
                    {
                        pt.X = i;
                        pt.Y = j;
                        pt.Offset(m_rcPCBImageArea.X, m_rcPCBImageArea.Y);

                        pt = VpToLp(pt);

                        try
                        {
                            if (GetPixelAreaImage(pt, out rgb))
                            {
                                _lockbmp.setPixel(i, j, rgb);
                            }
                            else
                            {
                                _lockbmp.setPixel(i, j, Color.FromArgb(100, 100, 100));
                            }
                        }
                        catch (Exception exc)
                        {
                            //Wells.WellsFramework.WellsMetroMessageBox.Show(null, exc.Message);
                        }
                    }
                }
                _lockbmp.unlockBits();

                UnlockAreaImage();

                if (!m_bIsColor)
                {
                    m_bmpArea.Palette = PCB.m_pPCB.palette;
                }

                System.Threading.Interlocked.Exchange(ref LockedSign.l2ShowIsCreatingImage, 0);
            }
            sw.Stop();
            //Wells.FrmType.frm_Log.Log("拼接耗时:" + sw.ElapsedMilliseconds.ToString() + " ms", 0, 0);

            return(true);

            #endregion
        }