Skip to content

Images in X11 backend only works with RGBA #950

@TomJGooding

Description

@TomJGooding

For example, nk_xsurf_load_image_from_file("lena.png") will display a garbled RGB image and segfault if you try to resize the window.

screenshot

$ file lena.png 
lena.png: PNG image data, 512 x 512, 8-bit/color RGB, non-interlaced
/* --snip-- */
#define NK_IMPLEMENTATION
#define NK_XLIB_IMPLEMENTATION
#define NK_XLIB_INCLUDE_STB_IMAGE
#define NK_XLIB_IMPLEMENT_STB_IMAGE
#include "../../nuklear.h"
#include "nuklear_xlib.h"

/* --snip-- */
    struct nk_image img = nk_xsurf_load_image_from_file("lena.png");

    while (running)
    {
        /* --snip-- */
        if (nk_begin(ctx, "Image", nk_rect(0, 0, 300, 300), NK_WINDOW_SCALABLE))
        {
            float win_h = nk_window_get_content_region(ctx).h;
            nk_layout_row_dynamic(ctx, win_h, 1);
            nk_image(ctx, img);
        }
        nk_end(ctx);
        /* --snip-- */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions