Image

class Image

Represents a raylib image.

Note that images are immutable and modification operations return new Image instances.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A byte array representation of this image's data.

Link copied to clipboard

The pixel format of the image.

Link copied to clipboard
val height: Int

The height of the image in pixels.

Link copied to clipboard

Whether the current image is valid.

Link copied to clipboard
val width: Int

The width of the image in pixels.

Functions

Link copied to clipboard
fun alphaClear(color: Color, threshold: Float): Image

Clears the alpha channel of the image based on a specified color and threshold. This operation sets the alpha channel to 0 for pixels that match the specified color within the threshold.

Link copied to clipboard
fun alphaMask(other: Image): Image

Applies an alpha mask to the image using another image as the mask. This operation sets the alpha channel of the image based on the brightness of the mask image.

Link copied to clipboard
fun blur(size: Int): Image

Applies a Gaussian blur to the image with the specified size.

Link copied to clipboard
fun brightness(brightness: Int): Image

Adjusts the brightness of the image.

Link copied to clipboard
fun circle(cx: Int, cy: Int, radius: Int, color: Color): Image

Draws a circle outline on the image.

Link copied to clipboard
fun contrast(contrast: Float): Image

Adjusts the contrast of the image.

Link copied to clipboard

Converts this image to another image format.

Link copied to clipboard
fun crop(x: Int, y: Int, width: Int, height: Int): Image

Crops the image to the specified rectangle.

Link copied to clipboard
fun dither(bpp: Int): Image

Dithers the image to the specified bits per pixel for all color channels.

fun dither(rbpp: Int, gbpp: Int, bbpp: Int, abpp: Int): Image

Dithers the image to the specified bits per pixel for each color channel.

Link copied to clipboard
fun draw(x: Int, y: Int, color: Color): Image

Draws a pixel on the current image.

fun draw(src: Image, x: Int, y: Int, tint: Color = Color.WHITE): Image

Draws the entire source image onto this image, scaling it to fit the dimensions of this image, using the specified tint color.

fun draw(src: Image, sx: Int, sy: Int, sw: Int, sh: Int, dx: Int, dy: Int, dw: Int, dh: Int, tint: Color = Color.WHITE): Image

Draws a source image onto this image at the specified destination rectangle, using the specified source rectangle and tint color.

Link copied to clipboard
fun drawText(x: Int, y: Int, text: String, fontSize: Int, color: Color): Image

Draws text on the image at the specified position, with the given font size and color.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun fillCircle(cx: Int, cy: Int, radius: Int, color: Color): Image

Draws a filled circle on the image.

Link copied to clipboard
fun fillRect(x: Int, y: Int, width: Int, height: Int, color: Color): Image

Draws a filled rectangle on the image.

Link copied to clipboard
fun fillTriangle(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int, color: Color): Image

Draws a filled triangle on the image.

fun fillTriangle(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int, color1: Color, color2: Color, color3: Color): Image

Draws a filled triangle on the image, linear interpolating three colors to the center.

Link copied to clipboard
fun flipH(): Image

Flips the image horizontally.

Link copied to clipboard
fun flipV(): Image

Flips the image vertically.

Link copied to clipboard
operator fun get(x: Int, y: Int): Color

Gets the color of the pixel at the specified (x, y) coordinates.

Link copied to clipboard

Gets the color data from the image.

Link copied to clipboard
fun getPalette(maxSize: Int = 10): List<Color>

Gets the color palette of the image.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun line(x1: Int, y1: Int, x2: Int, y2: Int, color: Color): Image
fun line(x1: Int, y1: Int, x2: Int, y2: Int, thick: Int, color: Color): Image

Draws a line on the current image.

Link copied to clipboard

Premultiplies the alpha channel of the image. This operation multiplies the RGB channels by the alpha channel.

Link copied to clipboard
fun rect(x: Int, y: Int, width: Int, height: Int, thick: Int, color: Color): Image

Draws a rectangle outline on the image.

Link copied to clipboard
fun replace(from: Color, to: Color): Image

Replaces a specific color in the image with another color.

Link copied to clipboard
fun resize(newWidth: Int, newHeight: Int): Image

Resizes the image to the specified width and height.

Link copied to clipboard
fun rotate(degrees: Int): Image

Rotates the image a certain number of degrees.

Link copied to clipboard

Rotates the image counter-clockwise 90 degrees.

Link copied to clipboard

Rotates the image clockwise 90 degrees.

Link copied to clipboard
fun triangle(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int, color: Color): Image

Draws a triangle outline on the image.

Link copied to clipboard
fun triangleFan(color: Color, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>): Image
fun triangleFan(color: Color, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>): Image

Draws a triangle fan on the image.

Link copied to clipboard
fun triangleStrip(color: Color, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>): Image
fun triangleStrip(color: Color, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>): ERROR CLASS: Unresolved name: memScoped

Draws a triangle strip on the image.

Link copied to clipboard
fun unload()

Unloads the raw image from memory.

Link copied to clipboard

Writes this image to a file.