← ziglang.inraylib-zigGitHub

textures

Images (CPU), textures (GPU) and colors. 125 functions, from raylib's rtextures.

Image loading functions

rl.loadImageRaw

Load image from RAW file data

Zigfn loadImageRaw(fileName: [:0]const u8, width: i32, height: i32, format: PixelFormat, headerSize: i32) error{LoadFailed}!Image
CImage LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize);

Used in textures_raw_data.

rl.loadImageAnim

Load image sequence from file (frames appended to image.data)

Load image sequence from file (frames appended to image.data).

Zigfn loadImageAnim(fileName: [:0]const u8) error{LoadFailed}!ImageAnim
CImage LoadImageAnim(const char *fileName, int *frames);

Used in textures_gif_player.

rl.loadImageAnimFromMemory

Load image sequence from memory buffer

Load image sequence from memory buffer (fileType: ".gif").

Zigfn loadImageAnimFromMemory(fileType: [:0]const u8, fileData: []const u8) error{LoadFailed}!ImageAnim
CImage LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int *frames);

rl.loadImageFromMemory

Load image from memory buffer, fileType refers to extension: i.e. '.png'

Zigfn loadImageFromMemory(fileType: [:0]const u8, fileData: []const u8) error{LoadFailed}!Image
CImage LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize);

rl.exportImage

Export image data to file, returns true on success

Zigfn exportImage(image: Image, fileName: [:0]const u8) bool
Cbool ExportImage(Image image, const char *fileName);

Used in textures_mouse_painting.

rl.exportImageToMemory

Export image to memory buffer, memory must be MemFree()

Export image to memory buffer (fileType: ".png"...). Free with `memFree`.

Zigfn exportImageToMemory(image: Image, fileType: [:0]const u8) error{ExportFailed}![]u8
Cunsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize);

rl.exportImageAsCode

Export image as code file defining an array of bytes, returns true on success

Zigfn exportImageAsCode(image: Image, fileName: [:0]const u8) bool
Cbool ExportImageAsCode(Image image, const char *fileName);

Image generation functions

rl.genImageGradientLinear

Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient

Zigfn genImageGradientLinear(width: i32, height: i32, direction: i32, start: Color, end: Color) Image
CImage GenImageGradientLinear(int width, int height, int direction, Color start, Color end);

Used in textures_image_generation.

rl.genImageGradientRadial

Generate image: radial gradient

Zigfn genImageGradientRadial(width: i32, height: i32, density: f32, inner: Color, outer: Color) Image
CImage GenImageGradientRadial(int width, int height, float density, Color inner, Color outer);

Used in textures_image_generation.

rl.genImageGradientSquare

Generate image: square gradient

Zigfn genImageGradientSquare(width: i32, height: i32, density: f32, inner: Color, outer: Color) Image
CImage GenImageGradientSquare(int width, int height, float density, Color inner, Color outer);

Used in textures_image_generation.

rl.genImageCellular

Generate image: cellular algorithm, bigger tileSize means bigger cells

Zigfn genImageCellular(width: i32, height: i32, tileSize: i32) Image
CImage GenImageCellular(int width, int height, int tileSize);

Used in textures_image_generation.

rl.genImageText

Generate image: grayscale image from text data

Zigfn genImageText(width: i32, height: i32, text: [:0]const u8) Image
CImage GenImageText(int width, int height, const char *text);

Image manipulation functions

rl.imageFromImage

Create an image from another image piece

Zigfn imageFromImage(image: Image, rec: Rectangle) Image
CImage ImageFromImage(Image image, Rectangle rec);

Used in models_rotating_cube.

rl.imageFromChannel

Create an image from a selected channel of another image (GRAYSCALE)

Zigfn imageFromChannel(image: Image, selectedChannel: i32) Image
CImage ImageFromChannel(Image image, int selectedChannel);

Used in textures_image_channel.

