decodeRegion method

  1. @override
ImageWrapper decodeRegion(
  1. Rectangle rect,
  2. double sampleSize
)
override

Method is used to decode rectangle region in the image specified by rect. rect area to render Rectangle sampleSize if set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. Returns constructed bitmap

Example:

// Decode region with sample size 1 (full resolution)
ImageWrapper decodedImage = _decoder!.decodeRegion(sampleRect, 1);
print(
 "Decoded region: ${sampleRect.width}x${sampleRect.height} at sample size 1",
);

Implementation

@override
ImageWrapper decodeRegion(Rectangle rect, double sampleSize) {
    final _decodeRegionFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
        Pointer<Void> Function(Pointer<Void>, Pointer<Void>, Float),
        Pointer<Void> Function(Pointer<Void>, Pointer<Void>, double)
      >('navigine_sdk_flutter_BitmapRegionDecoder_decodeRegion__Rect_SampleSize'));
    final _rectHandle = navigine_sdk_flutter_Rectangle_ToFfi(rect);
    final _sampleSizeHandle = navigine_sdk_flutter_double_ToFfi(sampleSize);
    final _handle = this.handle;
    final __resultHandle = _decodeRegionFfi(_handle, _rectHandle, _sampleSizeHandle);
    navigine_sdk_flutter_Rectangle_ReleaseFfiHandle(_rectHandle);
    navigine_sdk_flutter_double_ReleaseFfiHandle(_sampleSizeHandle);
    final _result = navigine_sdk_flutter_ImageWrapper_FromFfi(__resultHandle);
    navigine_sdk_flutter_ImageWrapper_ReleaseFfiHandle(__resultHandle);
    return _result;
}