diff options
Diffstat (limited to 'src/gdisp/gdisp_image_bmp.c')
-rw-r--r-- | src/gdisp/gdisp_image_bmp.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/gdisp/gdisp_image_bmp.c b/src/gdisp/gdisp_image_bmp.c index 371fdf2d..2ea4e95f 100644 --- a/src/gdisp/gdisp_image_bmp.c +++ b/src/gdisp/gdisp_image_bmp.c @@ -829,4 +829,65 @@ delaytime_t gdispImageNext_BMP(gdispImage *img) { return TIME_INFINITE; } +uint16_t 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, uint16_t 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 >= priv->palsize) + return 0; + + return priv->palette[(uint8_t)index]; + + #else + return 0; + #endif +} + +bool_t gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t 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 >= priv->palsize) + return FALSE; + + priv->palette[(uint8_t)index] = newColor; + + return TRUE; + + #else + return 0; + #endif +} + #endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE && GDISP_NEED_IMAGE_BMP */ |