Skip to content

Commit e50db6b

Browse files
committed
[GTK] Revert unification of blank Image initialization eclipse-platform#1891
A previous change unified the Image surface initialization for blank Image instances just based on height and width. Because of the change, screen capturing using a GC on the display does only work properly when executed the first time in an application lifecycle and in specific situation, the initial properties of a GC changed (such as the text anti-aliasing behavior). Due to a lack of a better solution for now, this change reverts the unification of the Image surface initialization to the previous state. Fixes eclipse-platform#1891 This partially reverts commit 5c2611d.
1 parent 487d1cb commit e50db6b

File tree

1 file changed

+5
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics

1 file changed

+5
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,11 @@ void init(int width, int height) {
12491249
this.type = SWT.BITMAP;
12501250

12511251
/* Create the pixmap */
1252-
surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, width, height);
1252+
if (GTK.GTK4) {
1253+
surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, width, height);
1254+
} else {
1255+
surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height);
1256+
}
12531257
if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
12541258
// When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale.
12551259
// Cairo will take care of scaling for us when image needs to be scaled.

0 commit comments

Comments
 (0)