IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
CalibrationPlate.cs
Go to the documentation of this file.
1using System.Runtime.InteropServices;
3using Microsoft.Win32.SafeHandles;
4
6
16public class CalibrationPlate : IDisposable, IHasSafeHandle
17{
18 internal readonly Handle _handle;
19
44 public CalibrationPlate(string filePath)
45 {
46 _handle = new Handle(filePath);
47 }
48
53 public void Dispose()
54 {
55 _handle.Dispose();
56 GC.SuppressFinalize(this);
57 }
58
59 SafeHandle IHasSafeHandle.Handle => _handle;
60
61 internal sealed class Handle : SafeHandleZeroOrMinusOneIsInvalid
62 {
63 internal Handle(string filePath) : base(true)
64 {
65 DllHelper.ExecuteAndMapReturnCodes(() =>
66 CInterface.peak_icv_Calibration_Plate_CreateFromFile(out handle,
67 Utils.ToUtf8(filePath)));
68 }
69
70 protected override bool ReleaseHandle()
71 {
72 return CInterface.peak_icv_Calibration_Plate_Destroy(handle) ==
73 Backend.Types.peak_icv_status.PEAK_ICV_STATUS_SUCCESS;
74 }
75 }
76
77 private static class CInterface
78 {
79 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
80 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Plate_Destroy(
81 IntPtr calibration_plate_handle);
82
83 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
84 public static extern Backend.Types.peak_icv_status peak_icv_Calibration_Plate_CreateFromFile(
85 out IntPtr calibration_plate_handle, byte[] filePath);
86 }
87}
Calibration plate representation holding the world coordinates of the reference points on a calibrati...
CalibrationPlate(string filePath)
Initializes the object by loading world coordinates from a description file.
void Dispose()
Releases the resources used by the CalibrationPlate class.