.. index:: 
  !DocumentImage.toBufferObject Method
  
.. _id3_document_document_image_to_buffer_object_class_method:

===============================================================================
DocumentImage.toBufferObject Method
===============================================================================

Module: :ref:`DocumentImage<id3_document_document_image_class>`

Definition
----------

Copies the image to a buffer in the specified format.

The compression level meaning depends on the algorithm used:

- For JPEG compression, the value is the expected quality and may vary from 1 to 100.

- For JPEG2000 compression, the value is the compression rate and may vary from 1 to 512.

- For PNG compression, the value is the compression rate and may vary from 1 to 10.

- For all other formats, the value is ignored.


.. tab-set::

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

      .. code:: Python

        to_buffer_object(self, document_image_format: ImageFormat, compression_level: float, buffer: ImageBuffer) -> None

      **Parameters**

        .. line-block::

          ``document_image_format`` :ref:`ImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compression_level`` float
          :guilabel:`in` The compression level to be applied.

          ``buffer`` :ref:`ImageBuffer<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        void toBufferObject(ImageFormat documentImageFormat, double compressionLevel, ImageBuffer buffer)

      **Parameters**

        .. line-block::

          ``documentImageFormat`` :ref:`ImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compressionLevel`` double
          :guilabel:`in` The compression level to be applied.

          ``buffer`` :ref:`ImageBuffer<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **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 void ToBufferObject(ImageFormat documentImageFormat, float compressionLevel, ImageBuffer buffer)

      **Parameters**

        .. line-block::

          ``documentImageFormat`` :ref:`ImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compressionLevel`` float
          :guilabel:`in` The compression level to be applied.

          ``buffer`` :ref:`ImageBuffer<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **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 void toBufferObject(ImageFormat documentImageFormat, float compressionLevel, ImageBuffer buffer) throws DocumentException

      **Parameters**

        .. line-block::

          ``documentImageFormat`` :ref:`ImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compressionLevel`` float
          :guilabel:`in` The compression level to be applied.

          ``buffer`` :ref:`ImageBuffer<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **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 func toBufferObject(documentImageFormat: ImageFormat, compressionLevel: Float, buffer: ImageBuffer) throws

      **Parameters**

        .. line-block::

          ``documentImageFormat`` :ref:`ImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compressionLevel`` Float
          :guilabel:`in` The compression level to be applied.

          ``buffer`` :ref:`ImageBuffer<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **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_ToBufferObject (
            ID3_DOCUMENT_IMAGE hDocumentImage, 
            id3DocumentImageFormat eDocumentImageFormat, 
            float compressionLevel, 
            ID3_DOCUMENT_IMAGE_BUFFER hBuffer)

      **Parameters**

        .. line-block::

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

          ``eDocumentImageFormat`` :ref:`id3DocumentImageFormat<id3_document_image_format_enum>`
          :guilabel:`in` The output image format.

          ``compressionLevel`` float
          :guilabel:`in` The compression level to be applied.

          ``hBuffer`` :ref:`ID3_DOCUMENT_IMAGE_BUFFER<id3_document_image_buffer_class>`
          :guilabel:`in` The image buffer that receives the image data.


      **Returns**

        .. line-block::

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


