Difference between revisions of "ImageBox"

From uGFX Wiki
Jump to: navigation, search
(Fix API reference link)
 
Line 2: Line 2:
  
 
== API reference ==
 
== API reference ==
The API reference of the image box widget can be found [http://api.ugfx.org/group___image_box.html here].
+
The API reference of the image box widget can be found [http://api.ugfx.io/group___image_box.html here].
  
 
== Animated Images ==
 
== Animated Images ==

Latest revision as of 07:24, 1 April 2020

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.

Example

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
	wi.g.show = 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
	gwinImageCache(ghImage1);
	gwinImageCache(ghImage2);
}
 
int main(void) {
	// Initialize µGFX and the underlying system
	gfxInit();
 
	// Set the widget defaults
	gwinSetDefaultFont(gdispOpenFont("UI2"));
	gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
	gdispClear(White);
 
	// create the widget
	createWidgets();
 
	while(1) {
		gfxSleepMilliseconds(100);
	}
 
	return 0;
}