jj.play.ns.nl.captcha.util.ImageUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jj-simplecaptcha Show documentation
Show all versions of jj-simplecaptcha Show documentation
SimpleCaptcha - an easy to implement CAPTCHA framework to generate image and audio challenges, for Java 1.5 and Java 6 (repackaged by Play! Framework)
The newest version!
package jj.play.ns.nl.captcha.util;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
public class ImageUtil {
public static final void applyFilter(BufferedImage img, ImageFilter filter) {
FilteredImageSource src = new FilteredImageSource(img.getSource(), filter);
Image fImg = Toolkit.getDefaultToolkit().createImage(src);
Graphics2D g = img.createGraphics();
g.drawImage(fImg, 0, 0, null, null);
g.dispose();
}
}