1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System.Drawing;
- using System.Windows.Media.Imaging;
- using System.Drawing.Imaging;
- namespace ConstRectCropImage
- {
- /// <summary>
- /// 图像处理工具类
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 图像裁切时保存的信息
- /// </summary>
- public class ImgInfoForSegEntity
- {
- /// <summary>
- /// 图片ID
- /// </summary>
- public string ImgId { get; set; } = string.Empty;
- /// <summary>
- /// 图片路径
- /// </summary>
- public string ImgLocalPath { get; set; } = string.Empty;
- /// <summary>
- /// 裁切是否成功
- /// </summary>
- public bool SegSucceed { get; set; } = false;
- /// <summary>
- /// 裁切后,图像左上点在原始图像上的像素坐标x
- /// </summary>
- public int Left { get; set; } = 0;
- /// <summary>
- /// 裁切后,图像右下点在原始图像上的像素坐标x
- /// </summary>
- public int Right { get; set; } = 0;
- /// <summary>
- /// 裁切后,图像左上点在原始图像上的像素坐标y
- /// </summary>
- public int Top { get; set; } = 0;
- /// <summary>
- /// 裁切后,图像右下点在原始图像上的像素坐标y
- /// </summary>
- public int Bottom { get; set; } = 0;
- }
- }
|