BufferImage class

An image object, pixel data stored in a Uint8List



BufferImage(dynamic width, dynamic height)
create BufferImage with specified with and height
BufferImage.raw(Uint8List data, {required int width, required int height})


buffer Uint8List
the color data of this image
no setter
bytePerPixel int
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
height int
no setteroverride
pixels List<int>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width int
no setteroverride


clip(int newWidth, int newHeight, [int offsetX = 0, int offsetY = 0]) → void
Clip the image to newWidth & newHeight from Offset(offsetX, offsetY)
clipPath(Path path, {bool doAntiAlias = true}) Future<void>
Clip this image with path, use a Canvas render
copy() BufferImage
A copy of this BufferImage
drawIcon(IconData icon, double size, Offset offset, Color color, [BlendMode mode = BlendMode.srcOver]) Future<void>
drawImage(BufferImage image, Offset offset, [BlendMode mode = BlendMode.srcOver]) → void
Draw the image on this image at offset, use the mode
drawPath(Path path, Color color, {BlendMode mode = BlendMode.srcOver, PaintingStyle style = PaintingStyle.fill, double strokeWidth = 0}) Future<void>
Draw the path on this image, use a Canvas render
drawRect(Rect rect, Color color, [BlendMode mode = BlendMode.srcOver]) → void
Draw a rect on this image with color, use the mode
drawText(String text, TextStyle style, Offset offset, [BlendMode mode = BlendMode.srcOver]) Future<void>
getChannel(int x, int y, [ImageChannel? channel]) int
getChannelSafe(int x, int y, [int? defaultValue, ImageChannel? channel]) int
getColor(int x, int y) Color
get the Color at Offset(x, y)
getColorSafe(int x, int y, [Color? defaultColor = const Color(0x00ffffff)]) Color
get the Color at Offset(x, y) with out error
getImage() Future<Image>
Get the Image Object from this image
getOffset(int x, int y) int
inverse() → void
inverse phase
mask(Color color, [BlendMode mode = BlendMode.color]) → void
Mask the image with color use mode(see BlendMode)
maskImage(BufferImage image, [BlendMode mode = BlendMode.color, Point<int>? offset, int repeat = RepeatMode.repeatAll]) → void
Mask the image with another image use mode(see BlendMode)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
resize(double ratio, [SampleMode sample = SampleMode.nearest]) → void
scale by ratio width sample
resizeTo(int newWidth, int newHeight, [SampleMode sample = SampleMode.nearest]) → void
scale to specified size (newWidth and newHeight) with sample
rotate(double radian, {bool isAntialias = true, SampleMode sample = SampleMode.bilinear, Color bgColor = const Color.fromARGB(0, 255, 255, 255), bool isClip = false}) → void
Rotate image by the specified radian, The blank area is filled with the specified bgColor If isClip, hold the old width & height (clip the image data out of canvas) Else adjust the canvas to fit the rotated image isAntialias not implemented
scaleDown(double scale) → void
zoom out an image. calc the avg channels of the colors in area as the new color
setChannel(int x, int y, int value, [ImageChannel? channel]) → void
setChannelSafe(int x, int y, int value, [ImageChannel? channel]) → void
setColor(int x, int y, Color color) → void
set the Color at Offset(x, y)
setColorSafe(int x, int y, Color color) → void
set Color at Offset(x, y) without error
toGray([GrayScale? grayScale]) GrayImage
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.

Static Methods

fromFile(Uint8List fileData) Future<BufferImage?>
load image from a image fileData use system codec(decodeImageFromList)
fromGray(GrayImage grayImage) BufferImage
fromImage(Image image) Future<BufferImage>
load data from an Image