summaryrefslogtreecommitdiff
path: root/xcbviewfs.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2012-09-27 23:07:51 +0200
committerPeter Wu <lekensteyn@gmail.com>2012-09-27 23:07:51 +0200
commit404f75edd88560f7c5ab76c0e083d0c44a92fb58 (patch)
tree78df13dac5d4f9b76c896c32c46cc08900ec5356 /xcbviewfs.c
parentb93811ee1ccb2a571764e28528482e34c95f182a (diff)
downloadc-files-404f75edd88560f7c5ab76c0e083d0c44a92fb58.tar.gz
xcbviewfs: fix colors
RGB is BGR apparently, also forgot to ignore the first # of a hex color.
Diffstat (limited to 'xcbviewfs.c')
-rw-r--r--xcbviewfs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/xcbviewfs.c b/xcbviewfs.c
index e7ab1d6..157d68d 100644
--- a/xcbviewfs.c
+++ b/xcbviewfs.c
@@ -240,14 +240,14 @@ static void xpm_parse_color_line(char *line, uint8_t color[3]) {
if (search_color) {
if (line[0] == '#') {
- unsigned int hex = strtol(line, NULL, 16);
+ unsigned int hex = strtol(line + 1, NULL, 16);
if (strlen(line) == 4) { /* #RGB */
color[0] = ((hex >> 2) & 0xF) * 0x11;
color[1] = ((hex >> 1) & 0xF) * 0x11;
color[2] = (hex & 0xF) * 0x11;
} else { /* assume #RRGGBB */
- color[0] = (hex >> 8) & 0xFF;
- color[1] = (hex >> 4) & 0xFF;
+ color[0] = (hex >>16) & 0xFF;
+ color[1] = (hex >> 8) & 0xFF;
color[2] = hex & 0xFF;
}
return;
@@ -352,7 +352,11 @@ static int load_xpm_image(char *filename, unsigned char **data,
while (color && color->key != key)
color = color->next;
if (color) {
- memcpy(data_line + 4 * x, color->color, cpp);
+ uint8_t *c = color->color;
+ unsigned char *p = data_line + 4 * x;
+ *(p++) = c[2]; /* b */
+ *(p++) = c[1]; /* g */
+ *(p++) = c[0]; /* r */
} else {
fprintf(stderr, "No color found\n");
}