Search in sources :

Example 21 with RescaleOp

use of java.awt.image.RescaleOp in project java-swing-tips by aterai.

the class LookAndFeelUtil method makeRolloverIcon.

private static Icon makeRolloverIcon(Icon srcIcon) {
    int w = srcIcon.getIconWidth();
    int h = srcIcon.getIconHeight();
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = img.createGraphics();
    srcIcon.paintIcon(null, g2, 0, 0);
    float[] scaleFactors = { 1.2f, 1.2f, 1.2f, 1f };
    float[] offsets = { 0f, 0f, 0f, 0f };
    RescaleOp op = new RescaleOp(scaleFactors, offsets, g2.getRenderingHints());
    g2.dispose();
    return new ImageIcon(op.filter(img, null));
}
Also used : RescaleOp(java.awt.image.RescaleOp) BufferedImage(java.awt.image.BufferedImage)

Example 22 with RescaleOp

use of java.awt.image.RescaleOp in project java-swing-tips by aterai.

the class RightPopupBasicComboBoxUI method makeRolloverIcon.

private static Icon makeRolloverIcon(Icon srcIcon) {
    int w = srcIcon.getIconWidth();
    int h = srcIcon.getIconHeight();
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = img.createGraphics();
    srcIcon.paintIcon(null, g2, 0, 0);
    float[] scaleFactors = { 1.2f, 1.2f, 1.2f, 1f };
    float[] offsets = { 0f, 0f, 0f, 0f };
    BufferedImageOp op = new RescaleOp(scaleFactors, offsets, g2.getRenderingHints());
    g2.dispose();
    return new ImageIcon(op.filter(img, null));
}
Also used : BufferedImageOp(java.awt.image.BufferedImageOp) RescaleOp(java.awt.image.RescaleOp) BufferedImage(java.awt.image.BufferedImage)

Aggregations

RescaleOp (java.awt.image.RescaleOp)22 BufferedImage (java.awt.image.BufferedImage)16 Graphics2D (java.awt.Graphics2D)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Color (java.awt.Color)2 BufferedImageOp (java.awt.image.BufferedImageOp)2 ConvolveOp (java.awt.image.ConvolveOp)2 LookupOp (java.awt.image.LookupOp)2 SurfaceData (sun.java2d.SurfaceData)2 Dimension (java.awt.Dimension)1 Graphics (java.awt.Graphics)1 GraphicsConfiguration (java.awt.GraphicsConfiguration)1 Paint (java.awt.Paint)1 Rectangle (java.awt.Rectangle)1 Rectangle2D (java.awt.geom.Rectangle2D)1 ColorConvertOp (java.awt.image.ColorConvertOp)1 File (java.io.File)1 URL (java.net.URL)1 ExecutionException (java.util.concurrent.ExecutionException)1