-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadpng.c
More file actions
39 lines (36 loc) · 1.36 KB
/
loadpng.c
File metadata and controls
39 lines (36 loc) · 1.36 KB
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
void Swap_Image(unsigned char *img, unsigned w, unsigned h) {
unsigned i, j, h2 = h / 2, h3 = h - 1, w2 = w * 4;
unsigned char *tmp, *tmp2, t;
for (i = 0; i < h2; ++i) {
tmp = img + i * w2;
tmp2 = img + (h3 - i) * w2;
for (j = 0; j < w; ++j) {
t = *tmp; *tmp = *tmp2; *tmp2 = t; ++tmp; ++tmp2;
t = *tmp; *tmp = *tmp2; *tmp2 = t; ++tmp; ++tmp2;
t = *tmp; *tmp = *tmp2; *tmp2 = t; ++tmp; ++tmp2;
t = *tmp; *tmp = *tmp2; *tmp2 = t; ++tmp; ++tmp2;
}
}
}
// void Swap_Image(unsigned char *img, unsigned w, unsigned h) {
// int i, j, k, h2 = h / 2, h3 = (h - 1) * 4 * w, l, m;
// unsigned char tmp;
// for (i = 0; i < h2; i++) {
// for (j = 0; j < w; j++) {
// l = (i * w + j) * 4;
// m = h3 - (i * w - j) * 4;
// for (k = 0; k < 4; k++) {
// tmp = *(img + l + k);
// *(img + l + k) = *(img + m + k);
// *(img + m + k) = tmp;
// }
// }
// }
// }
void Load_Png(unsigned char **img, unsigned *w, unsigned *h, const char *filename) {
lodepng_decode_file(img, w, h, filename, LCT_RGBA, 8);
}
void Load_Png_Swap(unsigned char **img, unsigned *w, unsigned *h, const char *filename) {
lodepng_decode_file(img, w, h, filename, LCT_RGBA, 8);
Swap_Image(*img, *w, *h);
}