Add PNG image support - Does not support interlaced PNG's
This commit is contained in:
parent
ecc7f94c88
commit
583b022657
@ -43,17 +43,18 @@
|
||||
#define GDISP_NEED_VALIDATION TRUE
|
||||
#define GDISP_NEED_CLIP TRUE
|
||||
#define GDISP_NEED_IMAGE TRUE
|
||||
#define GDISP_STARTUP_COLOR HTML2COLOR(0xC0C0C0)
|
||||
|
||||
/* GDISP image decoders */
|
||||
#define GDISP_NEED_IMAGE_NATIVE FALSE
|
||||
#define GDISP_NEED_IMAGE_GIF FALSE
|
||||
//#define GDISP_NEED_IMAGE_NATIVE TRUE
|
||||
//#define GDISP_NEED_IMAGE_GIF TRUE
|
||||
#define GDISP_NEED_IMAGE_BMP TRUE
|
||||
#define GDISP_NEED_IMAGE_JPG FALSE
|
||||
#define GDISP_NEED_IMAGE_PNG FALSE
|
||||
//#define GDISP_NEED_IMAGE_JPG TRUE
|
||||
//#define GDISP_NEED_IMAGE_PNG TRUE
|
||||
|
||||
#define GFX_USE_GFILE TRUE
|
||||
#define GFILE_NEED_ROMFS TRUE
|
||||
//#define GFILE_NEED_NATIVEFS TRUE
|
||||
//#define GFILE_NEED_NATIVEFS TRUE
|
||||
|
||||
#endif /* _GFXCONF_H */
|
||||
|
||||
|
@ -107,16 +107,31 @@
|
||||
// #define GDISP_NEED_IMAGE_NATIVE FALSE
|
||||
// #define GDISP_NEED_IMAGE_GIF FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_1 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_4 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_8 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_16 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_24 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_32 FALSE
|
||||
// #define GDISP_NEED_IMAGE_BMP_1 TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_4 TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_4_RLE TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_8_RLE TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_16 TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_24 TRUE
|
||||
// #define GDISP_NEED_IMAGE_BMP_32 TRUE
|
||||
// #define GDISP_NEED_IMAGE_JPG FALSE
|
||||
// #define GDISP_NEED_IMAGE_PNG FALSE
|
||||
// #define GDISP_NEED_IMAGE_PNG_INTERLACED FALSE
|
||||
// #define GDISP_NEED_IMAGE_PNG_TRANSPARENCY TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_BACKGROUND TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_ALPHACLIFF 32
|
||||
// #define GDISP_NEED_IMAGE_PNG_PALETTE_124 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_PALETTE_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_124 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_16 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_GRAYALPHA_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_GRAYALPHA_16 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_RGB_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_RGB_16 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_8 TRUE
|
||||
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE
|
||||
// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
|
||||
|
||||
//#define GDISP_NEED_PIXMAP FALSE
|
||||
|
@ -154,6 +154,16 @@ gdispImageError gdispImageCache(gdispImage *img) {
|
||||
|
||||
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy) {
|
||||
if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT;
|
||||
|
||||
// Check on window
|
||||
if (cx <= 0 || cy <= 0) return GDISP_IMAGE_ERR_OK;
|
||||
if (sx < 0) sx = 0;
|
||||
if (sy < 0) sy = 0;
|
||||
if (sx >= img->width || sy >= img->height) return GDISP_IMAGE_ERR_OK;
|
||||
if (sx + cx > img->width) cx = img->width - sx;
|
||||
if (sy + cy > img->height) cy = img->height - sy;
|
||||
|
||||
// Draw
|
||||
return img->fns->draw(g, img, x, y, cx, cy, sx, sy);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -380,6 +380,127 @@
|
||||
#ifndef GDISP_NEED_IMAGE_BMP_32
|
||||
#define GDISP_NEED_IMAGE_BMP_32 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @name GDISP PNG Image Options
|
||||
* @pre GDISP_NEED_IMAGE and GDISP_NEED_IMAGE_PNG must be TRUE
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Is PNG Interlaced image decoding required.
|
||||
* @details Defaults to FALSE
|
||||
* @note Currently not supported due to the complex decoding and display requirements
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_INTERLACED
|
||||
#define GDISP_NEED_IMAGE_PNG_INTERLACED FALSE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is PNG image transparency processed.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_TRANSPARENCY
|
||||
#define GDISP_NEED_IMAGE_PNG_TRANSPARENCY TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is PNG background data processed.
|
||||
* @details Defaults to TRUE
|
||||
* @note If the background is specified in the image file and this define is TRUE,
|
||||
* that background color is used for transparency and alpha blending.
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_BACKGROUND
|
||||
#define GDISP_NEED_IMAGE_PNG_BACKGROUND TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief What is the cliff between non-blended alpha pixels being displayed or not.
|
||||
* @details Range of 0 to 255
|
||||
* @note If GDISP_NEED_IMAGE_PNG_BACKGROUND is TRUE and the PNG file contains a
|
||||
* background color then the pixel will be blended with the background color
|
||||
* according to the alpha.
|
||||
* If not then no blending occurs. The pixel will either be set or not.
|
||||
* Any alpha value greater or equal to this number will be displayed.
|
||||
* Anything less than this number is not displayed.
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_ALPHACLIFF
|
||||
#define GDISP_NEED_IMAGE_PNG_ALPHACLIFF 32
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 1, 2 and 4 bit PNG palettized image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_PALETTE_124
|
||||
#define GDISP_NEED_IMAGE_PNG_PALETTE_124 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 8 bit PNG palettized image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_PALETTE_8
|
||||
#define GDISP_NEED_IMAGE_PNG_PALETTE_8 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 1,2 and 4 bit PNG grayscale image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_GRAYSCALE_124
|
||||
#define GDISP_NEED_IMAGE_PNG_GRAYSCALE_124 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 8 bit PNG grayscale image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_GRAYSCALE_8
|
||||
#define GDISP_NEED_IMAGE_PNG_GRAYSCALE_8 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 16 bit PNG grayscale image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_GRAYSCALE_16
|
||||
#define GDISP_NEED_IMAGE_PNG_GRAYSCALE_16 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 8 bit PNG grayscale with 8 bit alpha image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_GRAYALPHA_8
|
||||
#define GDISP_NEED_IMAGE_PNG_GRAYALPHA_8 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 16 bit PNG grayscale with 16 bit alpha image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_GRAYALPHA_16
|
||||
#define GDISP_NEED_IMAGE_PNG_GRAYALPHA_16 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 8/8/8 bit PNG RGB image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_RGB_8
|
||||
#define GDISP_NEED_IMAGE_PNG_RGB_8 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 16/16/16 bit PNG RGB image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_RGB_16
|
||||
#define GDISP_NEED_IMAGE_PNG_RGB_16 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 8/8/8 bit PNG RGB with 8 bit alpha image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_RGBALPHA_8
|
||||
#define GDISP_NEED_IMAGE_PNG_RGBALPHA_8 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @brief Is 16/16/16 bit PNG RGB with 16 bit alpha image decoding required.
|
||||
* @details Defaults to TRUE
|
||||
*/
|
||||
#ifndef GDISP_NEED_IMAGE_PNG_RGBALPHA_16
|
||||
#define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user