mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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 {
|
||||
origMask := mask
|
||||
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++ {
|
||||
// Top edge
|
||||
idx := i
|
||||
mask[idx/8] |= 1 << idx % 8
|
||||
mask[idx/8] |= 1 << (idx % 8)
|
||||
// Bottom edge
|
||||
idx = (ph-1)*pw + i
|
||||
mask[idx/8] |= 1 << idx % 8
|
||||
mask[idx/8] |= 1 << (idx % 8)
|
||||
}
|
||||
for j := 1; j < ph-1; j++ {
|
||||
// Left edge
|
||||
idx := j * pw
|
||||
mask[idx/8] |= 1 << idx % 8
|
||||
mask[idx/8] |= 1 << (idx % 8)
|
||||
// Right edge
|
||||
idx = j*pw + pw - 1
|
||||
mask[idx/8] |= 1 << idx % 8
|
||||
mask[idx/8] |= 1 << (idx % 8)
|
||||
|
||||
// Content
|
||||
for i := 1; i < pw-1; i++ {
|
||||
|
Loading…
Reference in New Issue
Block a user