-
Notifications
You must be signed in to change notification settings - Fork 35
/
composite.go
119 lines (114 loc) · 2.61 KB
/
composite.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package magick
// #include <magick/api.h>
// #include "bridge.h"
// #include "composite.h"
import "C"
// Composite represents a composition operation. Refer
// to the individual constants for more information. Note
// that not all compositions are supported by the
// GraphicsMagick backend.
type Composite int
const (
CompositeAlpha Composite = iota + 1
CompositeAtop
CompositeBlend
CompositeBlur
CompositeBumpmap
CompositeChangeMask
CompositeClear
CompositeColorBurn
CompositeColorDodge
CompositeColorize
CompositeCopyBlack
CompositeCopyBlue
CompositeCopy
CompositeCopyCyan
CompositeCopyGreen
CompositeCopyMagenta
CompositeCopyAlpha
CompositeCopyRed
CompositeCopyYellow
CompositeDarken
CompositeDarkenIntensity
CompositeDifference
CompositeDisplace
CompositeDissolve
CompositeDistort
CompositeDivideDst
CompositeDivideSrc
CompositeDstAtop
CompositeDst
CompositeDstIn
CompositeDstOut
CompositeDstOver
CompositeExclusion
CompositeHardLight
CompositeHue
CompositeIn
CompositeIntensity
CompositeLighten
CompositeLightenIntensity
CompositeLinearBurn
CompositeLinearDodge
CompositeLinearLight
CompositeLuminize
CompositeMathematics
CompositeMinusDst
CompositeMinusSrc
CompositeModulate
CompositeModulusAdd
CompositeModulusSubtract
CompositeMultiply
CompositeNo
CompositeOut
CompositeOver
CompositeOverlay
CompositePegtopLight
CompositePinLight
CompositePlus
CompositeReplace
CompositeSaturate
CompositeScreen
CompositeSoftLight
CompositeSrcAtop
CompositeSrc
CompositeSrcIn
CompositeSrcOut
CompositeSrcOver
CompositeThreshold
CompositeUndefined
CompositeVividLight
CompositeXor
)
// Composite modifies the image, drawing the draw Image argument at offset
// (x, y) using the c Composite operation.
func (im *Image) Composite(c Composite, draw *Image, x int, y int) error {
op, err := im.compositeOperator(c)
if err != nil {
return err
}
var ex C.ExceptionInfo
C.GetExceptionInfo(&ex)
defer C.DestroyExceptionInfo(&ex)
var data C.CompositeData
data.composite = C.int(op)
data.draw = draw.image
data.x = C.int(x)
data.y = C.int(y)
res, err := im.applyDataFunc("compositing", C.ImageDataFunc(C.compositeImage), &data)
// res.image will be != than im.image when im is a non
// coalesced animation
if res.image != im.image {
unrefImages(im.image)
initializeRefCounts(res.image)
refImages(res.image)
im.image = res.image
dontFree(res)
}
return err
}
// CompositeInto is equivalent to canvas.Composite/c, im, x, y). See Image.Composite
// for more information.
func (im *Image) CompositeInto(c Composite, canvas *Image, x int, y int) error {
return canvas.Composite(c, im, x, y)
}