Skip to content

Commit 5915c69

Browse files
committed
Major performance improvements
1 parent baf24b4 commit 5915c69

File tree

8 files changed

+104
-112
lines changed

8 files changed

+104
-112
lines changed

backbody.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,34 @@ func RenderBackBody(img image.Image, opts Options) *image.NRGBA {
3434
if opts.Overlay {
3535
overlaySkin := fixTransparency(skin)
3636

37-
backHead = composite(backHead, extract(overlaySkin, HeadOverlayBack), 0, 0)
37+
composite(backHead, extract(overlaySkin, HeadOverlayBack), 0, 0)
3838

3939
if !isOldSkin {
40-
backTorso = composite(backTorso, extract(overlaySkin, TorsoOverlayBack), 0, 0)
41-
backLeftArm = composite(backLeftArm, extract(overlaySkin, GetLeftArmOverlayBack(opts.Slim)), 0, 0)
42-
backRightArm = composite(backRightArm, extract(overlaySkin, GetRightArmOverlayBack(opts.Slim)), 0, 0)
43-
backLeftLeg = composite(backLeftLeg, extract(overlaySkin, LeftLegOverlayBack), 0, 0)
44-
backRightLeg = composite(backRightLeg, extract(overlaySkin, RightLegOverlayBack), 0, 0)
40+
composite(backTorso, extract(overlaySkin, TorsoOverlayBack), 0, 0)
41+
composite(backLeftArm, extract(overlaySkin, GetLeftArmOverlayBack(opts.Slim)), 0, 0)
42+
composite(backRightArm, extract(overlaySkin, GetRightArmOverlayBack(opts.Slim)), 0, 0)
43+
composite(backLeftLeg, extract(overlaySkin, LeftLegOverlayBack), 0, 0)
44+
composite(backRightLeg, extract(overlaySkin, RightLegOverlayBack), 0, 0)
4545
}
4646
}
4747

4848
// Face
49-
output = composite(output, backHead, 4, 0)
49+
composite(output, backHead, 4, 0)
5050

5151
// Torso
52-
output = composite(output, backTorso, 4, 8)
52+
composite(output, backTorso, 4, 8)
5353

5454
// Left Arm
55-
output = composite(output, backLeftArm, slimOffset, 8)
55+
composite(output, backLeftArm, slimOffset, 8)
5656

5757
// Right Arm
58-
output = composite(output, backRightArm, 12, 8)
58+
composite(output, backRightArm, 12, 8)
5959

6060
// Left Leg
61-
output = composite(output, backLeftLeg, 4, 20)
61+
composite(output, backLeftLeg, 4, 20)
6262

6363
// Right Leg
64-
output = composite(output, backRightLeg, 8, 20)
64+
composite(output, backRightLeg, 8, 20)
6565

6666
return scale(output, opts.Scale)
6767
}

