MLX42 1.0
MLX42
Loading...
Searching...
No Matches
mlx_png.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* :::::::: */
4/* mlx_png.c :+: :+: */
5/* +:+ */
6/* By: W2Wizard <main@w2wizard.dev> +#+ */
7/* +#+ */
8/* Created: 2022/02/16 23:11:29 by W2Wizard #+# #+# */
9/* Updated: 2022/06/27 19:55:06 by lde-la-h ######## odam.nl */
10/* */
11/* ************************************************************************** */
12
13#include "MLX42/MLX42_Int.h"
14
15//= Public =//
16
18{
20
22 if (!(image = malloc(sizeof(mlx_texture_t))))
23 return ((void*)mlx_error(MLX_MEMFAIL));
24
25 uint32_t error;
27 if ((error = lodepng_decode32_file(&image->pixels, &image->width, &image->height, path)))
28 {
29 free(image);
30 // Explicitly print error on purpose
31 fprintf(stderr, "MLX42: LodePNG: %s\n", lodepng_error_text(error));
32 return ((void*)mlx_error(MLX_INVPNG));
33 }
34 return (image);
35}
@ MLX_MEMFAIL
Definition MLX42.h:383
@ MLX_INVPNG
Definition MLX42.h:375
#define MLX_NONNULL(var)
Definition MLX42_Int.h:46
bool mlx_error(mlx_errno_t val)
Definition mlx_error.c:43
#define BPP
Definition MLX42_Int.h:42
GLenum GLenum GLsizei void * image
Definition glad.h:5132
GLuint GLsizei GLsizei * length
Definition glad.h:3372
unsigned lodepng_decode32_file(unsigned char **out, unsigned *w, unsigned *h, const char *filename)
const char * lodepng_error_text(unsigned code)
mlx_texture_t * mlx_load_png(const char *path)
Definition mlx_png.c:17
uint8_t bytes_per_pixel
Definition MLX42.h:267