C#  图像水平,垂直翻转的方法,速度很快

重新把图像绘制成翻转的方法

/// <summary>
/// 图像水平翻转
/// </summary>
/// <param name="bmp">原来图像</param>
/// <returns></returns>
public static Bitmap HorizontalFlip(Bitmap bmp)
{
try
{
var width = bmp.Width;
var height = bmp.Height;
Graphics g = Graphics.FromImage(bmp);
Rectangle rect = new Rectangle(0, 0, width, height); 
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
g.DrawImage(bmp, rect); 
return bmp;
}
catch (Exception ex)
{
return bmp;
}

}


/// <summary>
/// 图像垂直翻转
/// </summary>
/// <param name="bit">原来图像</param>
/// <returns></returns>
public static Bitmap VerticalFlip(Bitmap bmp)
{
try
{
var width = bmp.Width;
var height = bmp.Height;
Graphics g = Graphics.FromImage(bmp);
Rectangle rect = new Rectangle(0, 0, width, height);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
g.DrawImage(bmp, rect);
return bmp;
}
catch (Exception ex)
{
return bmp;
}
}

 
  

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
相关资源
相似解决方案