Commit 5efdc909 authored by Marius Lindvall's avatar Marius Lindvall

Fixed issues with transparent images

parent 98713b0d
package info.varden.imagetint;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
......@@ -55,16 +54,22 @@ public class ImageTint {
Graphics g = result.getGraphics();
g.drawImage(inputImg, 0, 0, null);
BufferedImage temp = new BufferedImage(w2, h2, BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < w2; x++) {
for (int y = 0; y < h2; y++) {
temp.setRGB(x, y, (inputImg.getRGB(x, y) & 0xFF000000) + (int) (col & 0xFFFFFF));
}
}
BufferedImage wm = new BufferedImage(w2, h2, BufferedImage.TYPE_INT_ARGB);
Graphics2D wmg = (Graphics2D) wm.getGraphics();
wmg.setComposite(AlphaComposite.SrcOver.derive(alpha));
Color c = new Color((int) (col & 0xFFFFFF));
wmg.setPaint(c);
wmg.fillRect(0, 0, w2, h2);
wmg.drawImage(temp, 0, 0, null);
wmg.dispose();
g.drawImage(wm, 0, 0, null);
g.dispose();
wm.flush();
temp.flush();
String name = f.getName();
int pos = name.lastIndexOf(".");
if (pos > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment