小弟写了一个图片镜像的代码,但是运行总是出错,大家帮忙看看private void 水平镜像ToolStripMenuItem_Click(object sender, EventArgs e)
{
box = new Bitmap(pictureBox1.Image);
width = pictureBox1.Image.Width;
height = pictureBox1.Image.Height;
Graphics g = pictureBox1.CreateGraphics();
Bitmap bmp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
g.Clear(this.BackColor);
Color c = new Color(); ;
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
c = box.GetPixel(x, y);
bmp.SetPixel(width - 1 - x, y, c);
}
}
pictureBox1.Image = bmp;
}
{
box = new Bitmap(pictureBox1.Image);
width = pictureBox1.Image.Width;
height = pictureBox1.Image.Height;
Graphics g = pictureBox1.CreateGraphics();
Bitmap bmp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
g.Clear(this.BackColor);
Color c = new Color(); ;
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
c = box.GetPixel(x, y);
bmp.SetPixel(width - 1 - x, y, c);
}
}
pictureBox1.Image = bmp;
}
height = pictureBox1.Image.Height;
to::
width = box.Width;
height = box.Height;ANDBitmap bmp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
to::
Bitmap bmp = new Bitmap(width , height );
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
pictureBox1.Image = bmp;
{
box = new Bitmap(pictureBox1.Image);
width = pictureBox1.Image.Width;
height = pictureBox1.Image.Height;
Graphics g = pictureBox1.CreateGraphics();
Bitmap bmp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
g.Clear(this.BackColor);
Color c = new Color(); ;
for (x = 0; x < width; x++)
{
for (y = 0; y < height; y++)
{
c = box.GetPixel(x, y);
bmp.SetPixel(x, height - 1 - y, c);
}
}
pictureBox1.Image = bmp;
}