.. index:: 
  !Image.fromBuffer Method
  
.. _id3_face_image_from_buffer_class_method:

===============================================================================
Image.fromBuffer Method
===============================================================================

Module: :ref:`Image<id3_face_image_class>`

Definition
----------

Creates an Image from the specified data buffer.


.. tab-set::

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

      .. code:: Python

        @staticmethod
        from_buffer(data: bytearray, pixel_format: PixelFormat) -> Image

      **Parameters**

        .. line-block::

          ``data`` bytearray
          :guilabel:`in` A buffer that contains the image data.

          ``pixel_format`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **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 fromBuffer(Uint8List? data, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

          ``data`` Uint8List
          :guilabel:`in` A buffer that contains the image data.

          ``pixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **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 FromBuffer(byte[] data, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

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

          ``pixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **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 fromBuffer(byte[] data, PixelFormat pixelFormat) throws FaceException

      **Parameters**

        .. line-block::

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

          ``pixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **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 fromBuffer(data: [UInt8], pixelFormat: PixelFormat) throws -> Image

      **Parameters**

        .. line-block::

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

          ``pixelFormat`` :ref:`PixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **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_FromBuffer (
            ID3_FACE_IMAGE hImage, 
            unsigned char * data, 
            int dataSize, 
            id3FacePixelFormat ePixelFormat)

      **Parameters**

        .. line-block::

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

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

          ``dataSize`` int
          :guilabel:`in` Size of the 'data' buffer.

          ``ePixelFormat`` :ref:`id3FacePixelFormat<id3_face_pixel_format_enum>`
          :guilabel:`in` The destination pixel format to convert the input to.


      **Returns**

        .. line-block::

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


