magickDistortImage method

Future<bool> magickDistortImage({
  1. required DistortMethod method,
  2. required Float64List arguments,
  3. required bool bestFit,
})

Distorts an image using various distortion methods, by mapping color lookups of the source image to a new destination image usually of the same size as the source image, unless 'bestfit' is set to true.

If 'bestfit' is enabled, and distortion allows it, the destination image is adjusted to ensure the whole source 'image' will just fit within the final destination image, which will be sized and offset accordingly. Also in many cases the virtual offset of the source image will be taken into account in the mapping.

This method runs inside an isolate different from the main isolate.

  • method: the method of image distortion.

ArcDistortion always ignores the source image offset, and always 'bestfit' the destination image with the top left corner offset relative to the polar mapping center.

Bilinear has no simple inverse mapping so it does not allow 'bestfit' style of image distortion.

Affine, Perspective, and Bilinear, do least squares fitting of the distortion when more than the minimum number of control point pairs are provided.

Perspective, and Bilinear, falls back to a Affine distortion when less that 4 control point pairs are provided. While Affine distortions let you use any number of control point pairs, that is Zero pairs is a no-Op (viewport only) distortion, one pair is a translation and two pairs of control points do a scale-rotate-translate, without any shearing.

  • arguments: the arguments for this distortion method.
  • bestFit: Attempt to resize destination to fit distorted source.

Implementation

Future<bool> magickDistortImage({
  required DistortMethod method,
  required Float64List arguments,
  required bool bestFit,
}) async =>
    await _magickCompute(
      _magickDistortImage,
      _MagickDistortImageParams(
        _wandPtr.address,
        method,
        arguments,
        bestFit,
      ),
    );