/******************************************************************************* * Copyright (c) 2020 Syntevo and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Syntevo - initial API and implementation *******************************************************************************/ import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Bug568641_GC_drawImage_IAE { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, true)); Label hint = new Label(shell, 0); hint.setText( "1) Go to your OS system settings and change Display DPI to 200%\n" + "2) Start this snippet\n" + "3) Change Display DPI to 100%\n" + "4) Snippet will crash with IllegalArgumentException in GC.drawImage()" ); Image image = new Image(display, 13, 13); ImageDataProvider imageProvider = zoom -> image.getImageData(zoom); CLabel label = new CLabel(shell, 0); label.setImage(new Image(display, imageProvider)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }