-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimapi_devil.c
113 lines (77 loc) · 2.05 KB
/
imapi_devil.c
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <IL/il.h>
#include <math.h>
void ia_up() {
ilInit();
ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
}
void ia_down() {}
int ia_new(unsigned int width, unsigned int height, unsigned int* handle) {
ILboolean success;
ilGenImages(1, handle);
ilBindImage(*handle);
success = ilTexImage(width, height, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, NULL);
ilRegisterOrigin(IL_ORIGIN_UPPER_LEFT);
if(!success) {
return 0;
}
return 1;
}
int ia_new_grey(unsigned int width, unsigned int height, unsigned int* handle) {
ILboolean success;
ilGenImages(1, handle);
ilBindImage(*handle);
success = ilTexImage(width, height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, NULL);
ilRegisterOrigin(IL_ORIGIN_UPPER_LEFT);
if(!success) {
return 0;
}
return 1;
}
void ia_delete(unsigned int* handle) {
ilDeleteImages(1, handle);
}
int ia_load(const char* filename, unsigned int* handle) {
ILboolean success;
ilGenImages(1, handle);
ilBindImage(*handle);
success = ilLoadImage((ILstring)filename);
if(!success) {
return 0;
}
success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
if(!success) {
ilDeleteImages(1, handle);
return 0;
}
return 1;
}
int ia_save(const char* filename, unsigned int handle) {
ILboolean success;
ilBindImage(handle);
success = ilSaveImage((ILstring)filename);
if(!success) {
return 0;
}
return 1;
}
unsigned int ia_get_width(unsigned int handle) {
ilBindImage(handle);
return ilGetInteger(IL_IMAGE_WIDTH);
}
unsigned int ia_get_height(unsigned int handle) {
ilBindImage(handle);
return ilGetInteger(IL_IMAGE_HEIGHT);
}
unsigned char* ia_get_data(unsigned int handle) {
ilBindImage(handle);
return ilGetData();
}
int ia_copy(unsigned int src, unsigned int dest, unsigned int xsrc, unsigned int ysrc, unsigned int xdest, unsigned int ydest, unsigned int width, unsigned int height) {
unsigned char* srcdata = ia_get_data(src);
ilBindImage(dest);
//ilSetPixels
}
inline unsigned int ia_map(unsigned int x, unsigned int y, unsigned int width, int scale) {
return scale * (y * width + x);
}