-
Notifications
You must be signed in to change notification settings - Fork 0
/
clext.c
59 lines (43 loc) · 953 Bytes
/
clext.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
#include <errno.h>
#include <string.h>
#include "bmp.h"
#include "io.h"
int progress = 0;
void unpackCB(LONG id, LONG width, LONG height, BYTE *rgbBuf) {
struct writer_t *w;
struct bmp24_writer_t *bw;
FILE *f;
char fn[256];
if (rgbBuf == NULL)
return;
sprintf(fn, "out/%d.bmp", id);
f = fopen(fn, "wb");
if (f == NULL) {
fprintf(stderr, "Failed to open %s for writing: %s\n", fn, strerror(errno));
exit(1);
}
w = newWriter(f);
bw = newBMP24Writer(w, width, height);
writeBMP24Header(bw);
writeBMP24Bitmap(bw, rgbBuf);
deleteBMP24Writer(bw);
deleteWriter(w);
fclose(f);
if (progress % 10 == 0)
fprintf(stderr, "%d..\n", progress);
progress++;
}
int main(void) {
FILE *f;
struct reader_t *r;
f = fopen("CL_Images", "rb");
if (f == NULL) {
fprintf(stderr, "Failed to open CL_Images: %s\n", strerror(errno));
return 1;
}
r = newReader(f);
unpack(r, unpackCB);
deleteReader(r);
fclose(f);
return 0;
}