This SWT snippet converts a BufferedImage
to SWT ImageData
:
static ImageData convertToSWT(BufferedImage bufferedImage) {
if (bufferedImage.getColorModel() instanceof DirectColorModel) {
...
} else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
...
}
return null;
}
The problem is, there is a third subclass of ColorModel
: ComponentColorModel
. And I need to convert an image using this color model. How do I do it?