MiniLibX allows you to create images in memory, manipulate their pixel data, and display them within a window.
To create a blank image, use mlx_new_image. To load an image from an XPM file, use mlx_xpm_file_to_image. Once an image is created, you can display it in a window using mlx_put_image_to_window.
Lifecycle:
- Create an image identifier using
mlx_new_image or mlx_xpm_file_to_image. - (Optional) Access the raw memory address via
mlx_get_data_addr to draw custom pixels. - Display the image in a window using
mlx_put_image_to_window. - Destroy the image when finished using
mlx_destroy_image to free memory.
void *img_ptr = mlx_new_image(mlx_ptr, width, height);
// ... manipulate img_ptr ...
mlx_put_image_to_window(mlx_ptr, win_ptr, img_ptr, x, y);
mlx_destroy_image(mlx_ptr, img_ptr);