Jump to content

Can't get Image to display in simple List

Recommended Posts

Hi All,

I am attempting to get the simple uGFX List code example to also show an image.

Below is my code, as well as defines added to gfxconf.h.

The list is displayed just fine, but no image in the list.

Is there something I'm missing?


I have defined the following in gfxconf.h:






And here's my code:

#include <string.h>
#include "gfx.h"

static GListener gl;
static GHandle   ghList1;
static gdispImage img1;

static void createWidgets(void) {
    GWidgetInit wi;

    // Apply some default values for GWIN
    wi.customDraw = 0;
    wi.customParam = 0;
    wi.customStyle = 0;
    wi.g.show = FALSE;

    // Apply the list parameters
    wi.g.width = 200;
    wi.g.height = 100;
    wi.g.y = 10;
    wi.g.x = 10;
    wi.text = "List Name";

    // Create the actual list
    ghList1 = gwinListCreate(NULL, &wi, FALSE);

int main(void) {
    uint16_t    i;
    char        item[20];
    GEvent        *pe;

    // Initialize the display

    // Set the widget defaults
    gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);

    // Attach the mouse input

    // create the widget

    // We want to listen for widget events

    // Add some items to the list widget
    for (i = 0; i < 100; i++) {
        sprintf(item, "Item Nr.: %d", i);
        gwinListAddItem(ghList1, item, TRUE);
    gdispImageOpenFile(&img1, "star16.gif");
    gwinListItemSetImage(ghList1, 0, &img1);

    // Make the list visible
    gwinSetVisible(ghList1, TRUE);

    while (1) {
        // Get an Event
        pe = geventEventWait(&gl, TIME_INFINITE);

    return 0;


Much thanks in advance,


Link to post
Share on other sites


Check the return code of gdispImageOpenFile(). It will tell you whether the image was loaded properly.
The widget will not display the image if it wasn't loaded properly.

In general I'd recommend you making sure that you can display the image using the imagebox widget before attempting to insert it into the list widget as this makes it easier to ensure that there are no underlying problems with the filesystem, image decoders and similar.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...