PictureBox的属性设置为zoom,
现在有原图像上的几个矩形的坐标,现在想在控件的图像上的对应位置显示这几个矩形,但是因为图像被调整了,所以矩形所对应位置的坐标也变了
请问,能否获得Zoom属性对应的缩放比例?如果能,请问该怎么获得?

解决方案 »

  1.   

    好像没有,不过可以自己计算一下
      System.Drawing.Image img = System.Drawing.Image.FromFile("c:\\1.jpg");      float scale = 0; //缩放比例
           if(pictureBox1.Height>0)
          {
                  if (img.Width / img.Height < pictureBox1.Width / pictureBox1.Height)
                {
                    scale = (pictureBox1.Height * 1.0f) / img.Height;
                }
                else
                {
                    scale = (pictureBox1.Width * 1.0f) / img.Width;
                }
           }
      

  2.   

    已知 PictureBox 的 size
    获取 image 的 size 用 PictureBox.size * image.size / 100 就是缩放的百分比了
      

  3.   

    自己算下就行
    double t=(double)现在的height/原来的Height