List of utility methods to do ImageIcon Scale
ImageIcon | scaleIconTo(ImageIcon icon, int width, int height) scale Icon To Image image = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
icon.setImage(image);
return icon;
|
ImageIcon | scaleImage(ImageIcon i, int x, int y) scale Image return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH)); |
ImageIcon | scaleImage(ImageIcon icon) scale Image Image img = icon.getImage(); Image newimg = img.getScaledInstance(444, 200, java.awt.Image.SCALE_SMOOTH); ImageIcon newIcon = new ImageIcon(newimg); return newIcon; |
ImageIcon | scaleImage(ImageIcon src, int width, int height) scale Image return new ImageIcon(scaleImage(src.getImage(), width, height)); |
ImageIcon | scaleImageIcon(ImageIcon icon, float scale, int hints) get a scaled instance of the input ImageIcon if (icon == null) return null; if (scale > 1.0f || scale <= 0.0f) throw new IllegalArgumentException("scale must be in (0, 1]."); int w = icon.getIconWidth(); int h = icon.getIconHeight(); return new ImageIcon(icon.getImage().getScaledInstance((int) (w * scale), (int) (h * scale), hints)); |
ImageIcon | scaleImageIcon(ImageIcon icon, int newHeight, int newWidth) Returns a scaled down image if the height or width is smaller than the image size. Image img = icon.getImage(); int height = icon.getIconHeight(); int width = icon.getIconWidth(); if (height > newHeight) { height = newHeight; if (width > newWidth) { width = newWidth; ... |
ImageIcon | scaleImageIcon(ImageIcon icon, int w, int h) scale Image Icon Image img = icon.getImage(); return new ImageIcon(img.getScaledInstance(w, h, Image.SCALE_SMOOTH)); |
ImageIcon | scaleImageIcon(String filePath, double maxHeight) scale Image Icon ImageIcon icon = new ImageIcon(filePath); double scaleFactor = maxHeight / icon.getIconHeight(); Image image = icon.getImage().getScaledInstance((int) (icon.getIconWidth() * scaleFactor), (int) maxHeight, Image.SCALE_SMOOTH); icon.setImage(image); return icon; |
ImageIcon | scaleImageIconTo(ImageIcon source, int height, int width) scale Image Icon To return new ImageIcon(source.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH)); |