private void mirror_Click(objectsender, EventArgs e)
{if (curBitmap!=null)
{
mirror mirForm= newmirror();if (mirForm.ShowDialog()==DialogResult.OK)
{
Rectangle rect= new Rectangle(0, 0, curBitmap.Width, curBitmap.Height);
BitmapData bmpData=curBitmap.LockBits(rect, ImageLockMode.ReadWrite, curBitmap.PixelFormat);
IntPtr ptr=bmpData.Scan0;int bytes = 0;判断是灰度色图像还是彩色图像,给相应的大小
if (curBitmap.PixelFormat==PixelFormat.Format8bppIndexed)
{
bytes= curBitmap.Width *curBitmap.Height;
}else if (curBitmap.PixelFormat ==PixelFormat.Format24bppRgb)
{
bytes= curBitmap.Width * curBitmap.Height * 3;
}byte[] pixelValues = new byte[bytes];
Marshal.Copy(ptr, pixelValues,0, bytes);//水平中轴
int halfWidth = curBitmap.Width / 2;//垂直中轴<