BitmapImage
classin packageklyn.gui.images
public class BitmapImage extends RasterImage
└ BitmapImage

Editable straight-alpha RGBA bitmap, independent of a window or a file. Each update publishes an immutable snapshot: already recorded Painter commands keep their pixels until that frame is released. Pixels use R,G,B,A byte order. Dimensions are limited to 4096 on each axis (64 MiB per image).

import klyn.gui.images
image = BitmapImage(640, 480)
pixels = image.getPixels()
pixels[3] = Byte(255)
image.setPixels(pixels)
image.save("drawing.png")
Inherited Properties
propertyInherited Properties from RasterImage: height, width
propertyInherited Properties from Image: fileName, height, width
Constructors
Modifier and Type Member Description
public BitmapImage Decodes the first frame/page without modifying the source file.
public BitmapImage
BitmapImage(width as Int, height as Int)
Creates a transparent bitmap.
Methods
Modifier and Type Member Description
public override crop
crop(x as Int, y as Int, width as Int, height as Int) as Void
Bitmap pixel dimensions cannot be changed by a display-only operation.
public static frameCount
frameCount(file as String) as Int
Reads GIF frame count / TIFF page count, 1 for other image families.
public getPixels
getPixels() as Byte[]
Returns a copy of all RGBA bytes.
public override load
load(fileName as String) as Void
Loading into an existing mutable bitmap is not supported; create one.
public override resize
resize(width as Int, height as Int) as Void
Bitmap pixel dimensions cannot be changed by a display-only operation.
public save
save(file as String, quality as Int = 92, background as Int = 0xffffff) as Void
Atomically exports PNG, JPEG, GIF, BMP or TIFF, selected by extension.
public setPixels
setPixels(pixels as Byte[]) as Void
Publishes exactly width*height*4 bytes; copies the caller's buffer.
public setText
setText(text as String, family as String = "sans-serif", size as Int = 32, rgba as Long = 0x202030ffl, x as Int = 0, y as Int = 0) as Void
Replaces pixels with antialiased text, on a transparent background.
Inherited Methods
methodInherited Methods from RasterImage: render
methodInherited Methods from Image: crop, getImage, load, resize