getData method

Uint8List getData()

Gets the image buffer data.

return Data of the image buffer object. throws FaceException An error has occurred during Face Library execution.

Implementation

Uint8List getData() {
  Pointer<UnsignedChar> pData = nullptr;
  Pointer<Int> pDataSize = calloc();
  pDataSize[0] = -1;
  try {
    var err = faceSDK.id3FaceImageBuffer_GetData(_pHandle.value, pData, pDataSize);
    if (err == FaceError.insufficientBuffer.value) {
      pData = calloc.allocate(pDataSize.value);
      err = faceSDK.id3FaceImageBuffer_GetData(_pHandle.value, pData, pDataSize);
    }
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vData = Uint8List.fromList(pData.cast<Uint8>().asTypedList(pDataSize.value));
    return vData;
  } finally {
    calloc.free(pData);
    calloc.free(pDataSize);
  }
}