mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/atlas: bug fix: wrong logic to create a new mask with edges
* Fixed wrong operator orders * Cleared an allocated region explicitlly Closes #2089
This commit is contained in:
parent
9cfa84ddaa
commit
faf1e7350d
@ -570,21 +570,25 @@ func (i *Image) replacePixels(pix []byte, mask []byte) {
|
|||||||
if mask != nil {
|
if mask != nil {
|
||||||
origMask := mask
|
origMask := mask
|
||||||
mask = theTemporaryBytes.alloc((pw*ph-1)/8 + 1)
|
mask = theTemporaryBytes.alloc((pw*ph-1)/8 + 1)
|
||||||
|
// Clear the allocated region explicitly (#2089).
|
||||||
|
for i := range mask {
|
||||||
|
mask[i] = 0
|
||||||
|
}
|
||||||
for i := 0; i < pw; i++ {
|
for i := 0; i < pw; i++ {
|
||||||
// Top edge
|
// Top edge
|
||||||
idx := i
|
idx := i
|
||||||
mask[idx/8] |= 1 << idx % 8
|
mask[idx/8] |= 1 << (idx % 8)
|
||||||
// Bottom edge
|
// Bottom edge
|
||||||
idx = (ph-1)*pw + i
|
idx = (ph-1)*pw + i
|
||||||
mask[idx/8] |= 1 << idx % 8
|
mask[idx/8] |= 1 << (idx % 8)
|
||||||
}
|
}
|
||||||
for j := 1; j < ph-1; j++ {
|
for j := 1; j < ph-1; j++ {
|
||||||
// Left edge
|
// Left edge
|
||||||
idx := j * pw
|
idx := j * pw
|
||||||
mask[idx/8] |= 1 << idx % 8
|
mask[idx/8] |= 1 << (idx % 8)
|
||||||
// Right edge
|
// Right edge
|
||||||
idx = j*pw + pw - 1
|
idx = j*pw + pw - 1
|
||||||
mask[idx/8] |= 1 << idx % 8
|
mask[idx/8] |= 1 << (idx % 8)
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
for i := 1; i < pw-1; i++ {
|
for i := 1; i < pw-1; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user