import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class ImageScaling { public static void main(String[] args) { final Display display = new Display(); final Image image = new Image(display, 32, 32); final GC gc = new GC(image); try { gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN)); gc.fillRectangle(0, 0, 32, 32); } finally { gc.dispose(); } final Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final Label label = new Label(shell, 0); label.setImage(image); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }