diff options
author | Joel Bodenmann <joel@embedded.pro> | 2016-11-10 23:00:31 +0100 |
---|---|---|
committer | Joel Bodenmann <joel@embedded.pro> | 2016-11-10 23:00:31 +0100 |
commit | 386e49480d449596b6f878c572241470a1cf9577 (patch) | |
tree | 7e029b66778875833bc2a9fd2ee5e947b6f73486 /src/gdisp/gdisp_image_bmp.c | |
parent | 2cf23ca69b188a89105fe7e06b655020409cee12 (diff) | |
download | uGFX-386e49480d449596b6f878c572241470a1cf9577.tar.gz uGFX-386e49480d449596b6f878c572241470a1cf9577.tar.bz2 uGFX-386e49480d449596b6f878c572241470a1cf9577.zip |
Adding ability to modify the color palette of BMP images (untested)
Diffstat (limited to 'src/gdisp/gdisp_image_bmp.c')
-rw-r--r-- | src/gdisp/gdisp_image_bmp.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/gdisp/gdisp_image_bmp.c b/src/gdisp/gdisp_image_bmp.c index 371fdf2d..f8ac07ab 100644 --- a/src/gdisp/gdisp_image_bmp.c +++ b/src/gdisp/gdisp_image_bmp.c @@ -829,4 +829,73 @@ delaytime_t gdispImageNext_BMP(gdispImage *img) { return TIME_INFINITE; } +int gdispImageGetPaletteSize_BMP(gdispImage *img) { + #if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8 + gdispImagePrivate_BMP *priv; + + priv = (gdispImagePrivate_BMP *)img->priv; + if (!priv) { + return 0; + } + + if (!(priv->bmpflags & BMP_PALETTE)) { + return 0; + } + + return priv->palsize; + #else + return 0; + #endif +} + +color_t gdispImageGetPalette_BMP(gdispImage *img, int index) { + #if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8 + gdispImagePrivate_BMP *priv; + + priv = (gdispImagePrivate_BMP *)img->priv; + if (!priv) { + return 0; + } + + if (!(priv->bmpflags & BMP_PALETTE)) { + return 0; + } + + if (index < 0 || index >= priv->palsize) { + return 0; + } + + return priv->palette[index]; + + #else + return 0; + #endif +} + +bool_t gdispImageAdjustPalette_BMP(gdispImage *img, int index, color_t newColor) { + #if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8 + gdispImagePrivate_BMP *priv; + + priv = (gdispImagePrivate_BMP *)img->priv; + if (!priv) { + return FALSE; + } + + if (!(priv->bmpflags & BMP_PALETTE)) { + return FALSE; + } + + if (index < 0 || index >= priv->palsize) { + return FALSE; + } + + priv->palette[index] = newColor; + + return TRUE; + + #else + return 0; + #endif +} + #endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE && GDISP_NEED_IMAGE_BMP */ |