Skip to content

Cannot load BMP image on RHEL-10 #2463

@raghucssit

Description

@raghucssit

Please use the below example and use any bmp image..

Environment:
Red Hat Enterprise Linux 10.0 (Coughlan)
Windowing System: Wayland
GTK: GTK3
It's fresh machine. I assume I miss something to render bmp image.

package org.eclipse.swt.examples.browserexample;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class SWTImageAbsolutePathExample {
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("SWT BMP Test");
        shell.setSize(420, 320);

        String imagePath = "/home/user/Downloads/swt_test_32bpp.bmp"; // <- change this
        try {
            Image image = new Image(display, imagePath);
            Label label = new Label(shell, SWT.NONE);
            label.setImage(image);
            label.setBounds(20, 20, image.getBounds().width, image.getBounds().height);
        } catch (Exception e) {
            e.printStackTrace();
        }

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }
}

Stacktrace:

org.eclipse.swt.SWTException: Invalid image
	at org.eclipse.swt.SWT.error(SWT.java:4945)
	at org.eclipse.swt.SWT.error(SWT.java:4860)
	at org.eclipse.swt.SWT.error(SWT.java:4831)
	at org.eclipse.swt.internal.NativeImageLoader.load(NativeImageLoader.java:81)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:161)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:197)
	at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:55)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:600)
	at org.eclipse.swt.examples.browserexample.SWTImageAbsolutePathExample.main(SWTImageAbsolutePathExample.java:17)

More data:
As i did debug the issue present at:
NativeImageLoader#load(ElementAtZoom<InputStream> streamAtZoom, ImageLoader imageLoader, int targetZoom)

The exception is thrown from this call at line 62:
C.memmove(buffer_ptr, data_buffer, data_buffer.length);

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