rl.imageText

Create an image from text (default font)

Create an image from text (default font).

Zigfn imageText(text: [:0]const u8, fontSize: i32, color: Color) Image
CImage ImageText(const char *text, int fontSize, Color color);

rl.imageTextEx

Create an image from text (custom sprite font)

Zigfn imageTextEx(font: Font, text: [:0]const u8, fontSize: f32, spacing: f32, tint: Color) Image
CImage ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint);

rl.imageToPOT

Convert image to POT (power-of-two)

Zigfn imageToPOT(image: *Image, fill: Color) void
Cvoid ImageToPOT(Image *image, Color fill);

rl.imageAlphaCrop

Crop image depending on alpha value

Zigfn imageAlphaCrop(image: *Image, threshold: f32) void
Cvoid ImageAlphaCrop(Image *image, float threshold);

rl.imageAlphaClear

Clear alpha channel to desired color

Zigfn imageAlphaClear(image: *Image, color: Color, threshold: f32) void
Cvoid ImageAlphaClear(Image *image, Color color, float threshold);

rl.imageAlphaPremultiply

Premultiply alpha channel

Zigfn imageAlphaPremultiply(image: *Image) void
Cvoid ImageAlphaPremultiply(Image *image);

rl.imageKernelConvolution

Apply custom square convolution kernel to image

Zigfn imageKernelConvolution(image: *Image, kernel: []const f32) void
Cvoid ImageKernelConvolution(Image *image, const float *kernel, int kernelSize);

Used in textures_image_kernel.

rl.imageResize

Resize image (Bicubic scaling algorithm)

Zigfn imageResize(image: *Image, newWidth: i32, newHeight: i32) void
Cvoid ImageResize(Image *image, int newWidth, int newHeight);

Used in textures_image_drawing.

rl.imageResizeNN

Resize image (Nearest-Neighbor scaling algorithm)

Zigfn imageResizeNN(image: *Image, newWidth: i32, newHeight: i32) void
Cvoid ImageResizeNN(Image *image, int newWidth, int newHeight);

Used in models_decals.

rl.imageResizeCanvas

Resize canvas and fill with color

Zigfn imageResizeCanvas(image: *Image, newWidth: i32, newHeight: i32, offsetX: i32, offsetY: i32, fill: Color) void
Cvoid ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill);

rl.imageMipmaps

Compute all mipmap levels for a provided image

Zigfn imageMipmaps(image: *Image) void
Cvoid ImageMipmaps(Image *image);

rl.imageDither

Dither image data to 16bpp or lower (Floyd-Steinberg dithering)

Zigfn imageDither(image: *Image, rBpp: i32, gBpp: i32, bBpp: i32, aBpp: i32) void
Cvoid ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp);

rl.imageRotate

Rotate image by input angle in degrees (-359 to 359)

Zigfn imageRotate(image: *Image, degrees: i32) void
Cvoid ImageRotate(Image *image, int degrees);

Used in textures_image_rotate.

rl.imageRotateCW

Rotate image clockwise 90deg

Zigfn imageRotateCW(image: *Image) void
Cvoid ImageRotateCW(Image *image);

rl.imageRotateCCW

Rotate image counter-clockwise 90deg

Zigfn imageRotateCCW(image: *Image) void
Cvoid ImageRotateCCW(Image *image);

rl.imageColorReplace

Modify image color: replace color

Zigfn imageColorReplace(image: *Image, color: Color, replace: Color) void
Cvoid ImageColorReplace(Image *image, Color color, Color replace);

rl.loadImagePalette

Load colors palette from image as a Color array (RGBA - 32bit)

Load colors palette from image as a Color array (RGBA - 32bit). Free with `unloadImagePalette`.

Zigfn loadImagePalette(image: Image, maxPaletteSize: i32) error{LoadFailed}![]Color
CColor *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount);

rl.unloadImagePalette

