/// <summary> /// Creates a new collection of <see cref="HeifImage"/> from the specified data. /// </summary> /// <param name="input">The data to load the image from.</param> /// <returns>A new <see cref="HeifImage"/> instance.</returns> public static IHeifImageCollection DecodeCollection(byte[] input) { var result = new HeifImageCollection(); HeifImageHandle?handle = null; try { using (var context = new HeifContext(input)) { foreach (var imageId in context.GetImageIds()) { handle = new HeifImageHandle(context, imageId); result.Add(new HeifImage(context, handle)); } } } catch { foreach (var image in result) { image.Dispose(); } handle?.Dispose(); throw; } return(result); }
private HeifImage(HeifContext context, HeifImageHandle handle) { this.context = context; this.handle = handle; this.nativeInstance = new NativeHeifImage(handle); this.Metadata = new HeifMetadata(this.nativeInstance.Width, this.nativeInstance.Height); }
internal static IntPtr GetInstance(HeifContext context) { if (context == null) { return(IntPtr.Zero); } return(context.nativeInstance.Instance); }
/// <summary> /// Creates a new <see cref="HeifMetadata"/> from the specified data. /// </summary> /// <param name="input">The data to load the metadata from.</param> /// <returns>A new <see cref="HeifMetadata"/>.</returns> public static HeifMetadata GetMetadata(byte[] input) { using (var context = new HeifContext(input)) { using (var handle = new HeifImageHandle(context)) { return(handle.ToMetadata()); } } }
public NativeHeifImageHandle(HeifContext context, uint imageId) { var instance = NativeMethods.HeifImageHandle_CreateById(HeifContext.GetInstance(context), imageId); if (instance == IntPtr.Zero) { throw new HeifException("Unable to load heif image handle."); } this.Instance = instance; }
/// <summary> /// Creates a new collection of <see cref="HeifMetadata"/> from the specified data. /// </summary> /// <param name="input">The data to load the metadata from.</param> /// <returns>A new <see cref="HeifMetadata"/>.</returns> public static IReadOnlyCollection <HeifMetadata> GetCollectionMetadata(byte[] input) { using (var context = new HeifContext(input)) { var result = new List <HeifMetadata>(); foreach (var imageId in context.GetImageIds()) { using (var handle = new HeifImageHandle(context, imageId)) { result.Add(handle.ToMetadata()); } } return(result); } }
/// <summary> /// Creates a new <see cref="HeifImage"/> from the specified data. /// </summary> /// <param name="input">The data to load the image from.</param> /// <returns>A new <see cref="HeifImage"/> instance.</returns> public static HeifImage Decode(byte[] input) { HeifContext? context = null; HeifImageHandle?handle = null; try { context = new HeifContext(input); handle = new HeifImageHandle(context); return(new HeifImage(context, handle)); } catch { handle?.Dispose(); context?.Dispose(); throw; } }
public HeifImageHandle(HeifContext context) { this.nativeInstance = new NativeHeifImageHandle(context); }
public HeifImageHandle(HeifContext context, uint imageId) { this.nativeInstance = new NativeHeifImageHandle(context, imageId); context.AddReference(); }