示例#1
0
        protected void GenerageBackImage()
        {
            if (mImgPictureBox.Width < 1 || this.mImgPictureBox.Height < 1)
            {
                return;
            }
            if (bakImage == null || bakImage.Size != mImgPictureBox.Size)
            {
                bakImage = new Bitmap(mImgPictureBox.Width, mImgPictureBox.Height);
            }
            Graphics g = Graphics.FromImage(bakImage);

            g.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, bakImage.Width, bakImage.Height));
            RectangleF srcRec      = new RectangleF(0, 0, (float)imageData.GetLength(1), (float)imageData.GetLength(0));
            RectangleF zoomSrcRec  = PubMatrix.TransformRectangle(srcRec, Jacobi_Image);
            RectangleF viewRec     = new RectangleF(0, 0, (float)mImgPictureBox.Width, (float)mImgPictureBox.Height);
            RectangleF viewZoomRec = RectangleF.Intersect(viewRec, zoomSrcRec);
            Matrix     mxInvert    = Jacobi_Image.Clone();

            mxInvert.Invert();
            RectangleF viewSrcRec = PubMatrix.TransformRectangle(viewZoomRec, mxInvert);

            if (PubMatrix.ReviseImageRect(imgObject.BMP.Size, ref viewSrcRec))
            {
                g.DrawImage(imgObject.BMP, viewZoomRec, viewSrcRec, GraphicsUnit.Pixel);
            }

            mxInvert.Dispose();
            g.Dispose();
        }
示例#2
0
        /// <summary>
        /// Mouse move.
        /// Moving without button pressed or with left button pressed
        /// is passed to active tool.
        /// </summary>
        protected virtual void mImgPictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (imageData != null && imageData.Length > 0)
            {
                Matrix m = Jacobi_Image.Clone();
                m.Invert();
                Point p = PubMatrix.TransformPoint(e.Location, m);
                int   v = 0;
                if (p.X < 0 || p.Y < 0 || p.X >= imageData.GetLength(1) || p.Y >= imageData.GetLength(0))
                {
                    v = 0;
                }
                else
                {
                    v = imageData[p.Y, p.X];
                }

                if (PositionAndValue != null)
                {
                    PositionAndValue(p, v);
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                int dx = e.X - WLmovePoint.X;
                int dy = e.Y - WLmovePoint.Y;
                if (dx == 0 && dy == 0)
                {
                    return;
                }
                WLmovePoint         = e.Location;
                imgObject.imgWindow = imgObject.imgWindow + dy * 2;
                if (imgObject.imgWindow <= 0)
                {
                    imgObject.imgWindow = 1;
                }
                imgObject.imgLevel = imgObject.imgLevel + dx * 2;
                if (imgObject.imgLevel <= 0)
                {
                    imgObject.imgLevel = 1;
                }

                imgObject.GenerateImage();

                RefreshView();
            }
        }