17 Star 44 Fork 12

hanguofeng / gocaptcha

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
imagefiltermanager.go 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
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 ()
//ImageFilterManager
type ImageFilterManager struct {
filters []ImageFilter
}
func init() {
RegisterImageFilter(IMAGE_FILTER_NOISE_LINE, imageFilterNoiseLineCreator)
RegisterImageFilter(IMAGE_FILTER_NOISE_POINT, imageFilterNoisePointCreator)
RegisterImageFilter(IMAGE_FILTER_STRIKE, imageFilterStrikeCreator)
}
func CreateImageFilterManager() *ImageFilterManager {
ret := new(ImageFilterManager)
ret.filters = []ImageFilter{}
return ret
}
func (manager *ImageFilterManager) AddFilter(filter ImageFilter) {
manager.filters = append(manager.filters, filter)
}
func (manager *ImageFilterManager) GetFilters() []ImageFilter {
return manager.filters
}
func CreateImageFilterManagerByConfig(config *FilterConfig) *ImageFilterManager {
mgr := new(ImageFilterManager)
mgr.filters = []ImageFilter{}
for _, cfgId := range config.Filters {
creator, has := imageFilterCreators[cfgId]
if !has {
continue
}
cfgGroup, has := config.GetGroup(cfgId)
if !has {
continue
}
mgr.AddFilter(creator(cfgGroup))
}
return mgr
}
1
https://gitee.com/hanguofeng/gocaptcha.git
git@gitee.com:hanguofeng/gocaptcha.git
hanguofeng
gocaptcha
gocaptcha
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891