I wanted to get scaled instance of a buffered image and I did:
public void analyzePosition(BufferedImage img, int x, int y){
img = (BufferedImage) img.getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH);
....
}
but I do get an exception:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.ToolkitImage cannot be cast to java.awt.image.BufferedImage
at ImagePanel.analyzePosition(ImagePanel.java:43)
I wanted then to cast to ToolkitImage
then use the method getBufferedImage
I read about in other articles. The problem is there is no class such as sun.awt.image.ToolkitImage
I cannot cast to it because Eclipse does not even see this class. I use Java 1.7
and jre1.7
.