From a02c124940b6c5d61ffcbfb2c7e4d493775c3192 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Sat, 20 Apr 2013 21:19:26 +1000 Subject: GIF image handling GIF image handling Updates to Image structure to make memory accounting optional Add set image background color to handle animated transparency. --- include/gdisp/image.h | 20 +++++++++++++++++++- include/gdisp/options.h | 7 +++++++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'include/gdisp') diff --git a/include/gdisp/image.h b/include/gdisp/image.h index 49b10d42..99e51118 100644 --- a/include/gdisp/image.h +++ b/include/gdisp/image.h @@ -113,9 +113,13 @@ typedef struct gdispImageIO { typedef struct gdispImage { gdispImageType type; /* @< The image type */ gdispImageFlags flags; /* @< The image flags */ + color_t bgcolor; /* @< The default background color */ coord_t width, height; /* @< The image dimensions */ gdispImageIO io; /* @< The image IO functions */ - uint32_t membytes; /* @< How much RAM has been allocated */ + #if GDISP_NEED_IMAGE_ACCOUNTING + uint32_t memused; /* @< How much RAM is currently allocated */ + uint32_t maxmemused; /* @< How much RAM has been allocated (maximum) */ + #endif const struct gdispImageHandlers * fns; /* @< Don't mess with this! */ struct gdispImagePrivate * priv; /* @< Don't mess with this! */ } gdispImage; @@ -176,6 +180,7 @@ extern "C" { * * @note This determines which decoder to use and then initialises all other fields * in the gdispImage structure. + * @note The image background color is set to White. * @note There are three types of return - everything OK, partial success and unrecoverable * failures. For everything OK it returns GDISP_IMAGE_ERR_OK. A partial success can * be distinguished from a unrecoverable failure by testing the GDISP_IMAGE_ERR_UNRECOVERABLE @@ -197,6 +202,19 @@ extern "C" { * @note Also calls the IO close function (if it hasn't already been called). */ void gdispImageClose(gdispImage *img); + + /** + * @brief Set the background color of the image. + * + * @param[in] img The image structure + * @param[in] bgcolor The background color to use + * + * @pre gdispImageOpen() must have returned successfully. + * + * @note This color is only used when an image has to restore part of the background before + * continuing with drawing that includes transparency eg some GIF animations. + */ + void gdispImageSetBgColor(gdispImage *img, color_t bgcolor); /** * @brief Cache the image diff --git a/include/gdisp/options.h b/include/gdisp/options.h index deacc036..5cdfbf59 100644 --- a/include/gdisp/options.h +++ b/include/gdisp/options.h @@ -186,6 +186,13 @@ #ifndef GDISP_NEED_IMAGE_PNG #define GDISP_NEED_IMAGE_PNG FALSE #endif + /** + * @brief Is memory accounting required during image decoding. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_IMAGE_ACCOUNTING + #define GDISP_NEED_IMAGE_ACCOUNTING FALSE + #endif /** * @} * -- cgit v1.2.3