getData method

Uint8List getData()

Gets the raw data buffer of the image.

return Raw data buffer of the image. 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.id3DocumentImage_GetData(_pHandle.value, pData, pDataSize);
    if (err == DocumentError.insufficientBuffer.value) {
      pData = calloc.allocate(pDataSize.value);
      err = documentSDK.id3DocumentImage_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);
  }
}