createDrawImage

Creates an immutable source image for platform-neutral drawing.

The input array is copied before the image is returned, and every DrawImage.copyArgb call returns a fresh copy. The checked area is exactly size.width * size.height; zero-width or zero-height extents therefore require an empty array. Equal sizes and pixel values produce equal images with equal hash codes.

Return

an immutable, thread-safe image value.

Parameters

size

the non-negative source image extent.

argb

row-major straight, non-premultiplied 0xAARRGGBB pixels.

Throws

when the checked image area overflows Int.

when the pixel array length does not equal the checked image area.


fun createDrawImage(size: IntSize, pixelAt: (x: Int, y: Int) -> Int): DrawImage(source)

Generates an immutable image directly into its privately owned storage.

pixelAt is borrowed synchronously on the caller's thread, once per pixel in row-major order, and never retained. Empty images do not invoke it. A callback failure propagates without publishing a partial image. The returned value has the same equality and copy contract as the array overload.

Return

an immutable, thread-safe image owning the generated pixels.

Parameters

size

the non-negative source extent whose checked area must fit in Int.

pixelAt

supplies straight, non-premultiplied 0xAARRGGBB pixels at the given x and y coordinates.

Throws

when the checked image area overflows Int, before invoking pixelAt.