Search in sources :

Example 11 with RescaleOp

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

the class AnimationUtil method makeRolloverIcon.

private static ImageIcon makeRolloverIcon(ImageIcon 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 = { .5f, .5f, .5f, 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 12 with RescaleOp

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

the class SearchBarLayout method makeRolloverIcon.

protected static ImageIcon makeRolloverIcon(ImageIcon 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 13 with RescaleOp

use of java.awt.image.RescaleOp in project poi by apache.

the class BitmapImageRenderer method setAlpha.

@Override
public void setAlpha(double alpha) {
    if (img == null)
        return;
    Dimension dim = getDimension();
    BufferedImage newImg = new BufferedImage((int) dim.getWidth(), (int) dim.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = newImg.createGraphics();
    RescaleOp op = new RescaleOp(new float[] { 1.0f, 1.0f, 1.0f, (float) alpha }, new float[] { 0, 0, 0, 0 }, null);
    g.drawImage(img, op, 0, 0);
    g.dispose();
    img = newImg;
}
Also used : RescaleOp(java.awt.image.RescaleOp) Dimension(java.awt.Dimension) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 14 with RescaleOp

use of java.awt.image.RescaleOp in project nationgen by elmokki.

the class Drawing method darken.

public static BufferedImage darken(BufferedImage image, int units) {
    float un = (float) units;
    float[] factors = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
    float[] offsets = new float[] { un, un, un, 0.0f };
    BufferedImage dstImage = null;
    RescaleOp op = new RescaleOp(factors, offsets, null);
    dstImage = op.filter(image, null);
    for (int x = 0; x < image.getWidth(); x++) for (int y = 0; y < image.getHeight(); y++) {
        int clr = image.getRGB(x, y);
        int red = (clr & 0x00ff0000) >> 16;
        int green = (clr & 0x0000ff00) >> 8;
        int blue = clr & 0x000000ff;
        if (red > 247 && blue > 247 && green == 0)
            dstImage.setRGB(x, y, clr);
        if (red == 0 && blue == 0 && green == 0)
            dstImage.setRGB(x, y, Color.BLACK.getRGB());
    }
    return dstImage;
}
Also used : RescaleOp(java.awt.image.RescaleOp) BufferedImage(java.awt.image.BufferedImage)

Example 15 with RescaleOp

use of java.awt.image.RescaleOp in project WorldPainter by Captain-Chaos.

the class BitmapBrush method setLevel.

@Override
public void setLevel(float level) {
    if (level != this.level) {
        this.level = level;
        rescaleOp = new RescaleOp(level, 0, null);
        createMask();
    }
}
Also used : RescaleOp(java.awt.image.RescaleOp)

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