.. index:: 
  !Image.fromRawBuffer Method
  
.. _id3_face_image_from_raw_buffer_class_method:

===============================================================================
Image.fromRawBuffer Method
===============================================================================

Module: :ref:`Image<id3_face_image_class>`

Definition
----------

Creates an Image from the specified raw data buffer.


.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

        @staticmethod
        from_raw_buffer(pixels: bytearray, width: int, height: int, stride: int, src_pixel_format: PixelFormat, dst_pixel_format: PixelFormat) -> Image

      **Parameters**

        .. line-block::

          ``pixels`` bytearray
          :guilabel:`in` A buffer that contains image pixels.

          ``width`` int
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` int
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` int
          :guilabel:`in` The stride, in pixels, of the image.

          ``src_pixel_format`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``dst_pixel_format`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The newly created image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

        static Image fromRawBuffer(Uint8List? pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat)

      **Parameters**

        .. line-block::

          ``pixels`` Uint8List
          :guilabel:`in` A buffer that contains image pixels.

          ``width`` int
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` int
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` int
          :guilabel:`in` The stride, in pixels, of the image.

          ``srcPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``dstPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The newly created image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: C#
      :sync: C#

      .. code:: C#

        public static Image FromRawBuffer(byte[] pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat)

      **Parameters**

        .. line-block::

          ``pixels`` byte[]
          :guilabel:`in` A buffer that contains image pixels.

          ``width`` int
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` int
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` int
          :guilabel:`in` The stride, in pixels, of the image.

          ``srcPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``dstPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The newly created image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Java
      :sync: Java

      .. code:: Java

        public static Image fromRawBuffer(byte[] pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat) throws FaceException

      **Parameters**

        .. line-block::

          ``pixels`` byte[]
          :guilabel:`in` A buffer that contains image pixels.

          ``width`` int
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` int
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` int
          :guilabel:`in` The stride, in pixels, of the image.

          ``srcPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``dstPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The newly created image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

        public static func fromRawBuffer(pixels: [UInt8], width: Int32, height: Int32, stride: Int32, srcPixelFormat: PixelFormat, dstPixelFormat: PixelFormat) throws -> Image

      **Parameters**

        .. line-block::

          ``pixels`` [UInt8]
          :guilabel:`in` A buffer that contains image pixels.

          ``width`` Int32
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` Int32
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` Int32
          :guilabel:`in` The stride, in pixels, of the image.

          ``srcPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``dstPixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The newly created image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: C
      :sync: C

      .. code:: C

        int id3FaceImage_FromRawBuffer (
            ID3_FACE_IMAGE hImage, 
            unsigned char * pixels, 
            int pixelsSize, 
            int width, 
            int height, 
            int stride, 
            id3FacePixelFormat eSrcPixelFormat, 
            id3FacePixelFormat eDstPixelFormat)

      **Parameters**

        .. line-block::

          ``hImage`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`in` Handle to the Image object.

          ``pixels`` unsigned char *
          :guilabel:`in` A buffer that contains image pixels.

          ``pixelsSize`` int
          :guilabel:`in` Size of the 'pixels' buffer.

          ``width`` int
          :guilabel:`in` The width, in pixels, of the image.

          ``height`` int
          :guilabel:`in` The height, in pixels, of the image.

          ``stride`` int
          :guilabel:`in` The stride, in pixels, of the image.

          ``eSrcPixelFormat`` :ref:`id3FacePixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

          ``eDstPixelFormat`` :ref:`id3FacePixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The pixel format into which to convert the input image.


      **Returns**

        .. line-block::

          ``int``
          An error code.
          See :ref:`id3FaceError<id3_face_face_error_enum>` file for the list of possible error codes.


