Revision 213
changed font to take less space
proj/src/font.c | ||
---|---|---|
19 | 19 |
if(ret == NULL) return NULL; |
20 | 20 |
enum xpm_image_type type = XPM_8_8_8_8; |
21 | 21 |
xpm_image_t img; |
22 |
ret->map = xpm_load((xpm_map_t)xpm, type, &img); |
|
23 |
if(ret->map == NULL){ |
|
22 |
ret->map = NULL; |
|
23 |
uint8_t *map = xpm_load((xpm_map_t)xpm, type, &img); |
|
24 |
if(map == NULL){ |
|
24 | 25 |
free(ret); |
25 | 26 |
return NULL; |
26 | 27 |
} |
27 | 28 |
ret->w = img.width; |
28 | 29 |
ret->h = img.height; |
30 |
ret->map = malloc(ret->w*ret->h*sizeof(uint8_t)); |
|
31 |
if(ret->map == NULL){ |
|
32 |
free(ret); |
|
33 |
return NULL; |
|
34 |
} |
|
35 |
for(unsigned i = 0; i < ret->w*ret->h; ++i){ |
|
36 |
ret->map[i] = map[4*i+3]; |
|
37 |
} |
|
29 | 38 |
return ret; |
30 | 39 |
} |
31 | 40 |
static void (glyph_dtor)(glyph_t *p){ |
... | ... | |
37 | 46 |
if(p == NULL) return NULL_PTR; |
38 | 47 |
for(int16_t h = 0; h < p->h; ++h){ |
39 | 48 |
for(int16_t w = 0; w < p->w; ++w){ |
40 |
uint32_t c = *((uint32_t*)p->map + w + h*p->w); |
|
41 |
uint8_t a = GET_ALP(c); |
|
42 |
|
|
49 |
uint8_t a = *(p->map + w + h*p->w); |
|
43 | 50 |
int16_t x_ = x+w, y_ = y-p->h+h; |
44 | 51 |
unsigned pos = x_ +y_*W; |
45 | 52 |
alp_buf[pos] = a; |
Also available in: Unified diff