/// <summary>
/// 获取一张图片中的一部分 (.png图片是可行的,其余格式暂时还没有测试过)
/// </summary>
/// <param name="ImgUri">图片路径</param>
/// <param name="XCoordinate">要截取部分的X坐标</param>
/// <param name="YCoordinate">要截取部分的Y坐标</param>
/// <param name="Width">截取的宽度</param>
/// <param name="Height">截取的高度</param>
/// <returns></returns>
public static BitmapSource GetPartImage(string ImgUri, int XCoordinate, int YCoordinate, int Width, int Height)
{
return new CroppedBitmap(BitmapFrame.Create(new Uri(ImgUri, UriKind.Relative)), new Int32Rect(XCoordinate, YCoordinate, Width, Height));
}
/// 获取一张图片中的一部分 (.png图片是可行的,其余格式暂时还没有测试过)
/// </summary>
/// <param name="ImgUri">图片路径</param>
/// <param name="XCoordinate">要截取部分的X坐标</param>
/// <param name="YCoordinate">要截取部分的Y坐标</param>
/// <param name="Width">截取的宽度</param>
/// <param name="Height">截取的高度</param>
/// <returns></returns>
public static BitmapSource GetPartImage(string ImgUri, int XCoordinate, int YCoordinate, int Width, int Height)
{
return new CroppedBitmap(BitmapFrame.Create(new Uri(ImgUri, UriKind.Relative)), new Int32Rect(XCoordinate, YCoordinate, Width, Height));
}