body.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,58 +44,58 @@ func RenderBody(img *image.NRGBA, opts Options) *image.NRGBA {
4444
if opts.Overlay {
4545
overlaySkin := fixTransparency(skin)
4646

47-
topHead = composite(topHead, rotate90(flipHorizontal(extract(overlaySkin, HeadOverlayTop))), 0, 0)
48-
frontHead = composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
49-
rightHead = composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
47+
composite(topHead, rotate90(flipHorizontal(extract(overlaySkin, HeadOverlayTop))), 0, 0)
48+
composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
49+
composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
5050

5151
if !isOldSkin {
52-
frontTorso = composite(frontTorso, extract(overlaySkin, TorsoOverlayFront), 0, 0)
53-
frontLeftArm = composite(frontLeftArm, extract(overlaySkin, GetLeftArmOverlayFront(opts.Slim)), 0, 0)
54-
topLeftArm = composite(topLeftArm, extract(overlaySkin, GetLeftArmOverlayTop(opts.Slim)), 0, 0)
55-
frontRightArm = composite(frontRightArm, extract(overlaySkin, GetRightArmOverlayFront(opts.Slim)), 0, 0)
56-
topRightArm = composite(topRightArm, extract(overlaySkin, GetRightArmOverlayTop(opts.Slim)), 0, 0)
57-
rightRightArm = composite(rightRightArm, extract(overlaySkin, RightArmOverlayRight), 0, 0)
58-
frontLeftLeg = composite(frontLeftLeg, extract(overlaySkin, LeftLegOverlayFront), 0, 0)
59-
frontRightLeg = composite(frontRightLeg, extract(overlaySkin, RightLegOverlayFront), 0, 0)
60-
rightRightLeg = composite(rightRightLeg, extract(overlaySkin, RightLegOverlayRight), 0, 0)
52+
composite(frontTorso, extract(overlaySkin, TorsoOverlayFront), 0, 0)
53+
composite(frontLeftArm, extract(overlaySkin, GetLeftArmOverlayFront(opts.Slim)), 0, 0)
54+
composite(topLeftArm, extract(overlaySkin, GetLeftArmOverlayTop(opts.Slim)), 0, 0)
55+
composite(frontRightArm, extract(overlaySkin, GetRightArmOverlayFront(opts.Slim)), 0, 0)
56+
composite(topRightArm, extract(overlaySkin, GetRightArmOverlayTop(opts.Slim)), 0, 0)
57+
composite(rightRightArm, extract(overlaySkin, RightArmOverlayRight), 0, 0)
58+
composite(frontLeftLeg, extract(overlaySkin, LeftLegOverlayFront), 0, 0)
59+
composite(frontRightLeg, extract(overlaySkin, RightLegOverlayFront), 0, 0)
60+
composite(rightRightLeg, extract(overlaySkin, RightLegOverlayRight), 0, 0)
6161
}
6262
}
6363

6464
// Right Side of Right Leg
65-
output = compositeTransform(output, scale(rightRightLeg, opts.Scale), sideMatrix, 4*scaleDouble, 23*scaleDouble)
65+
compositeTransform(output, scale(rightRightLeg, opts.Scale), sideMatrix, 4*scaleDouble, 23*scaleDouble)
6666

6767
// Front of Right Leg
68-
output = compositeTransform(output, scale(frontRightLeg, opts.Scale), frontMatrix, 8*scaleDouble, 31*scaleDouble)
68+
compositeTransform(output, scale(frontRightLeg, opts.Scale), frontMatrix, 8*scaleDouble, 31*scaleDouble)
6969

7070
// Front of Left Leg
71-
output = compositeTransform(output, scale(frontLeftLeg, opts.Scale), frontMatrix, 12*scaleDouble, 31*scaleDouble)
71+
compositeTransform(output, scale(frontLeftLeg, opts.Scale), frontMatrix, 12*scaleDouble, 31*scaleDouble)
7272

7373
// Front of Torso
74-
output = compositeTransform(output, scale(frontTorso, opts.Scale), frontMatrix, 8*scaleDouble, 19*scaleDouble)
74+
compositeTransform(output, scale(frontTorso, opts.Scale), frontMatrix, 8*scaleDouble, 19*scaleDouble)
7575

7676
// Front of Right Arm
77-
output = compositeTransform(output, scale(frontRightArm, opts.Scale), frontMatrix, float64(4+slimOffset)*scaleDouble, 19*scaleDouble)
77+
compositeTransform(output, scale(frontRightArm, opts.Scale), frontMatrix, float64(4+slimOffset)*scaleDouble, 19*scaleDouble)
7878

7979
// Front of Left Arm
80-
output = compositeTransform(output, scale(frontLeftArm, opts.Scale), frontMatrix, 16*scaleDouble, 19*scaleDouble)
80+
compositeTransform(output, scale(frontLeftArm, opts.Scale), frontMatrix, 16*scaleDouble, 19*scaleDouble)
8181

8282
// Top of Left Arm
83-
output = compositeTransform(output, scale(rotate270(topLeftArm), opts.Scale), plantMatrix, 15*scaleDouble, float64(slimOffset-1)*scaleDouble)
83+
compositeTransform(output, scale(rotate270(topLeftArm), opts.Scale), plantMatrix, 15*scaleDouble, float64(slimOffset-1)*scaleDouble)
8484

8585
// Right Side of Right Arm
86-
output = compositeTransform(output, scale(rightRightArm, opts.Scale), sideMatrix, float64(slimOffset)*scaleDouble, float64(15-slimOffset)*scaleDouble)
86+
compositeTransform(output, scale(rightRightArm, opts.Scale), sideMatrix, float64(slimOffset)*scaleDouble, float64(15-slimOffset)*scaleDouble)
8787

8888
// Top of Right Arm
89-
output = compositeTransform(output, scale(rotate90(topRightArm), opts.Scale), plantMatrix, 15*scaleDouble, 11*scaleDouble)
89+
compositeTransform(output, scale(rotate90(topRightArm), opts.Scale), plantMatrix, 15*scaleDouble, 11*scaleDouble)
9090

9191
// Front of Head
92-
output = compositeTransform(output, scale(frontHead, opts.Scale), frontMatrix, 10*scaleDouble, 13*scaleDouble)
92+
compositeTransform(output, scale(frontHead, opts.Scale), frontMatrix, 10*scaleDouble, 13*scaleDouble)
9393

9494
// Top of Head
95-
output = compositeTransform(output, scale(topHead, opts.Scale), plantMatrix, 5*scaleDouble, -5*scaleDouble)
95+
compositeTransform(output, scale(topHead, opts.Scale), plantMatrix, 5*scaleDouble, -5*scaleDouble)
9696

9797
// Right Side of Head
98-
output = compositeTransform(output, scale(rightHead, opts.Scale), sideMatrix, 2*scaleDouble, 3*scaleDouble)
98+
compositeTransform(output, scale(rightHead, opts.Scale), sideMatrix, 2*scaleDouble, 3*scaleDouble)
9999

100100
return output
101101
}

