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/ImageButton.cpp
- Revision:
- 9:ce69a7adfe9c
- Parent:
- 6:7917b0894655
- Child:
- 11:265884fa7fdd
--- a/Application/ImageButton.cpp Sat Jan 17 14:07:25 2015 +0100 +++ b/Application/ImageButton.cpp Tue Jan 20 09:05:30 2015 +0100 @@ -23,31 +23,33 @@ ImageButton::ImageButton(COLOR_T* fb, uint16_t x, uint16_t y, uint16_t width, uint16_t height) : Clickable(fb, x, y, width, height) { + _imgUp.pointerToFree = NULL; _imgUp.pixels = NULL; + _imgDown.pointerToFree = NULL; _imgDown.pixels = NULL; } ImageButton::~ImageButton() { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } } bool ImageButton::loadImages(const char* imgUp, const char* imgDown) { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } if (Image::decode(imgUp, Image::RES_16BIT, &_imgUp) != 0) { DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp); @@ -65,13 +67,13 @@ bool ImageButton::loadImages(const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown, unsigned int imgDownSize) { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } if (Image::decode(imgUp, imgUpSize, Image::RES_16BIT, &_imgUp) != 0) { DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp);