1. 程式人生 > >影象的放大與縮小

影象的放大與縮小

實現效果:

  

知識運用:

  PictureBox控制元件的Height和Width屬性

  和PictureBox控制元件的SizeMode屬性  //PictureBoxSizeMode列舉值

  

實現程式碼:

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            try
            {
                pictureBox1.Width = (int)(trackBar1.Value * pictureBox1.Image.Width * -0.2);
                pictureBox1.Height = (int)(trackBar1.Value * pictureBox1.Image.Height * -0.2);
            }
            catch {} 
        }