.. index:: 
  !Image.toBufferObject Method
  
.. _id3_face_image_to_buffer_object_class_method:

===============================================================================
Image.toBufferObject Method
===============================================================================

Module: :ref:`Image<id3_face_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, image_format: ImageFormat, compression_level: float, buffer: ImageBuffer) -> None

      **Parameters**

        .. line-block::

          ``image_format`` :ref:`ImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

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

      **Parameters**

        .. line-block::

          ``imageFormat`` :ref:`ImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


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

      **Parameters**

        .. line-block::

          ``imageFormat`` :ref:`ImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


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

      **Parameters**

        .. line-block::

          ``imageFormat`` :ref:`ImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


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

      **Parameters**

        .. line-block::

          ``imageFormat`` :ref:`ImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


      **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_ToBufferObject (
            ID3_FACE_IMAGE hImage, 
            id3FaceImageFormat eImageFormat, 
            float compressionLevel, 
            ID3_FACE_IMAGE_BUFFER hBuffer)

      **Parameters**

        .. line-block::

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

          ``eImageFormat`` :ref:`id3FaceImageFormat<id3_face_image_format_enum>`
          :guilabel:`in` The output image format.

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

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


      **Returns**

        .. line-block::

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


