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
17
mlx_texture_t
*
mlx_load_png
(
const
char
*
path
)
18
{
19
MLX_NONNULL
(
path
);
20
21
mlx_texture_t
*
image
;
22
if
(!(
image
=
malloc
(
sizeof
(
mlx_texture_t
))))
23
return
((
void
*)
mlx_error
(
MLX_MEMFAIL
));
24
25
uint32_t
error;
26
image
->
bytes_per_pixel
=
BPP
;
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
@ MLX_MEMFAIL
Definition
MLX42.h:383
MLX_INVPNG
@ MLX_INVPNG
Definition
MLX42.h:375
MLX42_Int.h
MLX_NONNULL
#define MLX_NONNULL(var)
Definition
MLX42_Int.h:46
mlx_error
bool mlx_error(mlx_errno_t val)
Definition
mlx_error.c:43
BPP
#define BPP
Definition
MLX42_Int.h:42
image
GLenum GLenum GLsizei void * image
Definition
glad.h:5132
length
GLuint GLsizei GLsizei * length
Definition
glad.h:3372
lodepng_decode32_file
unsigned lodepng_decode32_file(unsigned char **out, unsigned *w, unsigned *h, const char *filename)
lodepng_error_text
const char * lodepng_error_text(unsigned code)
mlx_load_png
mlx_texture_t * mlx_load_png(const char *path)
Definition
mlx_png.c:17
mlx_texture
Definition
MLX42.h:264
mlx_texture::bytes_per_pixel
uint8_t bytes_per_pixel
Definition
MLX42.h:267
lib
MLX42
src
textures
mlx_png.c
Generated by
1.9.8