aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdisp/gdisp_image.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@embedded.pro>2016-11-11 19:09:34 +0100
committerJoel Bodenmann <joel@embedded.pro>2016-11-11 19:09:34 +0100
commitb60383c03e8ddd0fb2f24f597fd15c787653d652 (patch)
tree194d64c2386f29f6b6faea429ac13c2f2bd35f92 /src/gdisp/gdisp_image.c
parentc91f42ec85a2c2f127663c0b0a9f11f11a6660b8 (diff)
parent477aa8e87872ae79e568e1a1d5468c614fc1c457 (diff)
downloaduGFX-b60383c03e8ddd0fb2f24f597fd15c787653d652.tar.gz
uGFX-b60383c03e8ddd0fb2f24f597fd15c787653d652.tar.bz2
uGFX-b60383c03e8ddd0fb2f24f597fd15c787653d652.zip
Merge branch 'image_palette'
Diffstat (limited to 'src/gdisp/gdisp_image.c')
-rw-r--r--src/gdisp/gdisp_image.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/gdisp/gdisp_image.c b/src/gdisp/gdisp_image.c
index 356ba64f..347ed6aa 100644
--- a/src/gdisp/gdisp_image.c
+++ b/src/gdisp/gdisp_image.c
@@ -33,6 +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 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
@@ -53,41 +56,49 @@
/* The structure defining the routines for image drawing */
typedef struct gdispImageHandlers {
- gdispImageError (*open)(gdispImage *img); /* The open function */
- void (*close)(gdispImage *img); /* The close function */
- gdispImageError (*cache)(gdispImage *img); /* The cache function */
+ gdispImageError (*open)(gdispImage *img); /* The open function */
+ void (*close)(gdispImage *img); /* The close function */
+ gdispImageError (*cache)(gdispImage *img); /* The cache function */
gdispImageError (*draw)(GDisplay *g,
gdispImage *img,
coord_t x, coord_t y,
coord_t cx, coord_t cy,
- coord_t sx, coord_t sy); /* The draw function */
- delaytime_t (*next)(gdispImage *img); /* The next frame function */
+ coord_t sx, coord_t sy); /* The draw function */
+ delaytime_t (*next)(gdispImage *img); /* The next frame function */
+ 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[] = {
#if GDISP_NEED_IMAGE_NATIVE
{ gdispImageOpen_NATIVE, gdispImageClose_NATIVE,
gdispImageCache_NATIVE, gdispGImageDraw_NATIVE, gdispImageNext_NATIVE,
+ 0, 0, 0
},
#endif
#if GDISP_NEED_IMAGE_GIF
{ gdispImageOpen_GIF, gdispImageClose_GIF,
gdispImageCache_GIF, gdispGImageDraw_GIF, gdispImageNext_GIF,
+ 0, 0, 0
},
#endif
#if GDISP_NEED_IMAGE_BMP
- { gdispImageOpen_BMP, gdispImageClose_BMP,
- gdispImageCache_BMP, gdispGImageDraw_BMP, gdispImageNext_BMP,
+ { gdispImageOpen_BMP, gdispImageClose_BMP,
+ gdispImageCache_BMP, gdispGImageDraw_BMP, gdispImageNext_BMP,
+ gdispImageGetPaletteSize_BMP, gdispImageGetPalette_BMP, gdispImageAdjustPalette_BMP
},
#endif
#if GDISP_NEED_IMAGE_JPG
{ gdispImageOpen_JPG, gdispImageClose_JPG,
gdispImageCache_JPG, gdispGImageDraw_JPG, gdispImageNext_JPG,
+ 0, 0, 0
},
#endif
#if GDISP_NEED_IMAGE_PNG
{ gdispImageOpen_PNG, gdispImageClose_PNG,
gdispImageCache_PNG, gdispGImageDraw_PNG, gdispImageNext_PNG,
+ 0, 0, 0
},
#endif
};
@@ -172,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