-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
98 lines (80 loc) · 1.83 KB
/
main.c
File metadata and controls
98 lines (80 loc) · 1.83 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
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
#include <stdio.h>
#include <stdlib.h>
#include <Imlib2.h>
#include <string.h>
#include <arpa/inet.h>
Imlib_Image c;
Imlib_Image t;
int hal;
int hs;
int wm;
int i;
FILE *f;
int
main(int argc, char **argv)
{
hs = 0;
wm = 0;
for(i=3; i<argc; i+=3){
t = imlib_load_image(argv[i]);
imlib_context_set_image(t);
int h = imlib_image_get_height();
int w = imlib_image_get_width();
if(w > wm)
wm = w;
hs += h;
}
c = imlib_create_image(wm, hs);
int p = 0;
imlib_context_set_image(c);
imlib_image_set_has_alpha(1);
for(i=3; i<argc; i+=3){
t = imlib_load_image(argv[i]);
imlib_context_set_image(t);
int h = imlib_image_get_height();
int w = imlib_image_get_width();
imlib_context_set_image(c);
imlib_blend_image_onto_image(t, 1, 0, 0, w, h, 0, p, w, h);
p += h;
}
imlib_image_set_format("ff");
char file[47] = {0};
memmove(file, argv[1], strlen(argv[1]));
if(atoi(argv[2]))
strcat(file, ".cb");
else
strcat(file, ".ff");
imlib_save_image(file);
if(atoi(argv[2])){
f = fopen(file, "r+");
fseek(f, 0, SEEK_END);
}else{
char cf[47] = {0};
memmove(cf, argv[1], strlen(argv[1]));
strcat(cf, ".ca");
f = fopen(cf, "w");
}
fprintf(f, "%d\n", (argc-3)/3);
p = 0;
for(i=3; i<argc; i+=3){
t = imlib_load_image(argv[i]);
imlib_context_set_image(t);
int h = imlib_image_get_height();
int w = imlib_image_get_width();
fprintf(f, "%s: %d: %d: ", argv[i], atoi(argv[i+1]), atoi(argv[i+2]));
fprintf(f, "%f %f %f %f %f %f %f %f",
(float)w / (float)(wm) / atoi(argv[i+1]),
(float)p / (float)(hs),
(float)w / (float)(wm) / atoi(argv[i+1]),
(float)(p+h) / (float)(hs) / atoi(argv[i+2]),
0.0,
(float)(p+h) / (float)(hs) / atoi(argv[i+2]),
0.0,
(float)(p) / (float)(hs));
fprintf(f, "\n");
p += h;
}
if(atoi(argv[2]) == 0)
fprintf(f, "%s;\n", file);
fclose(f);
}