Skip to content

[macOS Sonoma] Control.setBackgroundImage - image is upside down and flipped #772

Closed
@Phillipus

Description

@Phillipus

Describe the bug
Background images on SWT controls are inverted.

This was reported here but I've opened a dedicated issue as it's not to do with the splash screen but rather Control#setBackgroundImage.

To Reproduce

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ImageTest {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Image Test");
        shell.setLayout(new FillLayout());
        
        Image image = new Image(display, ImageTest.class.getResourceAsStream("splash.png"));
        shell.setBackgroundImage(image);
        
        shell.setSize(image.getBounds().width, image.getBounds().height);
        shell.open();
        
        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) display.sleep();
        }

        display.dispose();
    }
}

Use this image for testing (rename to splash.png), or your own image if you prefer:

splash

Expected behavior
The image should display the right way.

Screenshots
Run the snippet and see this:

inverted

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)
    macOS Sonoma 14
    Mac Mini M1

  2. JRE/JDK version
    Temurin 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededmacOShappens on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions