.. index:: 
  !DocumentImage.fromBuffer Method
  
.. _id3_document_document_image_from_buffer_class_method:

===============================================================================
DocumentImage.fromBuffer Method
===============================================================================

Module: :ref:`DocumentImage<id3_document_document_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) -> DocumentImage

      **Parameters**

        .. line-block::

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

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


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Dart

        static DocumentImage fromBuffer(Uint8List? data, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

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

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


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: C#

        public static DocumentImage FromBuffer(byte[] data, PixelFormat pixelFormat)

      **Parameters**

        .. line-block::

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

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


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Java

        public static DocumentImage fromBuffer(byte[] data, PixelFormat pixelFormat) throws DocumentException

      **Parameters**

        .. line-block::

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

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


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Swift

        public static func fromBuffer(data: [UInt8], pixelFormat: PixelFormat) throws -> DocumentImage

      **Parameters**

        .. line-block::

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

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


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The newly created document image.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: C

        int id3DocumentImage_FromBuffer (
            ID3_DOCUMENT_IMAGE hDocumentImage, 
            unsigned char * data, 
            int dataSize, 
            id3DocumentPixelFormat ePixelFormat)

      **Parameters**

        .. line-block::

          ``hDocumentImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` Handle to the DocumentImage object.

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

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

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


      **Returns**

        .. line-block::

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


