blob: d4f51817efe155eb0a11fe37bba53a8fafadd12f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "image.h"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#define STBI_NO_LINEAR
#define STBI_NO_HDR
#define STBI_MAX_DIMENSIONS 4096
#include "../third_party/stb/stb_image.h"
unsigned char *image_read_rgb(const char *path, int *width, int *height) {
if (!path || !width || !height)
return NULL;
int w, h, channels;
unsigned char *rgb = stbi_load(path, &w, &h, &channels, 3);
if (!rgb)
return NULL;
*width = w;
*height = h;
return rgb;
}
|