It might be expected that Image.Size is the size of Image.Bounds but this is not the case with SubImage created images which is causing me some math headaches. Take the following code:
package main
import (
"fmt"
"image"
"github.com/hajimehoshi/ebiten"
)
func main() {
img, _ := ebiten.NewImage(100, 100, ebiten.FilterDefault)
w, h := img.Size()
fmt.Printf("Bounds: %v, Size: %v - %v\n", img.Bounds(), w, h)
subImg := img.SubImage(image.Rect(20, 20, 40, 40)).(*ebiten.Image)
subW, subH := subImg.Size()
fmt.Printf("Bounds: %v, Size: %v - %v\n", subImg.Bounds(), subW, subH)
}
This outputs:
Bounds: (0,0)-(100,100), Size: 100 - 100
Bounds: (20,20)-(40,40), Size: 100 - 100
But you would expect:
Bounds: (0,0)-(100,100), Size: 100 - 100
Bounds: (20,20)-(40,40), Size: 20 - 20
If this is by intention, I cannot see it documented anywhere.
Nice catch, thanks!
@hajimehoshi - This change may have made other things break. I am still investigating...
@hajimehoshi - yeah, this broke many DrawImage calls which leverages Size. Can you confirm w/ a go build -a on any of your examples while having this commit checked out?
Oops, I'll revert this asap, and fix this again. Sorry.