List of usage examples for java.awt.image ImageProducer startProduction
public void startProduction(ImageConsumer ic);
From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java
/** * Converts AWT image into SWT one. Yours, C.O. ;-) *//* w w w. j av a 2 s .c o m*/ public static Image convertImage_AWT_to_SWT(final java.awt.Image image) throws Exception { return SwingUtils.runObjectLaterAndWait(new RunnableObjectEx<Image>() { public Image runObject() throws Exception { BufferedImage bufferedImage = (BufferedImage) image; int imageWidth = bufferedImage.getWidth(); int imageHeight = bufferedImage.getHeight(); Image swtImage = new Image(null, imageWidth, imageHeight); final ImageData swtImageData = swtImage.getImageData(); try { ImageProducer source = image.getSource(); source.startProduction(new AwtToSwtImageConverter(bufferedImage, swtImageData)); return new Image(null, swtImageData); } catch (Throwable e) { // fallback to ImageIO. return ImageUtils.convertToSWT(image); } finally { swtImage.dispose(); } } }); }