From uGFX Wiki
Jump to: navigation, search

The image box simply takes the GDISP image decoder features and wraps them around a GWIN widget. Therefore, please refer to the GDISP image and the GFILE documentation to learn how to use it.

API reference

The API reference of the image box widget can be found here.

Animated Images

If you want to use animated images such as multi-frame GIF images, you have to enable the GWIN_NEED_IMAGE_ANIMATION in your gfxconf.h.


The following example reads two images from a memory location (a BMP and an animated GIF) and displays them. The demo shows how GWIN automatically takes care about the animation.

#include "gfx.h"
#include "image_chibios.h"
#include "image_waterfall.h"
static GHandle   ghImage1, ghImage2;
static void createWidgets(void) {
	GWidgetInit	wi;
	// Apply some default values for GWIN = TRUE;
	// create the first image widget
	wi.g.x = 10; wi.g.y = 10; wi.g.width = 120; wi.g.height = 120;
	ghImage1 = gwinImageCreate(NULL, &wi.g);
	gwinImageOpenMemory(ghImage1, image_chibios);
	// create the second image widget
	wi.g.x = 160; wi.g.y = 10; wi.g.width = 120; wi.g.height = 120;
	ghImage2 = gwinImageCreate(NULL, &wi.g);
	gwinImageOpenMemory(ghImage2, image_waterfall);
	// optionally cache the images
int main(void) {
	// Initialize µGFX and the underlying system
	// Set the widget defaults
	gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
	// create the widget
	while(1) {
	return 0;