Images can be displayed in Java Swing using object JLabel. This is the partial code: JLabel label = new JLabel(); try { BufferedImage img = ImageIO.read(new File(IMG_FILES_PATH + IMG_FILENAME)); ImageIcon icon = new ImageIcon(img); label.setIcon(icon); } catch (IOException ex) { Logger.getLogger(SwingGUIMainScreen.class.getName()).log(Level.SEVERE, null, ex); } If I need the image to have an specific size, what […]
Archive | Java RSS feed for this section
How to scale an image in Java
I programmed my own function, based on other examples: /** * Method that scale an image (BufferedImage) into the specified dimensions * @param sbi Source image * @param imageType Image type among BufferedImage.TYPE_… constants (example: TYPE_INT_ARGB) * @param dWidth Image width, in pixels * @param dHeight Image height, in pixels * @return Destination image */ […]