Commit 16f492a7668162cda0aa59a56f6efbe644b19295
Parse colors
Charles Lehner committed on 2/10/2015, 3:48:49 AMParent: b405534855170d670048928d59818e8c22f0375c
Files changed
pngspark.c | changed |
pngspark.c | ||
---|---|---|
@@ -7,11 +7,15 @@ | ||
7 | 7 … | |
8 | 8 … | |
9 | 9 … | static const size_t initial_size = 8; |
10 | 10 … | |
11 | -uint32_t parse_color(const char *color) | |
11 … | +uint32_t parse_color(const char *color_str) | |
12 | 12 … | { |
13 | - return !strcmp("black", color) ? 0xff000000 : 0xff999989; | |
13 … | + if (!color_str) return 0; | |
14 … | + if (color_str[0] == '#') color_str++; | |
15 … | + uint32_t color = strtol(color_str, NULL, 16); | |
16 … | + return 0xff000000 | | |
17 … | + ((color >> 16) | (color & 0x00ff00) | (color & 0xff) << 16); | |
14 | 18 … | } |
15 | 19 … | |
16 | 20 … | int pngspark_init(struct pngspark *ps, size_t height, const char *color) |
17 | 21 … | { |
@@ -63,9 +67,8 @@ | ||
63 | 67 … | int pngspark_write(struct pngspark *ps, FILE *file) |
64 | 68 … | { |
65 | 69 … | LuImage *img = luImageCreate(ps->num_values, ps->max_value+1, 4, 8); |
66 | 70 … | if (!img) return 1; |
67 | - printf("size: %zu\n", img->dataSize); | |
68 | 71 … | |
69 | 72 … | int ret = pngspark_draw(ps, (uint32_t *)img->data, ps->num_values, |
70 | 73 … | ps->max_value); |
71 | 74 … | if (!ret) |
Built with git-ssb-web