The Dart Image Library provides a number of functions for modifying images, by applying color filters, transformations into other images (resize, crop), or basic drawing.
Most of the drawing functions can take a mask parameter. A mask is an image that controls the blending of the filter per pixel. You can specify which channel of the mask, or its luminance, to use for the blending value. Where the mask channel is full intensity, the filter has full effect, and where the mask channel is 0, it has no effect; and values in between will blend the filter with the original image.
Using a mask image to blend the sketch filter:
Image compositeImage(Image dst, Image src, {
int? dstX, int? dstY, int? dstW, int? dstH, int? srcX, int? srcY,
int? srcW, int? srcH, BlendMode blend = BlendMode.alpha,
bool linearBlend = false,
bool center = false, Image? mask,
Channel maskChannel = Channel.luminance })
Image drawChar(Image image, String char, { required BitmapFont font,
required int x, required int y, Color? color, Image? mask,
Channel maskChannel = Channel.luminance });
Image drawCircle(Image image, { required int x, required int y,
required int radius, required Color color, bool antialias = false,
Image? mask, Channel maskChannel = Channel.luminance })
Image drawLine(Image image, { required int x1, required int y1,
required int x2, required int y2, required Color color,
bool antialias = false, num thickness = 1, Image? mask,
Channel maskChannel = Channel.luminance })
Image drawPixel(Image image, int x, int y, Color c, { Color? filter,
num? alpha, BlendMode blend = BlendMode.alpha,
bool linearBlend = false, Image? mask,
Channel maskChannel = Channel.luminance })
Image drawPolygon(Image src, { required List<Point> vertices,
required Color color, bool antialias = false, Image? mask, Channel maskChannel = Channel.luminance })
Image drawRect(Image dst, { required int x1, required int y1, required int x2,
required int y2, required Color color, num radius = 0, num thickness = 1, Image? mask,
Channel maskChannel = Channel.luminance })
Image drawString(Image image, String string, { required BitmapFont font,
int? x, int? y, Color? color, bool rightJustify = false, bool wrap = false,
Image? mask, Channel maskChannel = Channel.luminance })
Image fill(Image image, { required Color color, Image? mask,
Channel maskChannel = Channel.luminance })
Image fillCircle(Image image, { required int x, required int y,
required int radius, required Color color, bool antialias = false,
Image? mask, Channel maskChannel = Channel.luminance})
Image fillFlood(Image src, { required int x, required int y,
required Color color, num threshold = 0.0, bool compareAlpha = false,
Image? mask, Channel maskChannel = Channel.luminance })
Image fillPolygon(Image src, { required List<Point> vertices,
required Color color, Image? mask, Channel maskChannel = Channel.luminance })
Image fillRect(Image src, { required int x1, required int y1, required int x2,
required int y2, required Color color, num Radius = 0, Image? mask,
Channel maskChannel = Channel.luminance })