图片工具 -ImgUtil
# 简介
# EasyTool.ImgUtil 类
ResizeImage
: 缩放图片CropImage
: 剪裁图片ConvertImageFormat
:将 图片转换为指定 格式 ConvertToBlackAndWhite
:将 彩色 图片转换为黑白 图片AddTextWatermark
:在 图片上 添加 文字 水 印 AddImageWatermark
:在 图片上 添加 图片水 印 RotateImage
: 旋转图片FlipImageHorizontally
:水平 翻 转图片
# ResizeImage-缩放图片
/// <summary>
/// 缩放图片
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="width">缩放后 的 宽度</param>
/// <param name="height">缩放后 的 高度 </param>
/// <returns>缩放后 的 图片</returns>
public static Image ResizeImage(Image img, int width, int height)
# CropImage-剪裁图片
/// <summary>
/// 剪裁图片
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="x">剪裁起 始 横 坐 标</param>
/// <param name="y">剪裁起 始 纵坐标</param>
/// <param name="width">剪裁宽度</param>
/// <param name="height">剪裁高度 </param>
/// <returns>剪裁后 的 图片</returns>
public static Image CropImage(Image img, int x, int y, int width, int height)
# ConvertImageFormat-将 图片转换为指定 格式
/// <summary>
/// 将 图片转换为指定 格式
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="format">目 标格式 </param>
/// <returns>转换后 的 图片</returns>
public static Image ConvertImageFormat(Image img, ImageFormat format)
# ConvertToBlackAndWhite-将 彩色 图片转换为黑白 图片
/// <summary>
/// 将 彩色 图片转换为黑白 图片
/// </summary>
/// <param name="img">原始 图片</param>
/// <returns>转换后 的 图片</returns>
public static Image ConvertToBlackAndWhite(Image img)
# AddTextWatermark-在 图片上 添加 文字 水 印
/// <summary>
/// 在 图片上 添加 文字 水 印
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="text">水 印 文字 </param>
/// <param name="font">水 印字 体 </param>
/// <param name="brush">水 印 笔刷</param>
/// <param name="x">水 印 起 始 横 坐 标</param>
/// <param name="y">水 印 起 始 纵坐标</param>
/// <returns>添加 水 印 后 的 图片</returns>
public static Image AddTextWatermark(Image img, string text, Font font, Brush brush, int x, int y)
# AddImageWatermark-在 图片上 添加 图片水 印
/// <summary>
/// 在 图片上 添加 图片水 印
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="watermark">水 印 图片</param>
/// <param name="opacity">水 印 透明 度 </param>
/// <param name="x">水 印 起 始 横 坐 标</param>
/// <param name="y">水 印 起 始 纵坐标</param>
/// <returns>添加 水 印 后 的 图片</returns>
public static Image AddImageWatermark(Image img, Image watermark, float opacity, int x, int y)
# RotateImage-旋转图片
/// <summary>
/// 旋转图片
/// </summary>
/// <param name="img">原始 图片</param>
/// <param name="angle">旋转角度 </param>
/// <returns>旋转后 的 图片</returns>
public static Image RotateImage(Image img, float angle)
# FlipImageHorizontally-水平 翻 转图片
/// <summary>
/// 水平 翻 转图片
/// </summary>
/// <param name="img">原始 图片</param>
/// <returns>翻 转后的 图片</returns>
public static Image FlipImageHorizontally(Image img)