Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DMBasicGUI by
Diff: Application/ImageButton.cpp
- Revision:
- 4:a73760d09423
- Parent:
- 3:3fabfe3339b8
- Child:
- 6:7917b0894655
--- a/Application/ImageButton.cpp Fri Dec 19 09:12:51 2014 +0100 +++ b/Application/ImageButton.cpp Fri Dec 19 16:40:30 2014 +0100 @@ -62,6 +62,31 @@ return true; } +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 (_imgDown.pixels != NULL) { + free(_imgDown.pixels); + _imgDown.pixels = NULL; + } + if (Image::decode(imgUp, imgUpSize, Image::RES_16BIT, &_imgUp) != 0) { + DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp); + return false; + } + if (imgDown != NULL) { + if (Image::decode(imgDown, imgDownSize, Image::RES_16BIT, &_imgDown) == 0) { + DMBoard::instance().logger()->printf("Failed to load %s\n", imgDown); + return false; + } + } + return true; +} + + void ImageButton::draw() { if (_pressed) {