92public class Hdr : IDisposable, IHasSafeHandle
94 private readonly Handle _handle;
95 private bool _disposed;
107 _handle =
new Handle();
124 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_HDR_GetAlgorithm(_handle, out algorithm));
135 GC.SuppressFinalize(
this);
138 SafeHandle IHasSafeHandle.Handle => _handle;
201 throw new ArgumentNullException(nameof(images));
204 Image[] imageArray = images.ToArray();
205 if (imageArray.Length == 0)
207 throw new ArgumentException(
"The image collection must not be empty.", nameof(images));
210 IntPtr[] imageHandles = imageArray.Select(img => img._handle.DangerousGetHandle()).ToArray();
212 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_HDR_EstimateResponseCurve(
215 (nuint) imageHandles.Length));
271 Image[] imageArray = images.ToArray();
272 if (imageArray.Length == 0)
277 Image refImage = imageArray.First();
280 IntPtr[] imageHandles = imageArray.Select(img => img._handle.DangerousGetHandle()).ToArray();
282 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_HDR_Process_GetOutputPixelFormat(
285 out outputPixelFormat));
287 Image outputImage =
new(
291 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_HDR_Process(
294 (nuint) imageHandles.Length,
295 outputImage._handle));
303 protected virtual void Dispose(
bool disposing)
318 private void ThrowIfDisposed()
326 internal sealed class Handle : SafeHandleZeroOrMinusOneIsInvalid
328 internal Handle() : base(true)
330 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_HDR_Create(out handle));
333 protected override bool ReleaseHandle()
335 return CInterface.peak_icv_HDR_Destroy(handle) == 0;
339 private static class CInterface
341 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
342 public static extern Backend.Types.peak_icv_status peak_icv_HDR_Create(
343 out IntPtr hdr_handle);
345 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
346 public static extern Backend.Types.peak_icv_status peak_icv_HDR_Destroy(
349 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
350 public static extern Backend.Types.peak_icv_status peak_icv_HDR_GetAlgorithm(
354 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
355 public static extern Backend.Types.peak_icv_status peak_icv_HDR_EstimateResponseCurve(
357 [In] IntPtr[] image_handles,
360 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
361 public static extern Backend.Types.peak_icv_status peak_icv_HDR_Process_GetOutputPixelFormat(
366 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
367 public static extern Backend.Types.peak_icv_status peak_icv_HDR_Process(
369 [In] IntPtr[] image_handles,
371 Image.Handle output_image_handle);