face.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func RenderFace(img *image.NRGBA, opts Options) *image.NRGBA {
1616
if opts.Overlay {
1717
overlaySkin := fixTransparency(skin)
1818

19-
output = composite(output, extract(overlaySkin, HeadOverlayFront), 0, 0)
19+
composite(output, extract(overlaySkin, HeadOverlayFront), 0, 0)
2020
}
2121

2222
return scale(output, opts.Scale)

frontbody.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,34 @@ func RenderFrontBody(img *image.NRGBA, opts Options) *image.NRGBA {
3434
if opts.Overlay {
3535
overlaySkin := fixTransparency(skin)
3636

37-
frontHead = composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
37+
composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
3838

3939
if !isOldSkin {
40-
frontTorso = composite(frontTorso, extract(overlaySkin, TorsoOverlayFront), 0, 0)
41-
leftArm = composite(leftArm, extract(overlaySkin, GetLeftArmOverlayFront(opts.Slim)), 0, 0)
42-
rightArm = composite(rightArm, extract(overlaySkin, GetRightArmOverlayFront(opts.Slim)), 0, 0)
43-
leftLeg = composite(leftLeg, extract(overlaySkin, LeftLegOverlayFront), 0, 0)
44-
rightLeg = composite(rightLeg, extract(overlaySkin, RightLegOverlayFront), 0, 0)
40+
composite(frontTorso, extract(overlaySkin, TorsoOverlayFront), 0, 0)
41+
composite(leftArm, extract(overlaySkin, GetLeftArmOverlayFront(opts.Slim)), 0, 0)
42+
composite(rightArm, extract(overlaySkin, GetRightArmOverlayFront(opts.Slim)), 0, 0)
43+
composite(leftLeg, extract(overlaySkin, LeftLegOverlayFront), 0, 0)
44+
composite(rightLeg, extract(overlaySkin, RightLegOverlayFront), 0, 0)
4545
}
4646
}
4747

4848
// Face
49-
output = composite(output, frontHead, 4, 0)
49+
composite(output, frontHead, 4, 0)
5050

5151
// Torso
52-
output = composite(output, frontTorso, 4, 8)
52+
composite(output, frontTorso, 4, 8)
5353

5454
// Left Arm
55-
output = composite(output, leftArm, 12, 8)
55+
composite(output, leftArm, 12, 8)
5656

5757
// Right Arm
58-
output = composite(output, rightArm, slimOffset, 8)
58+
composite(output, rightArm, slimOffset, 8)
5959

6060
// Left Leg
61-
output = composite(output, leftLeg, 8, 20)
61+
composite(output, leftLeg, 8, 20)
6262

6363
// Right Leg
64-
output = composite(output, rightLeg, 4, 20)
64+
composite(output, rightLeg, 4, 20)
6565

6666
return scale(output, opts.Scale)
6767
}

head.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ func RenderHead(img *image.NRGBA, opts Options) *image.NRGBA {
2323
if opts.Overlay {
2424
overlaySkin := fixTransparency(skin)
2525

26-
frontHead = composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
27-
topHead = composite(topHead, rotate90(flipHorizontal(extract(overlaySkin, HeadOverlayTop))), 0, 0)
28-
rightHead = composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
26+
composite(frontHead, extract(overlaySkin, HeadOverlayFront), 0, 0)
27+
composite(topHead, rotate90(flipHorizontal(extract(overlaySkin, HeadOverlayTop))), 0, 0)
28+
composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
2929
}
3030

3131
// Front Head
32-
output = compositeTransform(output, scale(frontHead, opts.Scale), frontMatrix, 8*scaleDouble, 12*scaleDouble)
32+
compositeTransform(output, scale(frontHead, opts.Scale), frontMatrix, 8*scaleDouble, 12*scaleDouble)
3333

3434
// Top Head
35-
output = compositeTransform(output, scale(topHead, opts.Scale), plantMatrix, 4*scaleDouble, -4*scaleDouble)
35+
compositeTransform(output, scale(topHead, opts.Scale), plantMatrix, 4*scaleDouble, -4*scaleDouble)
3636

3737
// Right Head
38-
output = compositeTransform(output, scale(rightHead, opts.Scale), sideMatrix, 0, 4*scaleDouble)
38+
compositeTransform(output, scale(rightHead, opts.Scale), sideMatrix, 0, 4*scaleDouble)
3939

4040
return output
4141
}

leftbody.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ func RenderLeftBody(img *image.NRGBA, opts Options) *image.NRGBA {
3030
if opts.Overlay {
3131
overlaySkin := fixTransparency(skin)
3232

33-
leftHead = composite(leftHead, extract(overlaySkin, HeadOverlayLeft), 0, 0)
33+
composite(leftHead, extract(overlaySkin, HeadOverlayLeft), 0, 0)
3434

3535
if !isOldSkin {
36-
leftLeftArm = composite(leftLeftArm, extract(overlaySkin, GetLeftArmOverlayLeft(opts.Slim)), 0, 0)
37-
leftLeftLeg = composite(leftLeftLeg, extract(overlaySkin, LeftLegOverlayLeft), 0, 0)
36+
composite(leftLeftArm, extract(overlaySkin, GetLeftArmOverlayLeft(opts.Slim)), 0, 0)
37+
composite(leftLeftLeg, extract(overlaySkin, LeftLegOverlayLeft), 0, 0)
3838
}
3939
}
4040

4141
// Left Head
42-
output = composite(output, leftHead, 4, 0)
42+
composite(output, leftHead, 4, 0)
4343

4444
// Left Arm
45-
output = composite(output, leftLeftArm, 6, 8)
45+
composite(output, leftLeftArm, 6, 8)
4646

4747
// Left Leg
48-
output = composite(output, leftLeftLeg, 6, 20)
48+
composite(output, leftLeftLeg, 6, 20)
4949

5050
return scale(output, opts.Scale)
5151
}

rightbody.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ func RenderRightBody(img *image.NRGBA, opts Options) *image.NRGBA {
2121
if opts.Overlay {
2222
overlaySkin := fixTransparency(skin)
2323

24-
rightHead = composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
24+
composite(rightHead, extract(overlaySkin, HeadOverlayRight), 0, 0)
2525

2626
if !IsOldSkin(skin) {
27-
rightRightArm = composite(rightRightArm, extract(overlaySkin, RightArmOverlayRight), 0, 0)
28-
rightRightLeg = composite(rightRightLeg, extract(overlaySkin, RightLegOverlayRight), 0, 0)
27+
composite(rightRightArm, extract(overlaySkin, RightArmOverlayRight), 0, 0)
28+
composite(rightRightLeg, extract(overlaySkin, RightLegOverlayRight), 0, 0)
2929
}
3030
}
3131

3232
// Right Head
33-
output = composite(output, rightHead, 4, 0)
33+
composite(output, rightHead, 4, 0)
3434

3535
// Right Arm
36-
output = composite(output, rightRightArm, 6, 8)
36+
composite(output, rightRightArm, 6, 8)
3737

3838
// Right Leg
39-
output = composite(output, rightRightLeg, 6, 20)
39+
composite(output, rightRightLeg, 6, 20)
4040

4141
return scale(output, opts.Scale)
4242
}

util.go

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -145,37 +145,6 @@ func removeTransparency(img *image.NRGBA) *image.NRGBA {
145145
return output
146146
}
147147

148-
func composite(bottom, top *image.NRGBA, dx, dy int) *image.NRGBA {
149-
output := clone(bottom)
150-
151-
outputBounds := output.Bounds()
152-
srcBounds := top.Bounds()
153-
154-
for x := srcBounds.Min.X; x < srcBounds.Max.X; x++ {
155-
for y := srcBounds.Min.Y; y < srcBounds.Max.Y; y++ {
156-
if dx+x < outputBounds.Min.X || dy+y < outputBounds.Min.Y || dx+x >= outputBounds.Max.X || dy+y >= outputBounds.Max.Y {
157-
continue
158-
}
159-
160-
index := y*top.Stride + x*4
161-
sourceColor := top.Pix[index : index+4]
162-
sourceAlpha := uint32(sourceColor[3]) * 0x101
163-
164-
index = (dy+y)*output.Stride + (dx+x)*4
165-
outputColor := output.Pix[index : index+4]
166-
167-
alphaOffset := ((1<<16 - 1) - sourceAlpha) * 0x101
168-
169-
outputColor[0] = uint8((uint32(outputColor[0])*alphaOffset/(1<<16-1) + (uint32(sourceColor[0]) * sourceAlpha / 0xff)) >> 8)
170-
outputColor[1] = uint8((uint32(outputColor[1])*alphaOffset/(1<<16-1) + (uint32(sourceColor[1]) * sourceAlpha / 0xff)) >> 8)
171-
outputColor[2] = uint8((uint32(outputColor[2])*alphaOffset/(1<<16-1) + (uint32(sourceColor[2]) * sourceAlpha / 0xff)) >> 8)
172-
outputColor[3] = uint8((uint32(outputColor[3])*alphaOffset/(1<<16-1) + sourceAlpha) >> 8)
173-
}
174-
}
175-
176-
return output
177-
}
178-
179148
func flipHorizontal(src *image.NRGBA) *image.NRGBA {
180149
bounds := src.Bounds()
181150
output := image.NewNRGBA(bounds)
@@ -233,16 +202,36 @@ func getSlimOffset(slim bool) int {
233202
return 0
234203
}
235204

205+
func composite(dst, src *image.NRGBA, dx, dy int) {
206+
outputBounds := dst.Bounds()
207+
srcBounds := src.Bounds()
208+
209+
for x := srcBounds.Min.X; x < srcBounds.Max.X; x++ {
210+
for y := srcBounds.Min.Y; y < srcBounds.Max.Y; y++ {
211+
if dx+x < outputBounds.Min.X || dy+y < outputBounds.Min.Y || dx+x >= outputBounds.Max.X || dy+y >= outputBounds.Max.Y {
212+
continue
213+
}
214+
215+
index := y*src.Stride + x*4
216+
sourceColor := src.Pix[index : index+4]
217+
218+
index = (dy+y)*dst.Stride + (dx+x)*4
219+
outputColor := dst.Pix[index : index+4]
220+
221+
compositeColors(outputColor, sourceColor)
222+
}
223+
}
224+
}
225+
236226
// This function is a whole mess of code that I do not want to touch, but it
237227
// seems to work very well. Most of this code was influenced by code in the
238228
// `go/x/image` package, but with a lot less redundancy. The color mixing
239229
// code was taken from the built-in Go method draw.Draw() from the
240230
// `image/draw` package.
241-
func compositeTransform(dst, src *image.NRGBA, m matrix2x2, outputX, outputY float64) *image.NRGBA {
231+
func compositeTransform(dst, src *image.NRGBA, m matrix2x2, outputX, outputY float64) {
242232
sourceBounds := src.Bounds()
243233

244-
output := clone(dst)
245-
outputBounds := output.Bounds()
234+
dstBounds := dst.Bounds()
246235

247236
im := m.Inverse()
248237
dr := transformRect(m, src.Bounds())
@@ -252,7 +241,7 @@ func compositeTransform(dst, src *image.NRGBA, m matrix2x2, outputX, outputY flo
252241
for boundY := dr.Min.Y; boundY < dr.Max.Y; boundY++ {
253242
outputX, outputY := boundX+int(dox), boundY+int(doy)
254243

255-
if outputX < outputBounds.Min.X || outputY < outputBounds.Min.Y || outputX >= outputBounds.Max.X || outputY >= outputBounds.Max.Y {
244+
if outputX < dstBounds.Min.X || outputY < dstBounds.Min.Y || outputX >= dstBounds.Max.X || outputY >= dstBounds.Max.Y {
256245
continue
257246
}
258247

@@ -264,21 +253,24 @@ func compositeTransform(dst, src *image.NRGBA, m matrix2x2, outputX, outputY flo
264253

265254
index := int(sourceY)*src.Stride + int(sourceX)*4
266255
sourceColor := src.Pix[index : index+4]
267-
sourceAlpha := uint32(sourceColor[3]) * 0x101
268-
269-
index = outputY*output.Stride + outputX*4
270-
outputColor := output.Pix[index : index+4]
271256

272-
alphaOffset := ((1<<16 - 1) - sourceAlpha) * 0x101
257+
index = outputY*dst.Stride + outputX*4
258+
outputColor := dst.Pix[index : index+4]
273259

274-
outputColor[0] = uint8((uint32(outputColor[0])*alphaOffset/(1<<16-1) + (uint32(sourceColor[0]) * sourceAlpha / 0xff)) >> 8)
275-
outputColor[1] = uint8((uint32(outputColor[1])*alphaOffset/(1<<16-1) + (uint32(sourceColor[1]) * sourceAlpha / 0xff)) >> 8)
276-
outputColor[2] = uint8((uint32(outputColor[2])*alphaOffset/(1<<16-1) + (uint32(sourceColor[2]) * sourceAlpha / 0xff)) >> 8)
277-
outputColor[3] = uint8((uint32(outputColor[3])*alphaOffset/(1<<16-1) + sourceAlpha) >> 8)
260+
compositeColors(outputColor, sourceColor)
278261
}
279262
}
263+
}
280264

281-
return output
265+
func compositeColors(outputColor, sourceColor []uint8) {
266+
sourceAlpha := uint32(sourceColor[3]) * 0x101
267+
268+
alphaOffset := ((1<<16 - 1) - sourceAlpha) * 0x101
269+
270+
outputColor[0] = uint8((uint32(outputColor[0])*alphaOffset/(1<<16-1) + (uint32(sourceColor[0]) * sourceAlpha / 0xff)) >> 8)
271+
outputColor[1] = uint8((uint32(outputColor[1])*alphaOffset/(1<<16-1) + (uint32(sourceColor[1]) * sourceAlpha / 0xff)) >> 8)
272+
outputColor[2] = uint8((uint32(outputColor[2])*alphaOffset/(1<<16-1) + (uint32(sourceColor[2]) * sourceAlpha / 0xff)) >> 8)
273+
outputColor[3] = uint8((uint32(outputColor[3])*alphaOffset/(1<<16-1) + sourceAlpha) >> 8)
282274
}
283275

284276
func rotate90(img *image.NRGBA) *image.NRGBA {

0 commit comments

Comments
 (0)