I’m using the following code to load images to display.
ImageIcon ii = new ImageIcon(imageLocation);
Image loadedImage = ii.getImage();
int imageWidth = loadedImage.getWidth(null);
int imageHeight = loadedImage.getHeight(null);
if (getGraphicsConfiguration() != null)
{
Image acceleratedImage = getGraphicsConfiguration().createCompatibleImage(
imageWidth, imageHeight, Transparency.TRANSLUCENT);
acceleratedImage.getGraphics().drawImage(loadedImage, 0, 0, null);
loadedImage = acceleratedImage;
}
The funny thing is this, I’m loading a 1360x768 image to display as a background and after doing several time trials I found something weird.
As a GIF - ~9s
As a PNG - ~18s
As a JPG - ~19s
Astonshing! And after I went through my images and made them all GIFs, my program loads 10s faster then before. Any ideas why GIFs are loading that much faster? And am I the only one who’s had this happen?