Object built-in object

objectImage

Image processing objects, used to convert, draw, store and other operations on images

Image objects belong togdmodule, create:

1 2
var img = gd.create(640, 480); var img1 = gd.load(data);

inheritance relationship

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<this>Image|width;height;format;type;colorsTotal;transparent;progressive;alphaBlending|getData();save();colorAllocate();colorAllocateAlpha();colorClosest();colorClosestHWB();colorClosestAlpha();colorExact();colorExactAlpha();colorResolve();colorResolveAlpha();colorDeallocate();clip();getPixel();getTrueColorPixel();setPixel();setThickness();line();rectangle();filledRectangle();polygon();openPolygon();filledPolygon();ellipse();filledEllipse();arc();filledArc();fill();fillToBorder();colorReplace();clone();resample();crop();flip();rotate();convert();copy();copyMerge();copyMergeGray();copyResized();copyResampled();copyRotated();filter();affine();gaussianBlur()] [object] <:- [Image] Image width height format type colorsTotal transparent progressive alphaBlending getData() save() colorAllocate() colorAllocateAlpha() colorClosest() colorClosestHWB() colorClosestAlpha() colorExact() colorExactAlpha() colorResolve() colorResolveAlpha() colorDeallocate() clip() getPixel() getTrueColorPixel() setPixel() setThickness() line() rectangle() filledRectangle() polygon() openPolygon() filledPolygon() ellipse() filledEllipse() arc() filledArc() fill() fillToBorder() colorReplace() clone() resample() crop() flip() rotate() convert() copy() copyMerge() copyMergeGray() copyResized() copyResampled() copyRotated() filter() affine() gaussianBlur() object toString() toJSON()

Member properties

width

Integer, query image width

1
readonly Integer Image.width;

height

Integer, query image height

1
readonly Integer Image.height;

format

Integer, query the image source format, the result isgd.PNG,gd.JPEG,gd.GIF,gd.BMP,gd.WEBP

1
readonly Integer Image.format;

type

Integer, query image type, the result isgd.TRUECOLOR,gd.PALETTE

1
readonly Integer Image.type;

colorsTotal

Integer, query the total number of colors in the image color table

1
readonly Integer Image.colorsTotal;

transparent

Integer, query and set the specified color as transparent

1
Integer Image.transparent;

progressive

Boolean, query and set whether the image is progressive, only supports jpeg format

1
Boolean Image.progressive;

alphaBlending

Boolean, query and set whether to calculate the alpha layer when drawing, the default is true

1
Boolean Image.alphaBlending;

member function

getData

Returns image data in the specified format

1 2
Buffer Image.getData(Integer format = gd.PNG, Integer quality = 85) async;

Call parameters:

  • format: Integer, specifies the format of the returned data, the allowed value isgd.PNG,gd.JPEG,gd.GIF,gd.BMP,gd.WEBP, the default isgd.PNG
  • quality: Integer, when the format isgd.JPEGorgd.WEBPis used to specify the compression quality, the default is 85, other formats ignore this parameter

Return result:

  • Buffer, returns formatted data

save

Store the image data in the stream object according to the specified format

1 2 3
Image.save(Stream stm, Integer format = gd.PNG, Integer quality = 85) async;

Call parameters:

  • stm:Stream, specifies the stream object to store
  • format: Integer, specifies the format of the returned data, the allowed value isgd.PNG,gd.JPEG,gd.GIF,gd.BMP,gd.WEBP, the default isgd.PNG
  • quality: Integer, when the format isgd.JPEGorgd.WEBPis used to specify the compression quality, the default is 85, other formats ignore this parameter

Save the image data to the specified file according to the specified format, the file will be forcibly overwritten

1 2 3
Image.save(String fname, Integer format = gd.PNG, Integer quality = 85) async;

Call parameters:

  • fname: String, specifies the file name
  • format: Integer, specifies the format of the returned data, the allowed value isgd.PNG,gd.JPEG,gd.GIF,gd.BMP,gd.WEBP, the default isgd.PNG
  • quality: Integer, when the format isgd.JPEGis used to specify the compression quality, the default is 85, other formats ignore this parameter

colorAllocate

