本文整理汇总了Java中nl.captcha.gimpy.FishEyeGimpyRenderer类的典型用法代码示例。如果您正苦于以下问题:Java FishEyeGimpyRenderer类的具体用法?Java FishEyeGimpyRenderer怎么用?Java FishEyeGimpyRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FishEyeGimpyRenderer类属于nl.captcha.gimpy包,在下文中一共展示了FishEyeGimpyRenderer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCaptchaImage
import nl.captcha.gimpy.FishEyeGimpyRenderer; //导入依赖的package包/类
private void getCaptchaImage(HttpServletRequest request, HttpServletResponse response) throws IOException
{
String seed = request.getParameter("seed");
if (seed == null || seed.isEmpty())
{
response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE);
return;
}
int seed_;
try
{
seed_ = Integer.parseInt(seed);
}
catch (NumberFormatException i)
{
response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE);
return;
}
PredictableCaptchaTextProducer producer = new PredictableCaptchaTextProducer(seed_);
final Captcha captcha = new Captcha.Builder(160, 50).addText(producer).addBackground(new GradiatedBackgroundProducer()).addNoise().gimp(new FishEyeGimpyRenderer()).addBorder().build();
CaptchaServletUtil.writeImage(response, captcha.getImage());
}
示例2: doGet
import nl.captcha.gimpy.FishEyeGimpyRenderer; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
List<java.awt.Font> textFonts = Arrays.asList(
new Font("Arial", Font.BOLD, 40),
new Font("Courier", Font.BOLD, 40));
Captcha captcha = new Captcha.Builder(250, 90).addText()
.addBackground(new FlatColorBackgroundProducer(Color.YELLOW))
.gimp(new FishEyeGimpyRenderer())
.addNoise(new CurvedLineNoiseProducer())
.addText(new DefaultTextProducer(5),
new DefaultWordRenderer(Color.RED, textFonts))
.build();
CaptchaServletUtil.writeImage(resp, captcha.getImage());
req.getSession().setAttribute(NAME, captcha);
}
示例3: updateCaptcha
import nl.captcha.gimpy.FishEyeGimpyRenderer; //导入依赖的package包/类
@At("/captcha/update")
@Ok("raw:image/png")
public BufferedImage updateCaptcha(HttpSession session, @Param("w") int w, @Param("h") int h) {
if (w * h == 0) { //长或宽为0?重置为默认长宽.
w = 200;
h = 60;
}
Captcha captcha = new Captcha.Builder(w, h)
.addText().addBackground(new GradiatedBackgroundProducer())
// .addNoise(new StraightLineNoiseProducer()).addBorder()
.gimp(new FishEyeGimpyRenderer())
.build();
String text = captcha.getAnswer();
session.setAttribute(Toolkit.captcha_attr, text);
return captcha.getImage();
}