Unload colors palette loaded with LoadImagePalette()

Unload colors palette loaded with `loadImagePalette`.

Zigfn unloadImagePalette(colors: []Color) void
Cvoid UnloadImagePalette(Color *colors);

rl.getImageAlphaBorder

Get image alpha border rectangle

Zigfn getImageAlphaBorder(image: Image, threshold: f32) Rectangle
CRectangle GetImageAlphaBorder(Image image, float threshold);

Image drawing functions

rl.imageDrawPixelV

Draw pixel within an image (Vector version)

Zigfn imageDrawPixelV(dst: *Image, position: Vector2, color: Color) void
Cvoid ImageDrawPixelV(Image *dst, Vector2 position, Color color);

rl.imageDrawLine

Draw line within an image

Zigfn imageDrawLine(dst: *Image, startPosX: i32, startPosY: i32, endPosX: i32, endPosY: i32, color: Color) void
Cvoid ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color);

rl.imageDrawLineV

Draw line within an image (Vector version)

Zigfn imageDrawLineV(dst: *Image, start: Vector2, end: Vector2, color: Color) void
Cvoid ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color);

rl.imageDrawLineEx

Draw a line defining thickness within an image

Zigfn imageDrawLineEx(dst: *Image, start: Vector2, end: Vector2, thick: i32, color: Color) void
Cvoid ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color color);

rl.imageDrawLineStrip

Draw a lines sequence within an image

Zigfn imageDrawLineStrip(dst: *Image, points: []const Vector2, color: Color) void
Cvoid ImageDrawLineStrip(Image *dst, const Vector2 *points, int pointCount, Color color);

rl.imageDrawTriangle

Draw triangle within an image

Zigfn imageDrawTriangle(dst: *Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void
Cvoid ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color);

rl.imageDrawTriangleGradient

Draw triangle with interpolated colors within an image

Zigfn imageDrawTriangleGradient(dst: *Image, v1: Vector2, v2: Vector2, v3: Vector2, c1: Color, c2: Color, c3: Color) void
Cvoid ImageDrawTriangleGradient(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3);

rl.imageDrawTriangleLines

Draw triangle outline within an image

Zigfn imageDrawTriangleLines(dst: *Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void
Cvoid ImageDrawTriangleLines(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color);

rl.imageDrawTriangleFan

Draw a triangle fan defined by points within an image (first vertex is the center)

Zigfn imageDrawTriangleFan(dst: *Image, points: []const Vector2, color: Color) void
Cvoid ImageDrawTriangleFan(Image *dst, const Vector2 *points, int pointCount, Color color);

rl.imageDrawTriangleStrip

Draw a triangle strip defined by points within an image

Zigfn imageDrawTriangleStrip(dst: *Image, points: []const Vector2, color: Color) void
Cvoid ImageDrawTriangleStrip(Image *dst, const Vector2 *points, int pointCount, Color color);

rl.imageDrawRectangle

Draw rectangle within an image

Zigfn imageDrawRectangle(dst: *Image, posX: i32, posY: i32, width: i32, height: i32, color: Color) void
Cvoid ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color);

Used in textures_image_drawing.

rl.imageDrawRectangleV

Draw rectangle within an image (Vector version)

Zigfn imageDrawRectangleV(dst: *Image, position: Vector2, size: Vector2, color: Color) void
Cvoid ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color);

rl.imageDrawRectangleRec

Draw rectangle within an image

Zigfn imageDrawRectangleRec(dst: *Image, rec: Rectangle, color: Color) void
Cvoid ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color);

rl.imageDrawRectanglePro

Draw a color-filled rectangle with pro parameters within and image

