C#截取图片代码分享
今天楼主在练习WPF,刚好遇到截取图片,代码发放/// <summary>
/// 截取图片
/// </summary>
/// <param name="imgaddress">文件名(包括地址+扩展名)</param>
/// <param name="x">左上角点X</param>
/// <param name="y">左上角点Y</param>
/// <param name="width">截取的图片宽</param>
/// <param name="height">截取的图片高</param>
/// <returns>截取后图片数据源</returns>
private BitmapSource cutImage(string imgaddress, int x, int y, int width, int height)
{
return new CroppedBitmap(
BitmapFrame.Create(new Uri(imgaddress, UriKind.Relative)),
new Int32Rect(x, y, width, height)
);
}
拿去直接调用,
多谢分享
页:
[1]