private void button3_Click(object sender, EventArgs e)//放大图片
{
Bitmap mybmp = new Bitmap(this.pictureBox1.Image);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(this.pictureBox1.BackColor);
g.ScaleTransform(1.2f, 1.2f);
g.DrawImage(mybmp, this.pictureBox1.ClientRectangle, 0, 0, mybmp.Width, mybmp.Height, GraphicsUnit.Pixel);
g.Dispose();
}
private void button4_Click(object sender, EventArgs e)//缩小图片
{
Bitmap mybmp = new Bitmap(this.pictureBox1.Image);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(this.pictureBox1.BackColor);
g.ScaleTransform(0.8f, 0.8f);
g.DrawImage(mybmp, this.pictureBox1.ClientRectangle, 0, 0, mybmp.Width, mybmp.Height, GraphicsUnit.Pixel);
g.Dispose();
}
private void button5_Click(object sender, EventArgs e)//照片左转
{
Bitmap mybitmap = new Bitmap(this.pictureBox1.Image);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(this.pictureBox1.BackColor);
g.TranslateTransform(0, (float)this.pictureBox1.Image.Width);
g.RotateTransform(-90.0f);
g.DrawImage(mybitmap, this.pictureBox1.ClientRectangle, 0, 0, mybitmap.Width, mybitmap.Height, GraphicsUnit.Pixel);
g.Dispose();
}
private void button6_Click(object sender, EventArgs e)//照片右转
{
Bitmap mybitmap = new Bitmap(this.pictureBox1.Image);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(this.pictureBox1.BackColor);
g.TranslateTransform((float)this.pictureBox1.Image.Height, 0);
g.RotateTransform(90.0f);
g.DrawImage(mybitmap, this.pictureBox1.ClientRectangle, 0, 0, mybitmap.Width, mybitmap.Height, GraphicsUnit.Pixel);
g.Dispose();
}
C#实现图片的放大缩小、左旋右旋,PS无法保存变化后的图片求辅导
最新推荐文章于 2023-05-30 11:23:19 发布