Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static ImageIcon resizeImage(ImageIcon original, int iconWidth, int iconHeight) {
- Image img = original.getImage();
- Image resized = getScaledImage(img, iconWidth, iconHeight);
- return new ImageIcon(resized);
- }
- private static Image getScaledImage(Image srcImg, int w, int h) {
- BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2 = resizedImg.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g2.drawImage(srcImg, 0, 0, w, h, null);
- g2.dispose();
- return resizedImg;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement