getData method

Uint8List getData()

Gets the image buffer data.

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

Implementation

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