I anticipate using some images in my Java application. These images will be drawn onto my JPanel using g.drawImage()
. The JPanel is resizable and the images should scale as the JPanel increases/decreases in size
Two questions:
- What image format is best for this type of desired scalable image? For instance, in this application, an image of size 100x100 may be scaled into an image of size 30x30 or 10x10 or 300x300.
- How can I write code to do this scaling?
Take a look at Java: maintaining aspect ratio of JPanel background image
I'd also take a read through The Perils of Image.getScaledInstance() and I'd also have a look at java-image-scaling (I've not used it personally, but I've heard good things about it).
As to the image format. I doubt it will really make that much of difference, the quality will be determined by the quality of the original image. Try and use a large image and scale it down, rather then trying to scale a small image up.