rt,像photoshop中的实现按比例大小显示的功能,用GDI+实现,谢谢

解决方案 »

  1.   

    图片放大:
    private float a,b;
    private Image image1;
      

  2.   

    private void Form1_Load(object sender, System.EventArgs e)
    {
    image1=Image.FromFile("f:\\1.jpg");
    a=Convert.ToSingle(image1.Width);
    b=Convert.ToSingle(image1.Height);
    }
    private void button1_Click(object sender, System.EventArgs e)
    {

    //建立一个画图对象
    this.pictureBox1.Refresh();
    Graphics g=this.pictureBox1.CreateGraphics();

    a=(float)(a*1.2);
    b=(float)(b*1.2);

    g.DrawImage(image1,0,0,a,b);

    }
      

  3.   

    图片缩小:
    private void button2_Click(object sender, System.EventArgs e)
    {

    //建立一个画图对象
          this.pictureBox1.Refresh();
    Graphics g=this.pictureBox1.CreateGraphics();

         a=(float)(a*0.8);
    b=(float)(b*0.8);

    g.DrawImage(image1,0,0,a,b);


    }