jj.play.ns.nl.captcha.gimpy.DropShadowGimpyRenderer 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.gimpy;
import java.awt.image.BufferedImage;
import jj.play.ns.com.jhlabs.image.ShadowFilter;
import static jj.play.ns.nl.captcha.util.ImageUtil.applyFilter;
/**
* Twists text and adds a dark drop-shadow.
*
* @author James Childers
*
*/
public class DropShadowGimpyRenderer implements GimpyRenderer {
private static final int DEFAULT_RADIUS = 3;
private static final int DEFAULT_OPACITY = 75;
private final int _radius;
private final int _opacity;
public DropShadowGimpyRenderer() {
this(DEFAULT_RADIUS, DEFAULT_OPACITY);
}
public DropShadowGimpyRenderer(int radius, int opacity) {
_radius = radius;
_opacity = opacity;
}
@Override
public void gimp(BufferedImage image) {
ShadowFilter sFilter = new ShadowFilter();
sFilter.setRadius(_radius);
sFilter.setOpacity(_opacity);
applyFilter(image, sFilter);
}
}