Without looking too closely, I had noticed a few things.
I haven't noticed a BufferStrategy.
When creating loading/creating images use "createCompatibleImage", like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| private static BufferedImage loadImage(final String imageName){ final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice myDevice = env.getDefaultScreenDevice(); final GraphicsConfiguration graphicConf = myDevice.getDefaultConfiguration();
final ClassLoader classLoad = ImageProcess.class.getClassLoader(); Graphics2D g2d = null;
BufferedImage img; try { img = ImageIO.read(classLoad.getResource("Images/"+imageName)); } catch (final IOException e) { return null; } final BufferedImage copy = graphicConf.createCompatibleImage(img.getWidth(), img.getHeight(),java.awt.Transparency.OPAQUE); g2d = copy.createGraphics(); g2d.drawImage(img,null,0,0);
img.flush(); img = null;
g2d.dispose(); g2d = null; return copy; } |
And don't use alpha when possible. So only create alpha "createCompatibleImage" when you need it to have alpha.
That might help a little.