Fixed red and blue channels being swapped in palette.c

This commit is contained in:
rxi
2016-09-22 19:59:59 +01:00
parent 6ec66adf57
commit 17d17a80df
2 changed files with 3 additions and 3 deletions

View File

@@ -57,9 +57,9 @@ const char *image_init(image_t *self, const char *filename) {
int i;
for (i = 0; i < width * height; i++) {
unsigned char *p = data32 + i * 4;
int b = p[0];
int r = p[0];
int g = p[1];
int r = p[2];
int b = p[2];
int a = p[3];
int idx = palette_colorIdx(r, g, b);
if (idx < 0) {

View File

@@ -44,7 +44,7 @@ int palette_colorIdx(int r, int g, int b) {
palette_init();
/* Make 18bit rgb color (6bits per-channel) from 8bit channels */
unsigned color = ((r & 0xfc) << 10) | ((g & 0xfc) << 4) | ((b & 0xfc) >> 2);
unsigned color = ((b & 0xfc) << 10) | ((g & 0xfc) << 4) | ((r & 0xfc) >> 2);
/* Hash color */
unsigned h = hash(&color, sizeof(color));