using System.Drawing;
using System.Windows.Media.Imaging;
using System.Drawing.Imaging;
namespace ConstRectCropImage
{
///
/// 图像处理工具类
///
public static class ImageUtility
{
public static BitmapImage BitmapToBitmapImage(Bitmap img)
{
BitmapImage bmpimg = new BitmapImage();
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
img.Save(ms, ImageFormat.Png);
bmpimg.BeginInit();
bmpimg.StreamSource = ms;
bmpimg.CacheOption = BitmapCacheOption.OnLoad;
bmpimg.EndInit();
bmpimg.Freeze();
ms.Dispose();
}
return bmpimg;
}
}
///
/// 图像裁切时保存的信息
///
public class ImgInfoForSegEntity
{
///
/// 图片ID
///
public string ImgId { get; set; } = string.Empty;
///
/// 图片路径
///
public string ImgLocalPath { get; set; } = string.Empty;
///
/// 裁切是否成功
///
public bool SegSucceed { get; set; } = false;
///
/// 裁切后,图像左上点在原始图像上的像素坐标x
///
public int Left { get; set; } = 0;
///
/// 裁切后,图像右下点在原始图像上的像素坐标x
///
public int Right { get; set; } = 0;
///
/// 裁切后,图像左上点在原始图像上的像素坐标y
///
public int Top { get; set; } = 0;
///
/// 裁切后,图像右下点在原始图像上的像素坐标y
///
public int Bottom { get; set; } = 0;
}
}