Zigfn imageDrawRectanglePro(dst: *Image, rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void
Cvoid ImageDrawRectanglePro(Image *dst, Rectangle rec, Vector2 origin, float rotation, Color color);

rl.imageDrawRectangleLines

Draw rectangle lines within an image

Zigfn imageDrawRectangleLines(dst: *Image, posX: i32, posY: i32, width: i32, height: i32, color: Color) void
Cvoid ImageDrawRectangleLines(Image *dst, int posX, int posY, int width, int height, Color color);

rl.imageDrawRectangleLinesEx

Draw rectangle lines within an image with line thickness

Zigfn imageDrawRectangleLinesEx(dst: *Image, rec: Rectangle, thick: i32, color: Color) void
Cvoid ImageDrawRectangleLinesEx(Image *dst, Rectangle rec, int thick, Color color);

rl.imageDrawRectangleGradientEx

Draw rectangle with gradient colors within an image, counter-clockwise color order

Zigfn imageDrawRectangleGradientEx(dst: *Image, rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void
Cvoid ImageDrawRectangleGradientEx(Image *dst, Rectangle rec, Color col1, Color col2, Color col3, Color col4);

rl.imageDrawCircleV

Draw a filled circle within an image (Vector version)

Zigfn imageDrawCircleV(dst: *Image, center: Vector2, radius: i32, color: Color) void
Cvoid ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color);

rl.imageDrawCircleLines

Draw circle outline within an image

Zigfn imageDrawCircleLines(dst: *Image, centerX: i32, centerY: i32, radius: i32, color: Color) void
Cvoid ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color);

Used in textures_image_drawing.

rl.imageDrawCircleLinesV

Draw circle outline within an image (Vector version)

Zigfn imageDrawCircleLinesV(dst: *Image, center: Vector2, radius: i32, color: Color) void
Cvoid ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color);

rl.imageDrawCircleGradient

Draw a gradient-filled circle within an image

Zigfn imageDrawCircleGradient(dst: *Image, center: Vector2, radius: f32, inner: Color, outer: Color) void
Cvoid ImageDrawCircleGradient(Image *dst, Vector2 center, float radius, Color inner, Color outer);

rl.imageDrawImage

Draw an image within an image

Zigfn imageDrawImage(dst: *Image, src: Image, posX: i32, posY: i32, tint: Color) void
Cvoid ImageDrawImage(Image *dst, Image src, int posX, int posY, Color tint);

rl.imageDrawImageEx

Draw an image with scaling and rotation within an image

Zigfn imageDrawImageEx(dst: *Image, src: Image, position: Vector2, rotation: f32, scale: f32, tint: Color) void
Cvoid ImageDrawImageEx(Image *dst, Image src, Vector2 position, float rotation, float scale, Color tint);

rl.imageDrawImageRec

Draw a part of an image defined by a rectangle within an image

Zigfn imageDrawImageRec(dst: *Image, src: Image, srcRec: Rectangle, position: Vector2, tint: Color) void
Cvoid ImageDrawImageRec(Image *dst, Image src, Rectangle srcRec, Vector2 position, Color tint);

rl.imageDrawImagePro

Draw a part of an image defined by a rectangle into destination rectangle, with scaling and rotation, within an image

Zigfn imageDrawImagePro(dst: *Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void
Cvoid ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Vector2 origin, float rotation, Color tint);

Used in textures_image_drawing.

rl.imageDrawText

Draw text (using default font) within an image (destination)

Zigfn imageDrawText(dst: *Image, text: [:0]const u8, posX: i32, posY: i32, fontSize: i32, color: Color) void
Cvoid ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color);

rl.imageDrawTextEx

Draw text (custom sprite font) within an image (destination)

Zigfn imageDrawTextEx(dst: *Image, font: Font, text: [:0]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void
Cvoid ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint);

Used in textures_image_drawing, textures_image_text.

rl.imageDrawTextPro

Draw text using Font and pro parameters (rotation)

Zigfn imageDrawTextPro(dst: *Image, font: Font, text: [:0]const u8, position: Vector2, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) void
Cvoid ImageDrawTextPro(Image *dst, Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint);

