-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.h
65 lines (52 loc) · 1.25 KB
/
image.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __IMAGE_H__
#define __IMAGE_H__
#include <stdint.h>
#include <time.h>
#include "equation.h"
#define IMG_N 6
#define IMG_W 200
#define IMG_H 200
#define IMG_M_256 0
#define IMG_M_LIN 1
#define IMG_R_RGB 0
#define IMG_R_SR 1
#define IMG_R_SG 2
#define IMG_R_SB 3
#define IMG_R_CR 4
#define IMG_R_CG 5
#define IMG_R_CB 6
#define build_channel(name, type) \
typedef union __##name { \
struct { type r,g,b; } __attribute__((packed)); \
type chan[3]; \
} name
build_channel(pixel_t, uint8_t);
build_channel(eval_t, double);
build_channel(equations_t, equ_t);
typedef uint8_t (*modifier_t)(equ_t*, double);
typedef struct image
{
union
{
pixel_t pixel_at[IMG_H][IMG_W];
pixel_t pixels[IMG_W*IMG_H];
uint8_t bytes[IMG_W*IMG_H*sizeof(pixel_t)];
};
union
{
eval_t eval_at[IMG_H][IMG_W];
eval_t evals[IMG_W*IMG_H];
};
modifier_t modifier;
int renderer;
time_t birth;
equations_t equ;
void *gui;
} image_t;
void image_new(size_t, int, int);
image_t* image_get(size_t);
void image_set_modifier(image_t*, int);
void image_set_renderer(image_t*, int);
void image_render(image_t*);
void image_save(size_t, char*);
#endif