I want to convert an Image
to a BufferedImage
. I know the following:
Image tmp;
... //read, scale
BufferedImage buffered = new BufferedImage(SMALL_SIZE, SMALL_SIZE,
BufferedImage.TYPE_INT_RGB);
buffered.getGraphics().drawImage(tmp, 0, 0, null);
But it's really slow. I need BufferedImage
, because I have to get pixel color data.
I found a possible way to do it, without drawing:
ToolkitImage ti = (ToolkitImage) tmp;
BufferedImage buffered = tmp.getBufferedImage();
But it always returns null
. Can anyone offer a solution for this?
EDIT: The bigger task (source of this problem) is here: Scale a BufferedImage the fastest and easiest way