]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Add a field to lbx_colour indicating which entries are used.
authorNick Bowler <nbowler@draconx.ca>
Sun, 7 Feb 2010 22:11:26 +0000 (17:11 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 8 Feb 2010 17:00:55 +0000 (12:00 -0500)
An LBX palette might not contain values for all 256 entries.  Currently,
there is no way to tell which entries were assigned when the palette is
retrieved from an image.  This patch adds an extra marker which can be
used to skip over unused palette entries.

src/image.c
src/image.h

index d58314544373a38ce86825d1ed4e511aa1044062..c8a71650fbb872f24a7a7140e8e96a43e4eaedc0 100644 (file)
@@ -341,9 +341,10 @@ int lbximg_loadpalette(FILE *f, struct lbx_colour palette[static 256])
                }
 
                palette[i] = (struct lbx_colour){
-                       .red   = entry[1] << 2,
-                       .green = entry[2] << 2,
-                       .blue  = entry[3] << 2,
+                       .red    = entry[1] << 2,
+                       .green  = entry[2] << 2,
+                       .blue   = entry[3] << 2,
+                       .active = 1,
                };
        }
 
@@ -368,7 +369,6 @@ lbximg_getpalette(struct lbx_image *img, struct lbx_colour palette[static 256])
 
        for (i = 0; i < img->palcount; i++) {
                rc = img->fops->read(entry, sizeof entry, img->f);
-
                if (rc < sizeof entry) {
                        goto readerr;
                }
@@ -379,9 +379,10 @@ lbximg_getpalette(struct lbx_image *img, struct lbx_colour palette[static 256])
                }
 
                palette[img->palstart + i] = (struct lbx_colour){
-                       .red   = entry[1] << 2,
-                       .green = entry[2] << 2,
-                       .blue  = entry[3] << 2,
+                       .red    = entry[1] << 2,
+                       .green  = entry[2] << 2,
+                       .blue   = entry[3] << 2,
+                       .active = 1,
                };
        }
 
index 5369e0aafbed4affb7ba4e0319664a0b3ee98f60..e12372b0842f21a773a8bd484c10d4f8ecc75b5d 100644 (file)
@@ -10,6 +10,7 @@ struct lbx_colour {
        unsigned char red;
        unsigned char green;
        unsigned char blue;
+       unsigned char active;
 };
 
 struct lbx_imginfo {