Skip to content

[GTK] Internal error loading image #3545

Description

@tmssngr

Describe the bug
Loading a certain image fails on Ubuntu 26.04.

To Reproduce
Unpack the zip file with the image into the current directory (from the perspective of a running snippet) and run this snippet:

import java.io.*;
import java.nio.file.*;

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class ImageViewer {

	public static void main(String[] args) throws IOException {
		final Display display = new Display();

		final Image image;
		try (InputStream stream = Files.newInputStream(Paths.get("16-bits-channels.png"))) {
			final ImageData data = new ImageData(stream);
			image = new Image(display, data);
		}

		final Shell shell = new Shell(display);
		shell.addListener(SWT.Paint, event -> {
			event.gc.drawImage(image, 10, 10);
		});
		shell.setSize(400, 300);
		shell.open();

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

		image.dispose();

		display.dispose();
	}
}

16-bits-channels.png.zip
With the latest HEAD commit and a normal FullHD display with 100% scaling I'm getting this exception on Ubuntu 26.04 (Wayland):

Exception in thread "main" java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:4915)
	at org.eclipse.swt.SWT.error(SWT.java:4849)
	at org.eclipse.swt.SWT.error(SWT.java:4820)
	at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:439)
	at org.eclipse.swt.graphics.ImageData.clone(ImageData.java:567)
	at org.eclipse.swt.internal.NativeImageLoader.load(NativeImageLoader.java:143)
	at org.eclipse.swt.graphics.ImageLoader.loadByZoom(ImageLoader.java:161)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:154)
	at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:29)
	at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:334)
	at ImageViewer.main(ImageViewer.java:15)

Expected behavior
It should start - just like on Windows or Linux Mint (X11).

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    stock Ubuntu 26.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linux/GTKHappens on LinuxbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions