fromPath static method

ImageRef fromPath(
  1. String path, {
  2. PathImageLoadOptions? options,
})

Creates ImageRef from the path to an image.

Implementation

static ImageRef fromPath(String path, {PathImageLoadOptions? options}) {
  return using((Arena arena) {
    PathImageLoadOptions resolvedOptions = options ?? PathImageLoadOptions();
    Pointer<Utf8> pPath = path.toNativeUtf8(allocator: arena);
    Pointer<CPathImageLoadOptions> pConfig = arena<CPathImageLoadOptions>();
    pConfig.ref.cropRect.x = resolvedOptions.cropRect.left;
    pConfig.ref.cropRect.y = resolvedOptions.cropRect.top;
    pConfig.ref.cropRect.width = resolvedOptions.cropRect.width;
    pConfig.ref.cropRect.height = resolvedOptions.cropRect.height;
    pConfig.ref.colorConversion = resolvedOptions.colorConversion.index;
    pConfig.ref.canvasColor = resolvedOptions.canvasColor.index;
    pConfig.ref.loadMode = resolvedOptions.loadMode.index;
    pConfig.ref.encryptionMode = resolvedOptions.encryptionMode.index;

    String uuid = _consumeString(_nativeCreateFromPath(pPath, pConfig));

    ImageRef ref = ImageRef._(uuid);
    return ref;
  });
}