当前位置: 代码迷 >> C# >> 关于Picturebox中图像的缩放跟拖动
  详细解决方案

关于Picturebox中图像的缩放跟拖动

热度:31   发布时间:2016-05-05 03:24:36.0
关于Picturebox中图像的缩放和拖动
最近用C#做了一个浏览图片的工具,欲实现图片的缩放和拖拽,但是试了很久,实现的都是对picturebox控件进行的拖拽和缩放,而并非是对picturebox中图片进行的缩放和拖拽,知道一点就是用bitmap、重绘,但是不知道怎么实现,希望在这里能得到解决方案。
------解决思路----------------------
picturebox in panel
img in picturebox sizemode zoom

  public static Image get_img(int w_x,int h_y)
        {
            Screen scr = Screen.PrimaryScreen;
            Rectangle rc = scr.Bounds;
            int iWidth = rc.Width;
            int iHeight = rc.Height;
            Bitmap myImage = new Bitmap(iWidth, iHeight);
            Graphics g1 = Graphics.FromImage(myImage);
            g1.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));

            return myImage.GetThumbnailImage(w_x, h_y, CallBack, IntPtr.Zero);
        }

        private static bool CallBack()  //这个委托方法需要是static的
        {
            return false;
        }


自己改改