72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using Maxwell.SemiFramework.DefaultConfig.Vision;
|
|
using MwFramework.Device.Model;
|
|
using SemiconductorVisionAlgorithm.SemiParams;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MainShell.Models
|
|
{
|
|
public sealed class MxImage : IDisposable
|
|
{
|
|
|
|
private readonly Camera _image = null;
|
|
public Camera Image => _image;
|
|
public MxImage(Camera image)
|
|
{
|
|
_image = image;
|
|
}
|
|
public MxImage(CameraData cameraData)
|
|
{
|
|
_image = new Camera
|
|
{
|
|
Ptr = ImageHelper.GetImageHandle(cameraData),
|
|
Height = (int)cameraData.Height,
|
|
Width = (int)cameraData.Width,
|
|
Type = "byte"
|
|
};
|
|
}
|
|
|
|
|
|
|
|
private bool disposedValue;
|
|
|
|
private void Dispose(bool disposing)
|
|
{
|
|
if (!disposedValue)
|
|
{
|
|
if (disposing)
|
|
{
|
|
// TODO: 释放托管状态(托管对象)
|
|
}
|
|
|
|
// TODO: 释放未托管的资源(未托管的对象)并重写终结器
|
|
// TODO: 将大型字段设置为 null
|
|
if (_image.Ptr != null)
|
|
{
|
|
Marshal.FreeHGlobal(_image.Ptr);
|
|
_image.Ptr = IntPtr.Zero;
|
|
}
|
|
disposedValue = true;
|
|
}
|
|
}
|
|
|
|
// // TODO: 仅当“Dispose(bool disposing)”拥有用于释放未托管资源的代码时才替代终结器
|
|
// ~MxImage()
|
|
// {
|
|
// // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
|
|
// Dispose(disposing: false);
|
|
// }
|
|
|
|
public void Dispose()
|
|
{
|
|
// 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
|
|
Dispose(disposing: true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|
|
}
|