forked from hanguofeng/gocaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagefilter.go
46 lines (36 loc) · 1.04 KB
/
imagefilter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// 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 ()
var imageFilterCreators = map[string]func(FilterConfigGroup) ImageFilter{}
func RegisterImageFilter(id string, f func(FilterConfigGroup) ImageFilter) bool {
if _, has := imageFilterCreators[id]; has {
return false
}
imageFilterCreators[id] = f
return true
}
//ImageFilter is the interface of image filter
type ImageFilter interface {
Proc(cimage *CImage)
GetId() string
SetConfig(FilterConfigGroup)
GetConfig() FilterConfigGroup
}
//ImageFilter is the base class of image filter
type ImageFilterBase struct {
config FilterConfigGroup
}
func (filter *ImageFilterBase) Proc(cimage *CImage) {
panic("not impl")
}
func (filter *ImageFilterBase) GetId() string {
panic("not impl")
}
func (filter *ImageFilterBase) SetConfig(config FilterConfigGroup) {
filter.config = config
}
func (filter *ImageFilterBase) GetConfig() FilterConfigGroup {
return filter.config
}