aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdisp/gdisp_image.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@embedded.pro>2016-11-11 18:28:48 +0100
committerJoel Bodenmann <joel@embedded.pro>2016-11-11 18:28:48 +0100
commitebfe1e95a240cdd29d295522f002325c65df622b (patch)
tree44f0f55177a0d950df46bbdfedbb8bfea4f5daee /src/gdisp/gdisp_image.c
parent386e49480d449596b6f878c572241470a1cf9577 (diff)
downloaduGFX-ebfe1e95a240cdd29d295522f002325c65df622b.tar.gz
uGFX-ebfe1e95a240cdd29d295522f002325c65df622b.tar.bz2
uGFX-ebfe1e95a240cdd29d295522f002325c65df622b.zip
Minor changes & improvements on image color palletization handling
Diffstat (limited to 'src/gdisp/gdisp_image.c')
-rw-r--r--src/gdisp/gdisp_image.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gdisp/gdisp_image.c b/src/gdisp/gdisp_image.c
index 13001d5c..347ed6aa 100644
--- a/src/gdisp/gdisp_image.c
+++ b/src/gdisp/gdisp_image.c
@@ -33,9 +33,9 @@
extern gdispImageError gdispImageCache_BMP(gdispImage *img);
extern gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
extern delaytime_t gdispImageNext_BMP(gdispImage *img);
- extern int gdispImageGetPaletteSize_BMP(gdispImage *img);
- extern color_t gdispImageGetPalette_BMP(gdispImage *img, int index);
- extern bool_t gdispImageAdjustPalette_BMP(gdispImage *img, int index, color_t newColor);
+ extern uint16_t gdispImageGetPaletteSize_BMP(gdispImage *img);
+ extern color_t gdispImageGetPalette_BMP(gdispImage *img, uint16_t index);
+ extern bool_t gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, color_t newColor);
#endif
#if GDISP_NEED_IMAGE_JPG
@@ -65,9 +65,9 @@ typedef struct gdispImageHandlers {
coord_t cx, coord_t cy,
coord_t sx, coord_t sy); /* The draw function */
delaytime_t (*next)(gdispImage *img); /* The next frame function */
- int (*getPaletteSize)(gdispImage *img); /* Retrieve the size of the palette (number of entries) */
- color_t (*getPalette)(gdispImage *img, int index); /* Retrieve a specific color value of the palette */
- bool_t (*adjustPalette)(gdispImage *img, int index, color_t newColor); /* Replace a color value in the palette */
+ uint16_t (*getPaletteSize)(gdispImage *img); /* Retrieve the size of the palette (number of entries) */
+ color_t (*getPalette)(gdispImage *img, uint16_t index); /* Retrieve a specific color value of the palette */
+ bool_t (*adjustPalette)(gdispImage *img, uint16_t index, color_t newColor); /* Replace a color value in the palette */
} gdispImageHandlers;
static gdispImageHandlers ImageHandlers[] = {
@@ -183,6 +183,25 @@ delaytime_t gdispImageNext(gdispImage *img) {
return img->fns->next(img);
}
+uint16_t gdispImageGetPaletteSize(gdispImage *img) {
+ if (!img->fns) return 0;
+ if (!img->fns->getPaletteSize) return 0;
+ return img->fns->getPaletteSize(img);
+}
+
+color_t gdispImageGetPalette(gdispImage *img, uint16_t index) {
+ if (!img->fns) return 0;
+ if (!img->fns->getPalette) return 0;
+ return img->fns->getPalette(img, index);
+}
+
+bool_t gdispImageAdjustPalette(gdispImage *img, uint16_t index, color_t newColor) {
+ if (!img->fns) return FALSE;
+ if (!img->fns->adjustPalette) return FALSE;
+ return img->fns->adjustPalette(img, index, newColor);
+}
+
+
// Helper Routines
void *gdispImageAlloc(gdispImage *img, size_t sz) {
#if GDISP_NEED_IMAGE_ACCOUNTING