Exemple #1
0
        /// <summary>
        /// Retrieves information about the supplied JPEG.
        /// </summary>
        /// <param name="libHandle">The NvJPEG library handle.</param>
        /// <param name="imageBytes">The JPEG image bytes.</param>
        /// <param name="numComponents">Filled in with the number of components.</param>
        /// <param name="subsampling">Filled in with the subsampling.</param>
        /// <param name="widths">Filled in with the widths.</param>
        /// <param name="heights">Filled in with the heights.</param>
        /// <returns>The error code.</returns>
        public unsafe NvJpegStatus GetImageInfo(
            IntPtr libHandle,
            ReadOnlySpan <byte> imageBytes,
            out int numComponents,
            out NvJpegChromaSubsampling subsampling,
            out int[] widths,
            out int[] heights)
        {
            widths  = new int[NvJpegConstants.NVJPEG_MAX_COMPONENT];
            heights = new int[NvJpegConstants.NVJPEG_MAX_COMPONENT];

            fixed(byte *imageBytesPtr = imageBytes)
            fixed(int *widthsPtr  = widths)
            fixed(int *heightsPtr = heights)
            {
                return(GetImageInfo(
                           libHandle,
                           imageBytesPtr,
                           (ulong)imageBytes.Length,
                           out numComponents,
                           out subsampling,
                           widthsPtr,
                           heightsPtr));
            }
        }
Exemple #2
0
 /// <inheritdoc cref="NvJpegAPI.GetImageInfo(
 ///     IntPtr,
 ///     ReadOnlySpan{byte},
 ///     out int,
 ///     out NvJpegChromaSubsampling,
 ///     out int[],
 ///     out int[])"/>
 public unsafe NvJpegStatus GetImageInfo(
     ReadOnlySpan <byte> imageBytes,
     out int numComponents,
     out NvJpegChromaSubsampling subsampling,
     out int[] widths,
     out int[] heights) =>
 API.GetImageInfo(
     LibHandle,
     imageBytes,
     out numComponents,
     out subsampling,
     out widths,
     out heights);