Texture loading functions

rl.loadTextureCubemap

Load cubemap from image, multiple image cubemap layouts supported

Zigfn loadTextureCubemap(image: Image, layout: CubemapLayout) error{LoadFailed}!TextureCubemap
CTextureCubemap LoadTextureCubemap(Image image, int layout);

Used in models_skybox_rendering.

rl.loadRenderTextureEx

Load texture for rendering (framebuffer), with specific format

Zigfn loadRenderTextureEx(width: i32, height: i32, format: PixelFormat) error{LoadFailed}!RenderTexture2D
CRenderTexture2D LoadRenderTextureEx(int width, int height, int format);

rl.isRenderTextureValid

Check if render texture is valid (loaded in GPU)

Zigfn isRenderTextureValid(target: RenderTexture2D) bool
Cbool IsRenderTextureValid(RenderTexture2D target);

rl.updateTextureRec

Update GPU texture rectangle with new data (pixels and rec should fit in texture)

Zigfn updateTextureRec(texture: Texture2D, rec: Rectangle, pixels: *const anyopaque) void
Cvoid UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels);

Used in shaders_game_of_life.

Texture configuration functions

Texture drawing functions

rl.drawTexturePro

Draw a part of a texture defined by a source rectangle to destination rectangle, with scaling and rotation

Zigfn drawTexturePro(texture: Texture2D, srcrec: Rectangle, dstrec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void
Cvoid DrawTexturePro(Texture2D texture, Rectangle srcrec, Rectangle dstrec, Vector2 origin, float rotation, Color tint);

Used in core_window_letterbox, core_vr_simulator, core_smooth_pixelperfect, core_render_texture, core_viewport_scaling, textures_clipboard_image and 10 more.

rl.drawTextureNPatch

Draw a texture (or part of it) that stretches or shrinks nicely

Zigfn drawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, dstrec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void
Cvoid DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dstrec, Vector2 origin, float rotation, Color tint);

Used in textures_npatch_drawing.

Color/pixel related functions

rl.colorIsEqual

Check if two colors are equal

Zigfn colorIsEqual(col1: Color, col2: Color) bool
Cbool ColorIsEqual(Color col1, Color col2);

rl.colorToHSV

Get HSV values for a Color, hue [0..360], saturation/value [0..1]

Zigfn colorToHSV(color: Color) Vector3
CVector3 ColorToHSV(Color color);

rl.colorTint

Get color multiplied with another color

Zigfn colorTint(color: Color, tint: Color) Color
CColor ColorTint(Color color, Color tint);

rl.colorBrightness

Get color with brightness correction, brightness factor goes from -1.0f to 1.0f

Zigfn colorBrightness(color: Color, factor: f32) Color
CColor ColorBrightness(Color color, float factor);

rl.colorContrast

Get color with contrast correction, contrast values between -1.0f and 1.0f

Zigfn colorContrast(color: Color, contrast: f32) Color
CColor ColorContrast(Color color, float contrast);

rl.colorAlphaBlend

Get src alpha-blended into dst color with tint

Zigfn colorAlphaBlend(dst: Color, src: Color, tint: Color) Color
CColor ColorAlphaBlend(Color dst, Color src, Color tint);

rl.getPixelColor

Get Color from a source pixel pointer of certain format

Zigfn getPixelColor(srcPtr: *const anyopaque, format: PixelFormat) Color
CColor GetPixelColor(const void *srcPtr, int format);

rl.setPixelColor

Set color formatted into destination pixel pointer

Zigfn setPixelColor(dstPtr: *anyopaque, color: Color, format: PixelFormat) void
Cvoid SetPixelColor(void *dstPtr, Color color, int format);

rl.getPixelDataSize

Get pixel data size in bytes for certain format

Zigfn getPixelDataSize(width: i32, height: i32, format: PixelFormat) i32
Cint GetPixelDataSize(int width, int height, int format);