public IntPtr GetPlane(HeifChannel channel, out int stride) { var data = NativeMethods.HeifImage_GetPlane(this.Instance, (UIntPtr)channel, out UIntPtr stridePtr); stride = (int)stridePtr.ToUInt32(); return(data); }
/// <summary> /// Initializes a new instance of the <see cref="HeifPlaneData"/> class. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="stride">The stride.</param> /// <param name="channel">The channel.</param> /// <param name="scan0">The starting address of the image data.</param> internal HeifPlaneData(int width, int height, int stride, HeifChannel channel, IntPtr scan0) { this.Width = width; this.Height = height; this.Stride = stride; this.Channel = channel; this.Scan0 = scan0; }
public void ShouldReturnThePlane(HeifChannel channel, int stride) { using (var image = HeifImage.Decode(TestFiles.Camel)) { var plane = image.GetPlane(channel); Assert.Equal(stride, plane.Stride); Assert.NotEqual(IntPtr.Zero, plane.Data); } }
/// <summary> /// Adds a plane to the image. /// </summary> /// <param name="channel">The channel.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitDepth">The bit depth.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="width"/> is less than or equal to zero. /// /// -or- /// /// <paramref name="height"/> is less than or equal to zero. /// /// -or- /// /// <paramref name="bitDepth"/> is less than or equal to zero. /// </exception> /// <exception cref="HeifException">A LibHeif error occurred.</exception> /// <exception cref="ObjectDisposedException">The object has been disposed.</exception> public void AddPlane(HeifChannel channel, int width, int height, int bitDepth) { Validate.IsPositive(width, nameof(width)); Validate.IsPositive(height, nameof(height)); Validate.IsPositive(bitDepth, nameof(bitDepth)); VerifyNotDisposed(); var error = LibHeifNative.heif_image_add_plane(this.image, channel, width, height, bitDepth); error.ThrowIfError(); }
/// <summary> /// Gets the image data for the specified plane. /// </summary> /// <param name="channel">The channel.</param> /// <returns>The image plane data.</returns> /// <exception cref="HeifException">The image does not contain the specified channel.</exception> /// <exception cref="ObjectDisposedException">The object has been disposed.</exception> public HeifPlaneData GetPlane(HeifChannel channel) { VerifyNotDisposed(); if (!LibHeifNative.heif_image_has_channel(this.image, channel)) { ExceptionUtil.ThrowHeifException(Resources.ImageDoesNotContainChannel); } int width = LibHeifNative.heif_image_get_width(this.image, channel); int height = LibHeifNative.heif_image_get_height(this.image, channel); var scan0 = LibHeifNative.heif_image_get_plane(this.image, channel, out int stride); if (scan0 == IntPtr.Zero || width == -1 || height == -1) { ExceptionUtil.ThrowHeifException(Resources.ImageDoesNotContainChannel); } return(new HeifPlaneData(width, height, stride, channel, scan0)); }
public static extern IntPtr HeifImageGetPlaneReadonly(HeifImagePointer image, HeifChannel channel, ref int outStride);
public static extern int HeifImageGetBitsPerPixelRange(HeifImagePointer img, HeifChannel channel);
public static extern int HeifImageGetHeight(HeifImagePointer img, HeifChannel channel);
internal static extern bool heif_image_has_channel(SafeHeifImage handle, HeifChannel channel);
internal static extern IntPtr heif_image_get_plane(SafeHeifImage handle, HeifChannel channel, out int planeStride);
internal static extern int heif_image_get_height(SafeHeifImage handle, HeifChannel channel);
internal static extern heif_error heif_image_add_plane(SafeHeifImage image, HeifChannel channel, int width, int height, int bitDepth);
/// <summary> /// Determines whether this image contains the specified channel. /// </summary> /// <param name="channel">The channel.</param> /// <returns> /// <see langword="true"/> this image contains the specified channel; otherwise, <see langword="false"/>. /// </returns> /// <exception cref="ObjectDisposedException">The object has been disposed.</exception> public bool HasChannel(HeifChannel channel) { VerifyNotDisposed(); return(LibHeifNative.heif_image_has_channel(this.image, channel)); }
/// <summary> /// Returns the plane for the specified channel. /// </summary> /// <param name="channel">The channel to get the plane for.</param> /// <returns>The plane for the specified channel.</returns> public HeifPlane GetPlane(HeifChannel channel) { var data = this.nativeInstance.GetPlane(channel, out int stride); return(new HeifPlane(data, stride)); }