Gama C Library
Gama C API Documentation
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1#pragma once
2
3#include "gapi.h"
4#include <stdint.h>
5
6/**
7 * @brief Structure representing an image with handle and dimensions.
8 */
9typedef struct {
10 uint32_t handle; /**< Internal handle for the image */
11 uint32_t width; /**< Width of the image in pixels */
12 uint32_t height; /**< Height of the image in pixels */
13} gmImage;
14
15/**
16 * @brief Loads an image from a file path.
17 * @param path The file path to the image.
18 * @return A gmImage structure containing the loaded image and its properties.
19 */
20gmImage gm_image_open(const char *path) {
21 gmImage img;
22 img.handle = gapi_create_image(path, &img.width, &img.height);
23 return img;
24}
25
26/**
27 * @brief Draws an entire image at the specified position and size.
28 * @param i The image to draw.
29 * @param x The x-coordinate to draw at.
30 * @param y The y-coordinate to draw at.
31 * @param w The width to draw the image.
32 * @param h The height to draw the image.
33 */
34void gm_image_draw(gmImage i, double x, double y, double w, double h) {
35 gapi_draw_image(i.handle, x, y, w, h);
36}
37
38/**
39 * @brief Draws a part of an image at the specified position and size.
40 * @param i The image to draw from.
41 * @param slice_x The x-coordinate of the slice to draw from the image.
42 * @param slice_y The y-coordinate of the slice to draw from the image.
43 * @param slice_width The width of the slice to draw from the image.
44 * @param slice_height The height of the slice to draw from the image.
45 * @param x The x-coordinate to draw at.
46 * @param y The y-coordinate to draw at.
47 * @param w The width to draw the slice.
48 * @param h The height to draw the slice.
49 */
50void gm_image_draw_part(gmImage i, int slice_x, int slice_y, int slice_width,
51 int slice_height, double x, double y, double w,
52 double h) {
53 gapi_draw_image_part(i.handle, slice_x, slice_y, slice_width, slice_height, x,
54 y, w, h);
55}
uint32_t gapi_create_image(const char *path, uint32_t *width, uint32_t *height)
int32_t gapi_draw_image(uint32_t handle, double x, double y, double width, double height)
int32_t gapi_draw_image_part(uint32_t handle, uint32_t slice_x, uint32_t slice_y, uint32_t slice_width, uint32_t slice_height, double x, double y, double width, double height)
gmImage gm_image_open(const char *path)
Loads an image from a file path.
Definition image.h:20
void gm_image_draw_part(gmImage i, int slice_x, int slice_y, int slice_width, int slice_height, double x, double y, double w, double h)
Draws a part of an image at the specified position and size.
Definition image.h:50
void gm_image_draw(gmImage i, double x, double y, double w, double h)
Draws an entire image at the specified position and size.
Definition image.h:34
Structure representing an image with handle and dimensions.
Definition image.h:9
uint32_t width
Definition image.h:11
uint32_t handle
Definition image.h:10
uint32_t height
Definition image.h:12