First form constructs new Image object and renders element on it as if element is given elementWidth/Height. If imageWidth/Height is provided then the function will try to scale/inscribe the element into that box.
Second form constructs new Image object and calls
) passing image bound graphics object as a parameter.
Optional clearBy defines color the bitmap will be initialized with. By default image is initilized by argb(0,0,0,0) color.
Destroys underlying native bitmap. Use this method to force the image to release its bitmap (that can be pretty big) when it is not needed.
Saves content of the image as a byte vector that can be used e.g. for uploading on the server.
compressionLevel is a number in the range 10..100 - JPEG or WebP compression level. If compressionLevel is omitted or zero and no packaging provided then the image is saved using PNG encoding.
#bgra packaging returns raw bitmap - array of B-G-R-A-B-G-R-A-... bytes in that sequence.
Static method, constructs image from bytes. The data bytes can contain any supported image packaging format : PNG, JPEG, etc.
The method returns width,height pair in one call, use it like this:
var (w,h) = img.size();
The method returns pixel color at x,y of the image. If new color c is provided then the method sets image pixel to that color.
This method allows to set alpha channel of the image from other image. By default, if second parameter is not provided, the method uses luminance of pixel in mask image as alpha value of corresponding pixel of this image. #r, #g, #b or #a - use mask's red, green, blue or alpha channels as alpha values.
This method allows to compose two images: this (dst) with the src Image.
compositionOp is one of composition opeatrions: #src-over, #dst-over, #src-in, #dst-in, #src-out, #dst-out, #src-atop, #dst-atop, #xor, #copy.
This method allows to render on existing image by calling
) passing image bound graphics object as a parameter. If clearBy parameter is provided and is a color then it is used to clear the image surface before rendering.