예제 #1
0
        /// <returns>
        ///   The number of channels for a <paramref name="format" />.
        ///   If channels don't make sense in the <paramref name="format" />, returns <c>0</c>.
        /// </returns>
        /// <remarks>
        ///   Unlike the original implementation, this API won't signal SIGABRT.
        /// </remarks>
        public static int NumberOfChannelsForFormat(ImageFormat.Types.Format format)
        {
            switch (format)
            {
            case ImageFormat.Types.Format.Srgb:
            case ImageFormat.Types.Format.Srgb48:
                return(3);

            case ImageFormat.Types.Format.Srgba:
            case ImageFormat.Types.Format.Srgba64:
            case ImageFormat.Types.Format.Sbgra:
                return(4);

            case ImageFormat.Types.Format.Gray8:
            case ImageFormat.Types.Format.Gray16:
                return(1);

            case ImageFormat.Types.Format.Vec32F1:
                return(1);

            case ImageFormat.Types.Format.Vec32F2:
                return(2);

            case ImageFormat.Types.Format.Lab8:
                return(3);

            case ImageFormat.Types.Format.Ycbcr420P:
            case ImageFormat.Types.Format.Ycbcr420P10:
            case ImageFormat.Types.Format.Unknown:
            default:
                return(0);
            }
        }
예제 #2
0
        /// <returns>
        ///   The channel size for a <paramref name="format" />.
        ///   If channels don't make sense in the <paramref name="format" />, returns <c>0</c>.
        /// </returns>
        /// <remarks>
        ///   Unlike the original implementation, this API won't signal SIGABRT.
        /// </remarks>
        public static int ChannelSizeForFormat(ImageFormat.Types.Format format)
        {
            switch (format)
            {
            case ImageFormat.Types.Format.Srgb:
            case ImageFormat.Types.Format.Srgba:
            case ImageFormat.Types.Format.Sbgra:
                return(sizeof(byte));

            case ImageFormat.Types.Format.Srgb48:
            case ImageFormat.Types.Format.Srgba64:
                return(sizeof(ushort));

            case ImageFormat.Types.Format.Gray8:
                return(sizeof(byte));

            case ImageFormat.Types.Format.Gray16:
                return(sizeof(ushort));

            case ImageFormat.Types.Format.Vec32F1:
            case ImageFormat.Types.Format.Vec32F2:
                // sizeof float may be wrong since it's platform-dependent, but we assume that it's constant across all supported platforms.
                return(sizeof(float));

            case ImageFormat.Types.Format.Lab8:
                return(sizeof(byte));

            case ImageFormat.Types.Format.Ycbcr420P:
            case ImageFormat.Types.Format.Ycbcr420P10:
            case ImageFormat.Types.Format.Unknown:
            default:
                return(0);
            }
        }
예제 #3
0
 public ImageFrame(ImageFormat.Types.Format format, int width, int height, int widthStep, IntPtr pixelData, Deleter deleter) : base()
 {
     unsafe
     {
         UnsafeNativeMethods.mp_ImageFrame__ui_i_i_i_Pui8_PF(format, width, height, widthStep, pixelData, deleter, out var ptr).Assert();
         this.ptr = ptr;
     }
 }
예제 #4
0
 public static extern MpReturnCode mp_ImageFrame__ui_i_i_i_Pui8_PF(
     ImageFormat.Types.Format format, int width, int height, int widthStep, IntPtr pixelData,
     [MarshalAs(UnmanagedType.FunctionPtr)] ImageFrame.Deleter deleter, out IntPtr imageFrame);
예제 #5
0
 public static extern MpReturnCode mp_ImageFrame__ui_i_i_ui(
     ImageFormat.Types.Format format, int width, int height, uint alignmentBoundary, out IntPtr imageFrame);
예제 #6
0
 /// <summary>
 ///   Initialize an <see cref="ImageFrame" />.
 /// </summary>
 /// <remarks>
 ///   <paramref name="pixelData" /> won't be released if the instance is disposed of.<br />
 ///   It's useful when:
 ///   <list type="bullet">
 ///     <item>
 ///       <description>You can reuse the memory allocated to <paramref name="pixelData" />.</description>
 ///     </item>
 ///     <item>
 ///       <description>You've not allocated the memory (e.g. <see cref="Texture2D.GetRawTextureData" />).</description>
 ///     </item>
 ///   </list>
 /// </remarks>
 public ImageFrame(ImageFormat.Types.Format format, int width, int height, int widthStep, NativeArray <byte> pixelData)
     : this(format, width, height, widthStep, pixelData, VoidDeleter)
 {
 }
예제 #7
0
 public unsafe ImageFrame(ImageFormat.Types.Format format, int width, int height, int widthStep, NativeArray <byte> pixelData, Deleter deleter)
     : this(format, width, height, widthStep, (IntPtr)NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(pixelData), deleter)
 {
 }
예제 #8
0
 public ImageFrame(ImageFormat.Types.Format format, int width, int height, uint alignmentBoundary) : base()
 {
     UnsafeNativeMethods.mp_ImageFrame__ui_i_i_ui(format, width, height, alignmentBoundary, out var ptr).Assert();
     this.ptr = ptr;
 }
예제 #9
0
 public ImageFrame(ImageFormat.Types.Format format, int width, int height) : this(format, width, height, DefaultAlignmentBoundary)
 {
 }
 public static extern ImageFormat.Types.Format mp__GpuBufferFormatForImageFormat__ui(ImageFormat.Types.Format format);