List of utility methods to do ImageIcon
ImageIcon | getThumbnail(ImageIcon src, int maxWidth) get Thumbnail if (src != null) { if (src.getIconWidth() > maxWidth) { return new ImageIcon(src.getImage().getScaledInstance(maxWidth, -1, Image.SCALE_SMOOTH)); } else { return src; return null; ... |
int[] | grabRGB(ImageIcon icon) Grabs a RGB values of the given image icon int width = icon.getIconWidth(); int height = icon.getIconHeight(); int[] rgb = new int[width * height]; PixelGrabber pg = new PixelGrabber(icon.getImage(), 0, 0, width, height, rgb, 0, width); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for pixels!"); ... |
ImageIcon | iconDefaultSize(ImageIcon imag) icon Default Size ImageIcon imagen = new ImageIcon(imag.getImage().getScaledInstance(14, 14, java.awt.Image.SCALE_DEFAULT)); return imagen; |
ImageIcon | imageFlip(int w, int h, ImageIcon... icons) image Flip BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D ig2 = bi.createGraphics(); for (ImageIcon icon : icons) { ig2.drawImage(icon.getImage(), 0, 0, icon.getIconWidth(), icon.getIconHeight(), null); return new ImageIcon(bi); |
byte[] | imageToBytes(ImageIcon icon) image To Bytes if (icon == null) { return null; Image img = icon.getImage(); if (img.getWidth(null) < 1 && img.getHeight(null) < 1) { return null; BufferedImage image = getBufferedImageFromImage(img); ... |
ImageIcon | imageWithBackground(ImageIcon icon, Color colorBg) image With Background if (icon != null) { BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D ig2 = bi.createGraphics(); if (colorBg != null) { ig2.setColor(colorBg); ig2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); ig2.drawImage(icon.getImage(), 0, 0, icon.getIconWidth(), icon.getIconHeight(), null); return new ImageIcon(bi); return icon; |
void | initImageIcon(Class cl) init Image Icon imageApp = getImage(cl, "app.gif"); imageEvaluate = getImage(cl, "evaluateIcon.gif"); imageAbout = getImage(cl, "about.gif"); imageIconExpand = new ImageIcon(getImage(cl, "handleExpand.gif")); imageIconCollapse = new ImageIcon(getImage(cl, "handleCollapse.gif")); plusIcon = new ImageIcon(getImage(cl, "plus.gif")); minusIcon = new ImageIcon(getImage(cl, "minus.gif")); wizardIcon = new ImageIcon(getImage(cl, "wizard.gif")); ... |
boolean | isValidImg(ImageIcon img) Verifica que la imagen tenga las dimensiones de 32x32 return (img.getIconWidth() == 32 && img.getIconHeight() == 32);
|
ImageIcon | loadJavaInternal(ImageIcon r, Dimension d, boolean noStretch) load Java Internal Image scaled = null; Dimension newD = getSizeKeepRatio(new Dimension(r.getIconWidth(), r.getIconHeight()), d, noStretch); if (newD == null) { return r; scaled = r.getImage().getScaledInstance(newD.width, newD.height, Image.SCALE_FAST); r.getImage().flush(); r.setImage(scaled); ... |
ImageIcon | makeDisabledImage(ImageIcon in) make Disabled Image if (in == null) return (null); Image greyImage = makeGrayImage(in.getImage()); return (new ImageIcon(greyImage)); |