paintEvent.width = canvas.getSize().x;
paintEvent.height = canvas.getSize().y;
paintEvent.widget = canvas;
paintEvent.display = canvas.getDisplay();
canvas.notifyListeners(SWT.Paint, paintEvent);
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };
int imageType = SWT.IMAGE_PNG;
switch (selected.getFileType()) {
case PNG: imageType = SWT.IMAGE_PNG; break;
case JPG: imageType = SWT.IMAGE_JPEG; break;
}
loader.save(selected.getFilePath(), imageType);
gc.dispose();
image.dispose();
}