有哪位朋友懂得通过MouseDown、MouseMove以及MouseUp这三步实现图像的裁切功能?或者可以在多一步MouseDoubleClick或MouseLeave急求!

解决方案 »

  1.   

    /// 裁剪
            /// </summary>
            /// <param name="xPosition">X起始点</param>
            /// <param name="yPosition">Y起始点</param>
            /// <param name="width">宽</param>
            /// <param name="height">高</param>
            public void DrawOutCropArea(int xPosition, int yPosition, int width, int height)
            {
                _bitmapPrevCropArea = (Bitmap)_currentBitmap;
                Bitmap bmap = (Bitmap)_bitmapPrevCropArea.Clone();
                Graphics gr = Graphics.FromImage(bmap);
                Brush cBrush = new Pen(Color.FromArgb(150, Color.White)).Brush;
                Rectangle rect1 = new Rectangle(0, 0, _currentBitmap.Width, yPosition);
                Rectangle rect2 = new Rectangle(0, yPosition, xPosition, height);
                Rectangle rect3 = new Rectangle(0, (yPosition + height), _currentBitmap.Width, _currentBitmap.Height);
                Rectangle rect4 = new Rectangle((xPosition + width), yPosition, (_currentBitmap.Width - xPosition - width), height);
                gr.FillRectangle(cBrush, rect1);
                gr.FillRectangle(cBrush, rect2);
                gr.FillRectangle(cBrush, rect3);
                gr.FillRectangle(cBrush, rect4);
                _currentBitmap = (Bitmap)bmap.Clone();
            }