17 Star 44 Fork 12

hanguofeng / gocaptcha

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
imagefilternoisepoint.go 995 Bytes
一键复制 编辑 原始数据 按行查看 历史
dtynn 提交于 2014-12-23 18:44 . some fixes and register image filter
// Copyright 2013 hanguofeng. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gocaptcha
import (
"strconv"
)
const IMAGE_FILTER_NOISE_POINT = "ImageFilterNoisePoint"
//ImageFilter is the interface of image filter
type ImageFilterNoisePoint struct {
ImageFilterBase
}
func imageFilterNoisePointCreator(config FilterConfigGroup) ImageFilter {
filter := ImageFilterNoisePoint{}
filter.SetConfig(config)
return &filter
}
//Proc the image
func (filter *ImageFilterNoisePoint) Proc(cimage *CImage) {
var num int
var err error
v, ok := filter.config.GetItem("Num")
if ok {
num, err = strconv.Atoi(v)
if nil != err {
num = 3
}
} else {
num = 3
}
for i := 0; i < num; i++ {
cimage.drawCircle(rnd(0, cimage.Bounds().Max.X), rnd(0, cimage.Bounds().Max.Y), rnd(0, 2), uint8(rnd(1, colorCount)))
}
}
func (filter *ImageFilterNoisePoint) GetId() string {
return IMAGE_FILTER_NOISE_POINT
}
1
https://gitee.com/hanguofeng/gocaptcha.git
git@gitee.com:hanguofeng/gocaptcha.git
hanguofeng
gocaptcha
gocaptcha
master

搜索帮助