.. index:: 
  !Portrait.toBuffer Method
  
.. _id3_face_portrait_to_buffer_class_method:

===============================================================================
Portrait.toBuffer Method
===============================================================================

Module: :ref:`Portrait<id3_face_portrait_class>`

Definition
----------

Exports the portrait to a buffer.


.. tab-set::

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

      .. code:: Python

        to_buffer(self) -> bytearray

      **Returns**

        .. line-block::

          ``bytearray``
          The buffer to which the portrait object is exported.

      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        Uint8List toBuffer()

      **Returns**

        .. line-block::

          ``Uint8List``
          The buffer to which the portrait object is exported.

      **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 byte[] ToBuffer()

      **Returns**

        .. line-block::

          ``byte[]``
          The buffer to which the portrait object is exported.

      **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 byte[] toBuffer() throws FaceException

      **Returns**

        .. line-block::

          ``byte[]``
          The buffer to which the portrait object is exported.

      **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 toBuffer() throws -> [UInt8]

      **Returns**

        .. line-block::

          ``[UInt8]``
          The buffer to which the portrait object is exported.

      **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 id3FacePortrait_ToBuffer (
            ID3_FACE_PORTRAIT hPortrait, 
            unsigned char * data, 
            int * dataSize)

      **Parameters**

        .. line-block::

          ``hPortrait`` :ref:`ID3_FACE_PORTRAIT<id3_face_portrait_class>`
          :guilabel:`in` Handle to the Portrait object.

          ``data`` unsigned char *
          :guilabel:`out` The buffer to which the portrait object is exported.

          ``dataSize`` int *
          :guilabel:`in` Size of the 'data' buffer. Receives the number of elements in the 'data' array.


      **Returns**

        .. line-block::

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


