A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
Diff: Application/Image.cpp
- Revision:
- 17:6e2abf107800
- Parent:
- 10:651861441108
diff -r feb669462368 -r 6e2abf107800 Application/Image.cpp --- a/Application/Image.cpp Mon Mar 09 14:24:54 2015 +0000 +++ b/Application/Image.cpp Fri Mar 20 14:25:46 2015 +0100 @@ -16,6 +16,7 @@ #include "mbed.h" #include "Image.h" +#include "Resource.h" #include "bmp.h" #include "lodepng.h" @@ -228,6 +229,30 @@ return result; } +int Image::decode(Resource* res, Resolution resolution, ImageData_t* pDataOut, Mutex* pLock) +{ + int result = 0; + if (res == NULL) { + result = 1; + } else { + // Load the image only if it is not already cached + if (res->_img.pixels == NULL) { + if (res->_isFile) { + result = decode(res->_filename, resolution, &res->_img, pLock); + } else { + result = decode(res->_data, res->_dataSize, resolution, &res->_img); + } + } + if ((result == 0) && (res->_img.pixels != NULL)) { + // Copy the cached copy to the user's data, but skip the pointerToFree + // as that would break the cache + memcpy(pDataOut, &res->_img, sizeof(ImageData_t)); + pDataOut->pointerToFree = NULL; + } + } + return result; +} + Image::Type Image::imageType(const unsigned char* pDataIn, unsigned int sizeIn) { if (sizeIn > 4)