C# 图片放大、缩小

    技术2022-06-08  63

    把pictureBox1的SizeMode属性设置为StretchImage定义变量:  Bitmap img; // 保存原图  int width; // 当前显示部分的宽度  int height; // 当前显示部分的高度初始化:  width = pictureBox1.Width;  height = pictureBox1.Height;  img = new Bitmap("Autumn.jpg"); // 从文件获取图片并显示在pictureBox1中:  bmp = new Bitmap(width, height);  Point pt = new Point(0, 0);  g.DrawImage(img, pt.X, pt.Y);  pictureBox1.Image = bmp;点击鼠标后的处理:  width += 50;  height += 50;  bmp = new Bitmap(width, height );  Graphics g = Graphics.FromImage(bmp);  Point pt = new Point(0, 0);  g.DrawImage(img, pt.X, pt.Y);  pictureBox1.Image = bmp;


    最新回复(0)