如何使用数组镜像图像

我需要镜像图像并显示如下:

在此处输入图像描述

要显示如下:

在此处输入图像描述

这是我的代码到目前为止,我没有运气:

int Height = TransformedPic.GetLength(0); int Width = TransformedPic.GetLength(1); for (int i = 0; i < Height; i++)//loop rows { for (int j = 0; j < Width; j++)//loop columns { TransformedPic[i, j] = TransformedPic[i, ((2 * Width) - (j + 1))]; } } 

Image.RotateFlip将更快更轻松地完成工作:

 Bitmap bmp1 = (Bitmap)pictureBox1.Image; Bitmap bmp2 = new Bitmap(bmp1.Width * 2, bmp1.Height); using (Graphics G = Graphics.FromImage(bmp2)) { G.DrawImage(bmp1, 0, 0); bmp1.RotateFlip(RotateFlipType.RotateNoneFlipX); G.DrawImage(bmp1, bmp1.Width, 0); pictureBox2.Image = bmp2; } 

在此处输入图像描述

相反,你可以使用类似于你的循环和Bitmap.GetPixelBitmap.SetPixel但这将非常慢:

 TransformedPic.SetPixel(Width - i, j, TransformedPic.GetPixel(i,j)); 

超过宽度的一半..