• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RandomRangeColorGenerator类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.octo.captcha.component.image.color.RandomRangeColorGenerator的典型用法代码示例。如果您正苦于以下问题:Java RandomRangeColorGenerator类的具体用法?Java RandomRangeColorGenerator怎么用?Java RandomRangeColorGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RandomRangeColorGenerator类属于com.octo.captcha.component.image.color包,在下文中一共展示了RandomRangeColorGenerator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildInitialFactories

点赞 3

import com.octo.captcha.component.image.color.RandomRangeColorGenerator; //导入依赖的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));
}
 

开发者ID:ivan-zapreev,
项目名称:x-cure-chat,
代码行数:22,
代码来源:XCureImageCaptchaEngine.java

示例2: buildInitialFactories

点赞 3

import com.octo.captcha.component.image.color.RandomRangeColorGenerator; //导入依赖的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));
}
 

开发者ID:8090boy,
项目名称:gomall.la,
代码行数:22,
代码来源:MyImageCaptchaEngine.java

示例3: buildInitialFactories

点赞 2

import com.octo.captcha.component.image.color.RandomRangeColorGenerator; //导入依赖的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));
}
 

开发者ID:iunet,
项目名称:iunet-blog,
代码行数:35,
代码来源:CaptchaEngineUtil.java

示例4: createCaptchaEngine

点赞 2

import com.octo.captcha.component.image.color.RandomRangeColorGenerator; //导入依赖的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)));
        }
    };
}
 

开发者ID:heisedebaise,
项目名称:ranch,
代码行数:15,
代码来源:EngineFactoryImpl.java

示例5: wordToImage

点赞 2

import com.octo.captcha.component.image.color.RandomRangeColorGenerator; //导入依赖的package包/类
@Bean
public WordToImage wordToImage() {
	ColorGenerator fontColorGenerator = new RandomRangeColorGenerator(new int[] { 128, 255 },
			new int[] { 128, 255 }, new int[] { 128, 255 });
	ColorGenerator backgroundColorGenerator = new RandomRangeColorGenerator(new int[] { 0, 127 },
			new int[] { 0, 127 }, new int[] { 0, 127 });
	return new ComposedWordToImage(new RandomFontGenerator(12, 20, new Font[] { new Font("Arial", 0, 1) }),
			new UniColorBackgroundGenerator(90, 34, backgroundColorGenerator),
			new SimpleTextPaster(4, 4, fontColorGenerator));
}
 

开发者ID:xiangxik,
项目名称:java-platform,
代码行数:11,
代码来源:CaptchaConfiguration.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)