本文整理汇总了Java中com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator类的典型用法代码示例。如果您正苦于以下问题:Java BackgroundGenerator类的具体用法?Java BackgroundGenerator怎么用?Java BackgroundGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BackgroundGenerator类属于com.octo.captcha.component.image.backgroundgenerator包,在下文中一共展示了BackgroundGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void buildInitialFactories() {
int minWordLength = 7;
int maxWordLength = 7;
int fontSize = 36;
int imageWidth = 300;
int imageHeight = 90;
WordGenerator wordGenerator = new RandomWordGenerator("0123456789ABCDEFGHIJKLTYREWSZabcdefghjkmnpqrstuvwxyz");
TextPaster randomPaster = new DecoratedRandomTextPaster(
minWordLength,
maxWordLength,
new RandomListColorGenerator(new Color[]{
new Color(23, 170, 27), new Color(220, 34, 11),
new Color(23, 67, 172)}), new TextDecorator[]{});
BackgroundGenerator background = new UniColorBackgroundGenerator(imageWidth, imageHeight, Color.GREEN);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[]{new Font("Calibri", Font.BOLD, fontSize),
new Font("Times New Roman", Font.PLAIN, fontSize),
new Font("Arial", Font.BOLD, fontSize)});
ImageDeformation postDef = new ImageDeformationByFilters(new ImageFilter[]{});
ImageDeformation backDef = new ImageDeformationByFilters(new ImageFilter[]{});
ImageDeformation textDef = new ImageDeformationByFilters(new ImageFilter[]{});
WordToImage word2image = new DeformedComposedWordToImage(font,
background, randomPaster, backDef, textDef, postDef);
addFactory(new GimpyFactory(wordGenerator, word2image));
}
示例2: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
com.octo.captcha.component.word.wordgenerator.WordGenerator wordGenerator =
new com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator(
new com.octo.captcha.component.word.FileDictionary(
"toddlist"));
TextPaster doubleRandomTextPaster = new DoubleRandomTextPaster(
new Integer(8), new Integer(10), Color.white);
BackgroundGenerator back = new MultipleShapeBackgroundGenerator(
new Integer(200), new Integer(100));
FontGenerator fontGenerator = new DeformedRandomFontGenerator(
new Integer(20), new Integer(25));
com.octo.captcha.component.image.wordtoimage.WordToImage word2image =
new com.octo.captcha.component.image.wordtoimage.ComposedWordToImage(
fontGenerator,
back, doubleRandomTextPaster);
com.octo.captcha.image.ImageCaptchaFactory imageCaptchaFactory =
new com.octo.captcha.image.gimpy.GimpyFactory(
wordGenerator, word2image);
this.addFactory(imageCaptchaFactory);
}
示例3: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
com.octo.captcha.component.word.wordgenerator.WordGenerator wordGenerator =
new com.octo.captcha.component.word.wordgenerator.RandomWordGenerator(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
TextPaster textPaster = new NonLinearTextPaster(new Integer(5),
new Integer(7), new RandomListColorGenerator(new Color[] {Color.BLACK, Color.YELLOW,
Color.WHITE}), Boolean.TRUE);
BackgroundGenerator backgroundGenerator = new GradientBackgroundGenerator(
new Integer(200), new Integer(100), Color.CYAN, Color.GRAY);
FontGenerator fontGenerator = new DeformedRandomFontGenerator(
new Integer(25), new Integer(30));
WordToImage wordToImage = new ComposedWordToImage(fontGenerator,
backgroundGenerator, textPaster);
this.addFactory(new com.octo.captcha.image.gimpy.GimpyFactory(wordGenerator, wordToImage));
}
示例4: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
//word generator
com.octo.captcha.component.word.wordgenerator.WordGenerator dictionnaryWords = new com.octo.captcha.component.word.wordgenerator.ComposeDictionaryWordGenerator(
new com.octo.captcha.component.word.FileDictionary(
"toddlist"));
//wordtoimage components
TextPaster randomPaster = new BaffleRandomTextPaster(new Integer(8), new Integer(
15), Color.black,
new Integer(3), Color.white);
BackgroundGenerator back = new UniColorBackgroundGenerator(
new Integer(200), new Integer(100), Color.white);
//BackgroundGenerator back = new FunkyBackgroundGenerator(new Integer(200), new Integer(100));
FontGenerator shearedFont = new RandomFontGenerator(new Integer(20),
new Integer(25));
//word2image 1
com.octo.captcha.component.image.wordtoimage.WordToImage word2image = new com.octo.captcha.component.image.wordtoimage.ComposedWordToImage(
shearedFont, back, randomPaster);
this.addFactory(
new com.octo.captcha.image.gimpy.GimpyFactory(dictionnaryWords,
word2image));
}
示例5: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
//word generator
com.octo.captcha.component.word.wordgenerator.WordGenerator dictionnaryWords =
new com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator(
new com.octo.captcha.component.word.FileDictionary(
"toddlist"));
//wordtoimage components
TextPaster randomPaster = new DoubleRandomTextPaster(new Integer(6),
new Integer(8), Color.white);
BackgroundGenerator fileBack = new FileReaderRandomBackgroundGenerator(
new Integer(200), new Integer(100), "gimpybackgrounds");
//BackgroundGenerator funkyBack = new FunkyBackgroundGenerator(new Integer(200), new Integer(100));
FontGenerator shearedFont = new TwistedAndShearedRandomFontGenerator(
new Integer(20), new Integer(25));
//word2image 1
com.octo.captcha.component.image.wordtoimage.WordToImage word2image =
new com.octo.captcha.component.image.wordtoimage.ComposedWordToImage(
shearedFont, fileBack, randomPaster);
this.addFactory(
new com.octo.captcha.image.gimpy.GimpyFactory(dictionnaryWords,
word2image));
}
示例6: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
WordGenerator wgen = new RandomWordGenerator( AVAILABLE_SYMBOLS );
RandomRangeColorGenerator cgen = new RandomRangeColorGenerator(
new int[] {0, 100},
new int[] {0, 100},
new int[] {0, 100});
TextPaster textPaster = new RandomTextPaster( new Integer(5), new Integer(7), cgen, new Boolean(true) );
BackgroundGenerator backgroundGenerator = new FunkyBackgroundGenerator(new Integer(150), new Integer(40));
Font[] fontsList = new Font[] {
new Font("Arial", 0, 10),
new Font("Tahoma", 0, 10),
new Font("Verdana", 0, 10),
};
FontGenerator fontGenerator = new RandomFontGenerator(new Integer(20), new Integer(25), fontsList);
WordToImage wordToImage = new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster);
this.addFactory(new GimpyFactory(wgen, wordToImage));
}
示例7: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
// 随机生成的字符
WordGenerator wgen = new RandomWordGenerator("abcdefghijklmnopqrstuvwxyz123456789");
RandomRangeColorGenerator cgen = new RandomRangeColorGenerator(new int[] { 0, 100 }, new int[] { 0, 100 }, new int[] { 0,
100 });
// 文字显示的个数
TextPaster textPaster = new RandomTextPaster(new Integer(4), new Integer(4), cgen, true);
// 图片的大小
// BackgroundGenerator backgroundGenerator = new
// FunkyBackgroundGenerator(new Integer(80), new Integer(25));
BackgroundGenerator backgroundGenerator = new GradientBackgroundGenerator(new Integer(80), new Integer(25), Color.gray,
Color.white);
// 字体格式
Font[] fontsList = new Font[] { new Font("Arial", 0, 10), new Font("Tahoma", 0, 10), new Font("Verdana", 0, 10), };
// 文字的大小
FontGenerator fontGenerator = new RandomFontGenerator(new Integer(15), new Integer(16), fontsList);
WordToImage wordToImage = new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster);
this.addFactory(new GimpyFactory(wgen, wordToImage));
}
示例8: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
/**
* 验证码图片生成
*/
@Override
protected void buildInitialFactories() {
FontGenerator fontGenerator = new RandomFontGenerator(MIN_FONT_SIZE, MAX_FONT_SIZE, FONTS);
BackgroundGenerator backgroundGenerator = new GradientBackgroundGenerator(IMAGE_WIDTH, IMAGE_HEIGHT,
new RandomListColorGenerator(BGCOLORS), new RandomListColorGenerator(BGCOLORS));
TextPaster textPaster = new DecoratedRandomTextPaster(MIN_WORD_LENGTH, MAX_WORD_LENGTH,
new RandomListColorGenerator(COLORS), new TextDecorator[] {});
addFactory(new GimpyFactory(new RandomWordGenerator(CHAR_STRING),
new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)));
}
示例9: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
int minWordLength = 6;
int maxWordLength = 6;
int fontSize = 50;
int imageWidth = 250;
int imageHeight = 100;
WordGenerator wordGenerator = new RandomWordGenerator("0123456789abcdefghijklmnopqrstuvwxyz");
RandomRangeColorGenerator cgen = new RandomRangeColorGenerator(new int[] { 0, 150 }, new int[] { 0, 150 },
new int[] { 0, 150 });
LineTextDecorator lineTextDecorator = new LineTextDecorator(1, cgen);// 曲线干扰
BaffleTextDecorator baffleTextDecorator = new BaffleTextDecorator(2, cgen);// 气泡干扰
TextDecorator[] textDecorators = new TextDecorator[2];
textDecorators[0] = lineTextDecorator;
textDecorators[1] = baffleTextDecorator;
TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength, maxWordLength,
new RandomListColorGenerator(
new Color[] { new Color(23, 170, 27), new Color(220, 34, 11), new Color(23, 67, 172) }),
textDecorators);
BackgroundGenerator background = new UniColorBackgroundGenerator(imageWidth, imageHeight, Color.white);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[] { new Font("nyala", Font.BOLD, fontSize), new Font("Bell MT", Font.PLAIN, fontSize),
new Font("Credit valley", Font.BOLD, fontSize) });
ImageDeformation postDef = new ImageDeformationByFilters(new ImageFilter[] {});
ImageDeformation backDef = new ImageDeformationByFilters(new ImageFilter[] {});
ImageDeformation textDef = new ImageDeformationByFilters(new ImageFilter[] {});
WordToImage word2image = new DeformedComposedWordToImage(font, background, randomPaster, backDef, textDef,
postDef);
addFactory(new GimpyFactory(wordGenerator, word2image));
}
示例10: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
int minWordLength = 4;
int maxWordLength = 5;
/*int fontSize = 50;
int imageWidth = 250;
int imageHeight = 100;*/
int fontSize = 30;
int imageWidth = 120;
int imageHeight = 50;
WordGenerator dictionnaryWords = new ComposeDictionaryWordGenerator(new FileDictionary("toddlist"));
// word2image components
TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength,
maxWordLength, new RandomListColorGenerator(new Color[] {
new Color(23, 170, 27), new Color(220, 34, 11),
new Color(23, 67, 172) }), new TextDecorator[] {});
BackgroundGenerator background = new UniColorBackgroundGenerator(
imageWidth, imageHeight, Color.white);
// ColorGenerator colorGenerator=new RandomListColorGenerator(new Color[]{new Color(235, 234, 235),new Color(255, 255, 255)});
// BackgroundGenerator background=new FunkyBackgroundGenerator(imageWidth, imageHeight,colorGenerator);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[] { new Font("nyala", Font.BOLD, fontSize),
new Font("Bell MT", Font.PLAIN, fontSize),
new Font("Credit valley", Font.BOLD, fontSize) });
ImageDeformation postDef = new ImageDeformationByFilters(
new ImageFilter[] {});
ImageDeformation backDef = new ImageDeformationByFilters(
new ImageFilter[] {});
ImageDeformation textDef = new ImageDeformationByFilters(
new ImageFilter[] {});
WordToImage word2image = new DeformedComposedWordToImage(font,
background, randomPaster, backDef, textDef, postDef);
addFactory(new GimpyFactory(dictionnaryWords, word2image));
}
示例11: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
/**
* 验证码图片生成
*/
@Override
protected void buildInitialFactories() {
FontGenerator fontGenerator = new RandomFontGenerator(MIN_FONT_SIZE, MAX_FONT_SIZE, FONTS);
BackgroundGenerator backgroundGenerator = new FileReaderRandomBackgroundGenerator(IMAGE_WIDTH, IMAGE_HEIGHT, new ClassPathResource(BACKGROUND_IMAGE_PATH).getPath());
TextPaster textPaster = new DecoratedRandomTextPaster(MIN_WORD_LENGTH, MAX_WORD_LENGTH, new RandomListColorGenerator(COLORS), new TextDecorator[] {});
addFactory(new GimpyFactory(new RandomWordGenerator(CHAR_STRING), new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)));
}
示例12: createCaptchaEngine
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
@Override
public CaptchaEngine createCaptchaEngine(CaptchaModel captcha) {
return new ListImageCaptchaEngine() {
@Override
protected void buildInitialFactories() {
FontGenerator fontGenerator = new RandomFontGenerator(captcha.getFontMin(), captcha.getFontMax(), getFonts());
BackgroundGenerator backgroundGenerator = createBackgroundGenerator(captcha.getWidth(), captcha.getHeight(), captcha.getBackground());
TextPaster textPaster = new RandomTextPaster(captcha.getLength(), captcha.getLength(),
new RandomRangeColorGenerator(new int[]{0, 100}, new int[]{0, 100}, new int[]{0, 100}), true);
addFactory(new GimpyFactory(new RandomWordGenerator(captcha.getChars()),
new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)));
}
};
}
示例13: main
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
TextPaster paster = new SimpleTextPaster(new Integer(8),
new Integer(8), Color.white);
BackgroundGenerator back = new FileReaderRandomBackgroundGenerator(
new Integer(200), new Integer(100),
"/gimpybackgrounds");
FontGenerator font = new TwistedAndShearedRandomFontGenerator(
new Integer(30), null);
WordGenerator words = new DummyWordGenerator("JCAPTCHA");
WordToImage word2image = new ComposedWordToImage(font, back, paster);
ImageCaptchaFactory factory = new GimpyFactory(words, word2image);
ImageCaptcha pix = factory.getImageCaptcha();
ImageToFile.serialize(pix.getImageChallenge(), new File(args[0]));
}
示例14: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
com.jhlabs.image.RippleFilter rippleBack = new com.jhlabs.image.RippleFilter();
rippleBack.setWaveType(com.jhlabs.image.RippleFilter.NOISE);
rippleBack.setXAmplitude(5);
rippleBack.setYAmplitude(5);
rippleBack.setXWavelength(10);
rippleBack.setYWavelength(10);
rippleBack.setEdgeAction(com.jhlabs.image.TransformFilter.CLAMP);
TextPaster paster =
new DoubleRandomTextPaster(new Integer(8), new Integer(15),
Color.black);
BackgroundGenerator back = new MultipleShapeBackgroundGenerator(
new Integer(200), new Integer(100));
FontGenerator font =
new DeformedRandomFontGenerator(new Integer(25),
new Integer(27));
com.octo.captcha.component.word.wordgenerator.WordGenerator words =
new com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator(
new com.octo.captcha.component.word.FileDictionary(
"toddlist"));
com.octo.captcha.component.image.wordtoimage.WordToImage word2image =
new com.octo.captcha.component.image.wordtoimage.FilteredComposedWordToImage(
font,
back,
paster,
new ImageFilter[]{rippleBack},
new ImageFilter[]{},
new ImageFilter[]{});
com.octo.captcha.image.ImageCaptchaFactory factory = new com.octo.captcha.image.gimpy.GimpyFactory(
words, word2image);
this.addFactory(factory);
}
示例15: buildInitialFactories
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; //导入依赖的package包/类
protected void buildInitialFactories() {
com.octo.captcha.component.word.wordgenerator.WordGenerator wordGenerator = new com.octo.captcha.component.word.wordgenerator.RandomWordGenerator(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
TextPaster textPaster = new RandomTextPaster(new Integer(5),
new Integer(8), Color.white);
BackgroundGenerator backgroundGenerator = new FunkyBackgroundGenerator(
new Integer(200), new Integer(100));
FontGenerator fontGenerator = new TwistedAndShearedRandomFontGenerator(
new Integer(25), new Integer(30));
com.octo.captcha.component.image.wordtoimage.WordToImage wordToImage = new com.octo.captcha.component.image.wordtoimage.ComposedWordToImage(
fontGenerator, backgroundGenerator, textPaster);
this.addFactory(
new com.octo.captcha.image.gimpy.GimpyFactory(wordGenerator,
wordToImage));
}