mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 13:03:12 -05:00
set anti-aliasing
This commit is contained in:
parent
c047691424
commit
715b9e4206
@ -2,6 +2,7 @@ package lc;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
@ -15,6 +16,8 @@ public class GifCaptcha implements ChallengeProvider{
|
||||
BufferedImage img = new BufferedImage(250, 100, BufferedImage.TYPE_INT_RGB);
|
||||
Font font = new Font("Bradley Hand", Font.ROMAN_BASELINE, 48);
|
||||
Graphics2D graphics2D = img.createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
graphics2D.setFont(font);
|
||||
graphics2D.setColor(new Color((int)(Math.random() * 0x1000000)));
|
||||
graphics2D.drawString( text , 45, 45);
|
||||
|
@ -2,6 +2,7 @@ package lc;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.font.TextLayout;
|
||||
@ -24,6 +25,9 @@ public class ShadowTextCaptcha implements ChallengeProvider{
|
||||
BufferedImage img = new BufferedImage(350, 100, BufferedImage.TYPE_INT_RGB);
|
||||
Font font = new Font("Arial",Font.ROMAN_BASELINE ,48);
|
||||
Graphics2D graphics2D = img.createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
TextLayout textLayout = new TextLayout(text, font, graphics2D.getFontRenderContext());
|
||||
HelperFunctions.setRenderingHints(graphics2D);
|
||||
graphics2D.setPaint(Color.WHITE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user