I'm Java beginner trying to load a .PNG
8356 x 5092 pixels into a JFrame 720 x 600.
I can load the image but it is zoomed to the top left, wanting to make the .PNG
fit into the JFrame and then be able to span with the mouse click and zoom with mouse scroll.
I have been looking for answers for about 2 weeks now but no avail. Just wanting a good shove into the right direction...
Cheers
EDIT
Ok I got the Image to load and scale to size by doing:
public Image ScaledImage(Image img, int w, int h) {
BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = resizedImg.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(img, 0, 0, w, h, null);
g2.dispose();
return resizedImg;
}
and passing it over to the JLabel like:
BufferedImage Map = ImageIO.read(new File(.PNG-LOCATION));
ImageIcon icon = new ImageIcon(ScaledImage(Map, 720, 600));
JLabel Label = new JLabel();
Label.setIcon(icon);
Now just need help or guidance in zooming, click to drag
Thanks for the help