-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppm.h
42 lines (32 loc) · 836 Bytes
/
ppm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef PPM_H
#define PPM_H
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
int min(int l, int r);
int max(int l, int r);
int clamp(int in, int less, int greater);
typedef struct {
int width;
int height;
} PPM_Header;
typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
} PPM_Pixel;
typedef struct {
PPM_Header header;
PPM_Pixel* buffer;
} PPM_Image;
PPM_Pixel ppm_rgb(int r, int g, int b);
PPM_Image* ppm_create(int w, int h);
void ppm_destroy(PPM_Image* img);
void ppm_set_pixel(PPM_Image* img, int x, int y, PPM_Pixel pixel);
void ppm_set_rgb(PPM_Image* img, int x, int y, int r, int g, int b);
PPM_Pixel ppm_get_pixel(const PPM_Image* img, int x, int y);
void ppm_save(PPM_Image* img, const char* filename);
PPM_Image* ppm_load(const char* filename);
#endif //PPM_H