.. index:: 
  !DocumentImage.fromRawBuffer Method
  
.. _id3_document_document_image_from_raw_buffer_class_method:

===============================================================================
DocumentImage.fromRawBuffer Method
===============================================================================

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

      **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_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **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 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_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **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 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_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **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 fromRawBuffer(byte[] pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat) throws DocumentException

      **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_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **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 fromRawBuffer(pixels: [UInt8], width: Int32, height: Int32, stride: Int32, srcPixelFormat: PixelFormat, dstPixelFormat: PixelFormat) throws -> DocumentImage

      **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_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **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_FromRawBuffer (
            ID3_DOCUMENT_IMAGE hDocumentImage, 
            unsigned char * pixels, 
            int pixelsSize, 
            int width, 
            int height, 
            int stride, 
            id3DocumentPixelFormat eSrcPixelFormat, 
            id3DocumentPixelFormat eDstPixelFormat)

      **Parameters**

        .. line-block::

          ``hDocumentImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` Handle to the DocumentImage 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:`id3DocumentPixelFormat<id3_document_pixel_format_enum>`
          :guilabel:`in` The pixel format of the input image.

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


      **Returns**

        .. line-block::

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


