]> git.draconx.ca Git - liblbx.git/blobdiff - src/gui/render.c
liblbx: Don't scale palette values internally.
[liblbx.git] / src / gui / render.c
index e30e6c845623feb011fb8397ce05bb80807a6434..a96cc06a0b0e83f03b6f80ca944d6e48e70186f5 100644 (file)
@@ -29,6 +29,13 @@ struct lbx_colour palette_external[256];
 struct lbx_colour palette_internal[256];
 struct lbx_colour palette_override[256];
 
+static inline unsigned scale6to8(unsigned x)
+{
+       assert(x <= 0x3f);
+
+       return x*0xff / 0x3f;
+}
+
 static void get_colour(unsigned char index, unsigned char out[static 4])
 {
        struct lbx_colour *colour;
@@ -40,11 +47,11 @@ static void get_colour(unsigned char index, unsigned char out[static 4])
        else if (palette_external[index].active)
                colour = palette_external + index;
        else
-               colour = &(struct lbx_colour) { .red = 0xff, .blue = 0xff };
+               colour = &(struct lbx_colour) { .red = 0x3f, .blue = 0x3f };
 
-       out[0] = colour->red;
-       out[1] = colour->green;
-       out[2] = colour->blue;
+       out[0] = scale6to8(colour->red);
+       out[1] = scale6to8(colour->green);
+       out[2] = scale6to8(colour->blue);
        out[3] = -1; /* opaque */
 }