From: Nick Bowler Date: Sun, 7 Feb 2010 22:11:26 +0000 (-0500) Subject: liblbx: Add a field to lbx_colour indicating which entries are used. X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/84050ee438ba1661047709f3c8b95b126ca10f93?hp=4aed5deccace2e80cf7efa80ab451628c3ca2c3b liblbx: Add a field to lbx_colour indicating which entries are used. 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. --- diff --git a/src/image.c b/src/image.c index d583145..c8a7165 100644 --- a/src/image.c +++ b/src/image.c @@ -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, }; } diff --git a/src/image.h b/src/image.h index 5369e0a..e12372b 100644 --- a/src/image.h +++ b/src/image.h @@ -10,6 +10,7 @@ struct lbx_colour { unsigned char red; unsigned char green; unsigned char blue; + unsigned char active; }; struct lbx_imginfo {