Request a color number for the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1 2 3
Integer Image.colorAllocate(Integer red, Integer green, Integer blue);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Request a color number for the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1
Integer Image.colorAllocate(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorAllocateAlpha

Apply a color number for the specified color and transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1 2 3 4
Integer Image.colorAllocateAlpha(Integer red, Integer green, Integer blue, Number alpha);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255
  • alpha: Number, transparent component, range is 0-1.0

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Apply a color number for the specified color and transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1
Integer Image.colorAllocateAlpha(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorClosest

Find a closest color number for the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1 2 3
Integer Image.colorClosest(Integer red, Integer green, Integer blue);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find a closest color number for the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1
Integer Image.colorClosest(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorClosestHWB

Find a closest color number for the specified color, this method uses the Hue/White/Black calculation to find the closest color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1 2 3
Integer Image.colorClosestHWB(Integer red, Integer green, Integer blue);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find a closest color number for the specified color, this method uses the Hue/White/Black calculation to find the closest color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1
Integer Image.colorClosestHWB(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorClosestAlpha

Find the closest color number for the specified color and transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1 2 3 4
Integer Image.colorClosestAlpha(Integer red, Integer green, Integer blue, Number alpha);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255
  • alpha: Number, transparent component, range is 0-1.0

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find the closest color number for the specified color and transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1
Integer Image.colorClosestAlpha(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorExact

Find the color number corresponding to the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1 2 3
Integer Image.colorExact(Integer red, Integer green, Integer blue);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find the color number corresponding to the specified color, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1
Integer Image.colorExact(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorExactAlpha

Find the specified color and the color number corresponding to transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1 2 3 4
Integer Image.colorExactAlpha(Integer red, Integer green, Integer blue, Number alpha);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255
  • alpha: Number, transparent component, range is 0-1.0

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find the specified color and the color number corresponding to transparency, forgd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1
Integer Image.colorExactAlpha(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorResolve

Find the color number corresponding to the specified color, if the color does not exist, apply for a new color number for it.gd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1 2 3
Integer Image.colorResolve(Integer red, Integer green, Integer blue);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find the color number corresponding to the specified color, if the color does not exist, apply for a new color number for it.gd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgb encoded value

1
Integer Image.colorResolve(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorResolveAlpha

Find the specified color and the color number corresponding to transparency, if the color does not exist, apply for a new color number for it.gd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1 2 3 4
Integer Image.colorResolveAlpha(Integer red, Integer green, Integer blue, Number alpha);

Call parameters:

  • red: Integer, red component, range 0-255
  • green: Integer, green component, range 0-255
  • blue: Integer, blue component, range 0-255
  • alpha: Number, transparent component, range is 0-1.0

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

Find the specified color and the color number corresponding to transparency, if the color does not exist, apply for a new color number for it.gd.PALETTEimage, the color number is the palette index, forgd.TRUECOLORImage, the color number is an rgba encoded value

1
Integer Image.colorResolveAlpha(Integer color);

Call parameters:

  • color: Integer, the combined color value, which can be set bygd.color, gb.rgb,gd.rgbaEqual function generation

Return result:

  • Integer, returns the color number, if unsuccessful, returns -1

colorDeallocate

Release the specified color number, and the released color number will be replaced after reapplying

1
Image.colorDeallocate(Integer color);

Call parameters:

  • color: Integer, specifies the color number to release

clip

Set the clipping window of the drawing, after setting, all the drawing will be clipped inside the window

1 2 3 4
Image.clip(Integer x1, Integer y1, Integer x2, Integer y2);

Call parameters:

  • x1: Integer, the upper left x coordinate of the clipping window
  • y1: Integer, the upper left y coordinate of the clipping window
  • x2: Integer, the bottom right x coordinate of the clipping window
  • y2: Integer, the lower right y coordinate of the clipping window

getPixel

Query the color of the specified location point

1 2
Integer Image.getPixel(Integer x, Integer y);

Call parameters:

  • x: Integer, specifies the x-coordinate of the query
  • y: Integer, specifies the y coordinate of the query

Return result:

  • Integer, returns the color number of the specified point

getTrueColorPixel

Query the true color of the specified location point

1 2
Integer Image.getTrueColorPixel(Integer x, Integer y);

Call parameters:

  • x: Integer, specifies the x-coordinate of the query
  • y: Integer, specifies the y coordinate of the query

Return result:

  • Integer, returns the color number of the specified point

setPixel

draw a point at the specified location

1 2 3
Image.setPixel(Integer x, Integer y, Integer color);

Call parameters:

  • x: Integer, specifies the x-coordinate of the drawn point
  • y: Integer, specify the y coordinate of the point to be drawn
  • color: Integer, specify the color number of the point to be drawn

setThickness

Set the width of the line. The default width of line, rectangle, arc and other methods is one pixel. You can use this method to change the width of the line.

1
Image.setThickness(Integer thickness);

Call parameters:

  • thickness: Integer, the width of the line to draw

line

Draw a line at the specified location

1 2 3 4 5
Image.line(Integer x1, Integer y1, Integer x2, Integer y2, Integer color);

Call parameters:

  • x1: Integer, specifies the starting x coordinate of the line to draw
  • y1: Integer, specifies the starting y coordinate of the line to draw
  • x2: Integer, specifies the end x coordinate of the line drawing
  • y2: Integer, specifies the end y coordinate of the line drawing
  • color: Integer, specify the color number of the line to draw

rectangle

Draw a rectangle at the specified location

1 2 3 4 5
Image.rectangle(Integer x1, Integer y1, Integer x2, Integer y2, Integer color);

Call parameters:

  • x1: Integer, specifies the x coordinate of the upper left corner
  • y1: Integer, specifies the y coordinate of the upper left corner
  • x2: Integer, specifies the x coordinate of the lower right corner
  • y2: Integer, specifies the y coordinate of the lower right corner
  • color: Integer, specifies the color number of the rectangle

filledRectangle

Draw a filled rectangle at the specified location

1 2 3 4 5
Image.filledRectangle(Integer x1, Integer y1, Integer x2, Integer y2, Integer color);

Call parameters:

  • x1: Integer, specifies the x coordinate of the upper left corner
  • y1: Integer, specifies the y coordinate of the upper left corner
  • x2: Integer, specifies the x coordinate of the lower right corner
  • y2: Integer, specifies the y coordinate of the lower right corner
  • color: Integer, specifies the color number of the rectangle

polygon

Draw a polygon based on a given point

1 2
Image.polygon(Array points, Integer color);

Call parameters:

  • points: Array, Array containing polygon points, such as [[1, 1], [1, 10], [10, 15], [10, 20]]
  • color: Integer, specifies the color number of the rectangle

openPolygon

Draws an open polygon based on a given point

1 2
Image.openPolygon(Array points, Integer color);

Call parameters:

  • points: Array, Array containing polygon points, such as [[1, 1], [1, 10], [10, 15], [10, 20]]
  • color: Integer, specifies the color number of the rectangle

filledPolygon

Draws a filled polygon based on a given point

1 2
Image.filledPolygon(Array points, Integer color);

Call parameters:

  • points: Array, Array containing polygon points, such as [[1, 1], [1, 10], [10, 15], [10, 20]]
  • color: Integer, specifies the color number of the rectangle

ellipse

draw an ellipse

1 2 3 4 5
Image.ellipse(Integer x, Integer y, Integer width, Integer height, Integer color);

Call parameters:

  • x: Integer, the x coordinate of the center of the ellipse
  • y: Integer, the y-coordinate of the center of the ellipse
  • width: Integer, the width of the ellipse
  • height: Integer, the height of the ellipse
  • color: Integer, specifies the color number of the rectangle

filledEllipse

draw a filled ellipse

1 2 3 4 5
Image.filledEllipse(Integer x, Integer y, Integer width, Integer height, Integer color);

Call parameters:

  • x: Integer, the x coordinate of the center of the ellipse
  • y: Integer, the y-coordinate of the center of the ellipse
  • width: Integer, the width of the ellipse
  • height: Integer, the height of the ellipse
  • color: Integer, specifies the color number of the rectangle

arc

draw a fan

1 2 3 4 5 6 7
Image.arc(Integer x, Integer y, Integer width, Integer height, Integer start, Integer end, Integer color);

Call parameters:

  • x: Integer, the x-coordinate of the center of the sector
  • y: Integer, the y coordinate of the center of the sector
  • width: Integer, the width of the ellipse where the sector is located
  • height: Integer, the height of the ellipse where the sector is located
  • start: Integer, the angle at which the sector starts, in the range 0-360
  • end: Integer, the angle at which the sector ends, in the range 0-360
  • color: Integer, specifies the color number of the rectangle

filledArc

draw a filled sector

1 2 3 4 5 6 7 8
Image.filledArc(Integer x, Integer y, Integer width, Integer height, Integer start, Integer end, Integer color, Integer style = gd.ARC);

Call parameters:

  • x: Integer, the x-coordinate of the center of the sector
  • y: Integer, the y coordinate of the center of the sector
  • width: Integer, the width of the ellipse where the sector is located
  • height: Integer, the height of the ellipse where the sector is located
  • start: Integer, the angle at which the sector starts, in the range 0-360
  • end: Integer, the angle at which the sector ends, in the range 0-360
  • color: Integer, specifies the color number of the rectangle
  • style: Integer, specifies the style of the sector, the allowed values ​​aregd.ARC,gd.CHORD,gd.NOFILL,gd.EDGEDand its combination

fill

Fill the enclosed area starting from the specified point

1 2 3
Image.fill(Integer x, Integer y, Integer color);

Call parameters:

  • x: Integer, x coordinate to start filling
  • y: Integer, y coordinate to start filling
  • color: Integer, specify the color number of the fill

fillToBorder

Fills the enclosed area within a border of the specified color starting from the specified point

1 2 3 4
Image.fillToBorder(Integer x, Integer y, Integer borderColor, Integer color);

Call parameters:

  • x: Integer, x coordinate to start filling
  • y: Integer, y coordinate to start filling
  • borderColor: Integer, specifies the color number of the border
  • color: Integer, specify the color number of the fill

colorReplace

Replace the color specified in the image with a new color

1 2
Image.colorReplace(Integer src, Integer dst) async;

Call parameters:

  • src: Integer, specifies the color to replace
  • dst: Integer, specify a new color

clone

Copy the current image to a new image

1
Image Image.clone() async;

Return result:

  • Image, returns the new image object copied

resample

Generate a new size image based on image stretching

1 2
Image Image.resample(Integer width, Integer height) async;

Call parameters:

  • width: Integer, specifies the width of the stretch
  • height: Integer, specifies the height of the stretch

Return result:

  • Image, returns the new image object

crop

Cut part of an image into a new image

1 2 3 4
Image Image.crop(Integer x, Integer y, Integer width, Integer height) async;

Call parameters:

  • x: Integer, the upper left x coordinate of the clipping window
  • y: Integer, the upper left y coordinate of the clipping window
  • width: Integer, the width of the clipping window
  • height: Integer, the height of the clipping window

Return result:

  • Image, returns the cropped image

flip

mirror current image

1
Image.flip(Integer dir = gd.HORIZONTAL) async;

Call parameters:


rotate

Rotate the current image

1
Image.rotate(Integer dir) async;

Call parameters:

  • dir: Integer, rotation direction, allowed values ​​aregd.LEFT,gd.RIGHT

convert

Convert the current image type

1
Image.convert(Integer color = gd.TRUECOLOR) async;

Call parameters:


copy

Copy an area from an image to a specified location

1 2 3 4 5 6 7
Image.copy(Image source, Integer dstX, Integer dstY, Integer srcX, Integer srcY, Integer width, Integer height) async;

Call parameters:

  • source: Image, source image object
  • dstX: Integer, specifies the x-coordinate of the copy target
  • dstY: Integer, specifies the y coordinate of the copy target
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • width: Integer, specifies the width of the copy
  • height: Integer, specifies the height of the copy

copyMerge

Copy an area from an image to overlay at the specified location

1 2 3 4 5 6 7 8
Image.copyMerge(Image source, Integer dstX, Integer dstY, Integer srcX, Integer srcY, Integer width, Integer height, Integer percent) async;

Call parameters:

  • source: Image, source image object
  • dstX: Integer, specifies the x-coordinate of the copy target
  • dstY: Integer, specifies the y coordinate of the copy target
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • width: Integer, specifies the width of the copy
  • height: Integer, specifies the height of the copy
  • percent: Integer, specifies the transparency of the overlay

copyMergeGray

Copy a grayscale overlay of an area from an image to a specified location

1 2 3 4 5 6 7 8
Image.copyMergeGray(Image source, Integer dstX, Integer dstY, Integer srcX, Integer srcY, Integer width, Integer height, Integer percent) async;

Call parameters:

  • source: Image, source image object
  • dstX: Integer, specifies the x-coordinate of the copy target
  • dstY: Integer, specifies the y coordinate of the copy target
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • width: Integer, specifies the width of the copy
  • height: Integer, specifies the height of the copy
  • percent: Integer, specifies the transparency of the overlay

copyResized

Stretch and copy an area of ​​an image to a specified location

1 2 3 4 5 6 7 8 9
Image.copyResized(Image source, Integer dstX, Integer dstY, Integer srcX, Integer srcY, Integer dstW, Integer dstH, Integer srcW, Integer srcH) async;

Call parameters:

  • source: Image, source image object
  • dstX: Integer, specifies the x-coordinate of the copy target
  • dstY: Integer, specifies the y coordinate of the copy target
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • dstW: Integer, specifies the stretch width of the copy
  • dstH: Integer, specifies the extruded height of the copy
  • srcW: Integer, specifies the source width of the copy
  • srcH: Integer, specifies the source height of the copy

copyResampled

Stretch an area in an image and copy it to the specified position. Different from copyResized, this method will shake the image when stretching.

1 2 3 4 5 6 7 8 9
Image.copyResampled(Image source, Integer dstX, Integer dstY, Integer srcX, Integer srcY, Integer dstW, Integer dstH, Integer srcW, Integer srcH) async;

Call parameters:

  • source: Image, source image object
  • dstX: Integer, specifies the x-coordinate of the copy target
  • dstY: Integer, specifies the y coordinate of the copy target
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • dstW: Integer, specifies the stretch width of the copy
  • dstH: Integer, specifies the extruded height of the copy
  • srcW: Integer, specifies the source width of the copy
  • srcH: Integer, specifies the source height of the copy

copyRotated

Rotate and copy an area of ​​an image to a specified location

1 2 3 4 5 6 7 8
Image.copyRotated(Image source, Number dstX, Number dstY, Integer srcX, Integer srcY, Integer width, Integer height, Number angle) async;

Call parameters:

  • source: Image, source image object
  • dstX: Number, specifies the x-coordinate of the copy destination
  • dstY: Number, specifies the y-coordinate of the copy destination
  • srcX: Integer, specifies the x coordinate of the upper left corner of the copy source
  • srcY: Integer, specifies the y-coordinate of the upper left corner of the copy source
  • width: Integer, specifies the width of the copy
  • height: Integer, specifies the height of the copy
  • angle: Number, specifies the angle of rotation

filter

Apply the filter filterType to the image and pass in the required parameters according to the filter type

1 2 3 4 5
Image.filter(Integer filterType, Number arg1 = 0, Number arg2 = 0, Number arg3 = 0, Number arg4 = 0) async;

Call parameters:

  • filterType: Integer, filter type
  • arg1: Number, Filter required parameters: smoothing level for SMOOTH, brightness level for BRIGHTNESS, contrast level for CONTRAST, red score for COLORIZE
  • arg2: Number, filter required parameters: the green score of COLORIZE
  • arg3: Number, filter required parameters: COLORIZE's blue score
  • arg4: Number, filter required parameters: COLORIZE transparency alpha score

The parameter filterType can be the following values:

  • MEAN_REMOVAL, use the average removal method to achieve the contour effect
  • EDGEDETECT, using edge detection to highlight the edges of the image
  • EMBOSS, to emboss the image
  • SELECTIVE_BLUR, blurred image
  • GAUSSIAN_BLUR, blur the image with a Gaussian algorithm
  • NEGATE, inverts all colors in the image
  • GRAYSCALE, convert the image to grayscale
  • SMOOTH, to make the image smoother, use arg1 to set the smoothness level
  • BRIGHTNESS, Change the brightness of the image, use arg1 to set the brightness level, the value range is -255~255
  • CONTRAST, Change the contrast of the image, use arg1 to set the contrast level, the value range is 0~100
  • COLORIZE, Change the color tone of the image, use arg1, arg2, arg3 to specify the red, blue, and green points respectively, each color range is 0~255, arg4 is the transparency, and the value returned is 0~127

affine

Affine the current image according to the given matrix

1 2 3 4 5
Image Image.affine(Array affine, Integer x = -1, Integer y = -1, Integer width = -1, Integer height = -1) async;

Call parameters:

  • affine: Array, affine matrix, consisting of 6 numbers of type double
  • x: Integer, the x-coordinate of the origin of the optional clipping region
  • y: Integer, the y-coordinate of the origin of the optional clipping region
  • width: Integer, the width of the optional clipping region
  • height: Integer, the height of the optional clipping region

Return result:

  • Image, returns the affine image

The parameter affine is an array:

1 2 3
affine = [a0, a1, b0, b1, a2, b2]; x ' = a0x + a1y + a2; y ' = b0x + b1y + b2;

gaussianBlur

Apply Gaussian blur to the current image

1
Image.gaussianBlur(Integer radius) async;

Call parameters:

  • radius: Integer, blur radius

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be reimplemented according to its own characteristics

1
String Image.toString();

Return result:

  • String, returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns the set of readable properties defined by the object

1
Value Image.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable