Adding GDISP_IMAGE_PNG_FILE_BUFFER_SIZE configuration option

release/v2.9
Joel Bodenmann 2017-01-10 10:39:07 +01:00
parent ff8aa09949
commit ffe01aef80
3 changed files with 15 additions and 11 deletions

View File

@ -137,6 +137,7 @@
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_8 TRUE // #define GDISP_NEED_IMAGE_PNG_RGBALPHA_8 TRUE
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE // #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE
// #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32 // #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32
// #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8
// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE // #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
//#define GDISP_NEED_PIXMAP FALSE //#define GDISP_NEED_PIXMAP FALSE

View File

@ -11,12 +11,6 @@
#include "gdisp_image_support.h" #include "gdisp_image_support.h"
/**
* How big a byte array to use for input file buffer
* Bigger is faster but uses more RAM.
* Must be more than 8 bytes
*/
#define PNG_FILE_BUFFER_SIZE 8
/** /**
* How big a byte array to use for inflate decompression * How big a byte array to use for inflate decompression
* Bigger is faster but uses more RAM. * Bigger is faster but uses more RAM.
@ -73,7 +67,7 @@ typedef struct PNG_input {
uint8_t *pbuf; // The pointer to the next byte uint8_t *pbuf; // The pointer to the next byte
uint32_t chunklen; // The number of bytes left in the current PNG chunk uint32_t chunklen; // The number of bytes left in the current PNG chunk
uint32_t chunknext; // The file position of the next PNG chunk uint32_t chunknext; // The file position of the next PNG chunk
uint8_t buf[PNG_FILE_BUFFER_SIZE]; // Must be a minimum of 8 bytes to hold a chunk header uint8_t buf[GDISP_IMAGE_PNG_FILE_BUFFER_SIZE]; // Must be a minimum of 8 bytes to hold a chunk header
} PNG_input; } PNG_input;
// Handle the display output and windowing // Handle the display output and windowing
@ -191,8 +185,8 @@ gotchunk:
// Try to read data some from the chunk // Try to read data some from the chunk
sz = d->i.chunklen; sz = d->i.chunklen;
if (sz > PNG_FILE_BUFFER_SIZE) if (sz > GDISP_IMAGE_PNG_FILE_BUFFER_SIZE)
sz = PNG_FILE_BUFFER_SIZE; sz = GDISP_IMAGE_PNG_FILE_BUFFER_SIZE;
if (gfileRead(d->i.f, d->i.buf, sz) != sz) if (gfileRead(d->i.f, d->i.buf, sz) != sz)
return FALSE; return FALSE;
d->i.chunklen -= sz; d->i.chunklen -= sz;

View File

@ -390,7 +390,7 @@
#endif #endif
/** /**
* @brief The BMP blit buffer size. * @brief The BMP blit buffer size.
* @details Defaults to TRUE * @details Defaults to 32
* @note Bigger is faster but requires more RAM. * @note Bigger is faster but requires more RAM.
* @note This must be greater than 40 bytes and 32 pixels as we read our headers into this space as well. * @note This must be greater than 40 bytes and 32 pixels as we read our headers into this space as well.
*/ */
@ -520,12 +520,21 @@
#endif #endif
/** /**
* @brief The PNG blit buffer size in pixels. * @brief The PNG blit buffer size in pixels.
* @details Defaults to TRUE * @details Defaults to 32
* @note Bigger is faster but requires more RAM. * @note Bigger is faster but requires more RAM.
*/ */
#ifndef GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE #ifndef GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE
#define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32 #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32
#endif #endif
/**
* @brief The PNG input file buffer size in bytes.
* @details Defaults to 8
* @note Bigger is faster but requires more RAM.
* @note Must be >= 8
*/
#ifndef GDISP_IMAGE_PNG_FILE_BUFFER_SIZE
#define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8
#endif
/** /**
* @} * @}
* *