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));
}
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));
}
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;
}
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;
}
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();
}
}
Aggregations