2 #error "XPM_FILE undefined"
6 #error "XPM_NAME undefined"
9 #define STRINGIFY_I(x) #x
10 #define STRINGIFY(x) STRINGIFY_I(x)
12 #include STRINGIFY(XPM_FILE)
20 int width
, height
, color_count
, foo
;
24 if(4 != sscanf(XPM_NAME
[0], "%d %d %d %d", &width
, &height
, &color_count
, &foo
)) {
25 fputs("Fehler beim Parsen der Dimensionen\n", stderr
);
29 for(int i
= 0; i
< color_count
; ++i
) {
30 size_t len
= strlen((char*) XPM_NAME
[i
+ 1]);
31 if(len
> 7 && strcmp((char*) XPM_NAME
[i
+ 1] + len
- 7, "#000000") == 0) {
32 black
= XPM_NAME
[i
+ 1][0];
38 fputs("Konnte Schwarz nicht identifizieren.\n", stderr
);
42 data
= calloc(width
* height
/ 8 + 1, 1);
44 printf("{ %d, %d, (uint8_t const *) \"", width
, height
);
50 for(x
= 0; x
< width
; ++x
) {
51 for(y
= 0; y
< height
; ++y
) {
52 data
[i
/ 8] |= (XPM_NAME
[y
+ 1 + color_count
][x
] == black
) << i
% 8;
57 for(j
= 0; j
< i
/ 8 + (i
% 8 != 0); ++j
) {
58 printf("\\x%02x", data
[j
]);
This page took 0.049898 seconds and 5 git commands to generate.