-
Notifications
You must be signed in to change notification settings - Fork 35
/
operator_gm.go
77 lines (73 loc) · 1.66 KB
/
operator_gm.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// +build gm
package magick
// #include <magick/api.h>
import "C"
import (
"fmt"
)
func (im *Image) operateChannel(op Operator, ch Channel, value float64) error {
var cop C.QuantumOperator
switch op {
case OpAdd:
cop = C.AddQuantumOp
case OpAnd:
cop = C.AndQuantumOp
case OpAssign:
cop = C.AssignQuantumOp
case OpDepth:
cop = C.DepthQuantumOp
case OpDivide:
cop = C.DivideQuantumOp
case OpGamma:
cop = C.GammaQuantumOp
case OpLog:
cop = C.LogQuantumOp
case OpLShift:
cop = C.LShiftQuantumOp
case OpMax:
cop = C.MaxQuantumOp
case OpMin:
cop = C.MinQuantumOp
case OpMultiply:
cop = C.MultiplyQuantumOp
case OpGaussianNoise:
cop = C.GammaQuantumOp
case OpImpulseNoise:
cop = C.NoiseImpulseQuantumOp
case OpLaplacianNoise:
cop = C.NoiseLaplacianQuantumOp
case OpMultiplicativeNoise:
cop = C.NoiseMultiplicativeQuantumOp
case OpPoissonNoise:
cop = C.NoisePoissonQuantumOp
case OpRandomNoise:
cop = C.NoiseRandomQuantumOp
case OpUniformNoise:
cop = C.NoisePoissonQuantumOp
case OpOr:
cop = C.OrQuantumOp
case OpPow:
cop = C.PowQuantumOp
case OpRShift:
cop = C.RShiftQuantumOp
case OpSubstract:
cop = C.SubtractQuantumOp
case OpThresholdBlack:
cop = C.ThresholdBlackQuantumOp
case OpThreshold:
cop = C.ThresholdQuantumOp
case OpThresholdWhite:
cop = C.ThresholdWhiteQuantumOp
case OpXor:
cop = C.XorQuantumOp
default:
return notImplementedError(fmt.Sprintf("operator %s", op))
}
var ex C.ExceptionInfo
C.GetExceptionInfo(&ex)
defer C.DestroyExceptionInfo(&ex)
if C.QuantumOperatorImage(im.image, C.ChannelType(ch), cop, C.double(value), &ex) != C.MagickTrue {
return exError(&ex, "operating")
}
return nil
}