-
-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ebiten: NewImageFromImage should respect the original image bounds #2013
Comments
Quick reply:
In general, |
I'm not sure what the differences between Ebiten's image and For |
Yes, as I wrote, "Ebiten still complies with the spec reviewed above". But then I highlighted that it only complies due to a very specific set of restrictions in the ways Ebiten operates. I make the point that trying to fix At first glance it may seem vain to focus on these "hypotheticals", but I argue that we can't even classify |
So, I cannot see the reason why we should keep the original bounds yet (I think you just suggest the possibility). I think I can change NewImageFromImage and Image implementation without breaking at Draw* behaviors, as Draw* doesn't respect the left-upper position anyway. (Even though the left-upper position is non-zero, Draw* treats the image as if the image's left-upper position is (0, 0)). |
My understanding is that you want to use Ebiten's images for other Go utilities, right? Then negative left-upper positions might be meaningful in this case. |
I realized the case when this breaks the compatibility: when an image created by So, unfortunately I hesitate to introduce this change. I'd like to revisit when the version becomes v3.0, or if this is urgent, I'll consider to add a new function besides |
It's ok, we can leave it for v3, I'll use a wrapper in the meantime. |
Should |
This change adds NewImageWithOptions, that creates a new image with the given options. NewImageWithOptions takes image.Rectangle instead of a width and a height, then a user can create an image with an arbitrary bounds. A left-upper position can be a negative number. NewImageWithOptions can create an unmanged image, that is no longer on an automatic internal texture atlas. A user can have finer controls over the image. This change also adds tests for this function. Updates #2013 Updates #2017 Updates #2124
NewImageFromImage
will reset the bounds to start at(0, 0)
instead of keeping the bounds of the given image, and no safe alternative mechanism exists to modify them afterwards.I came across this while drawing font glyphs: in glyph masks, bounds can be used to indicate which parts of the glyph go above and below the baseline. More generally, we could say that bounds do not only delimit the area of the image being used, but also its origin (x, y) coordinates.
Ebiten bounds vs
image.Image
boundsWhile exploring the issue more in depth I realized that Ebiten semantics for bounds are actually quite different from
image.Image
specs (from now ongo/image
). Reviewing thego/image
definition:I want to highlight the following:
go/image
would become more obvious, including the fact thatAt()
could panic despite the passed coordinates being within bounds. In particular, negative coordinates would always panic.DrawImage
would illustrate these points, but it's obvious if we refer back to the first item in this list.Conclusion
Despite what it may look like, the point of the previous section wasn't to bash Ebiten for doing wrong something it hasn't tried to do yet, but rather to highlight the severe discordances with
go/image
and conclude:NewImageFromImage
to respect original bounds would be a non-breaking change only if bounds didn't do anything when drawing... but as previously mentioned, this would still break Ebiten internally and require changes in the implementation of subimages. Comparing the cost (implementation work + at least oneimage.Point
more in*ebiten.Image
to control subimage offset fromoriginal
) and the benefits (users can access the bounds as they originally were) doesn't look too fun.go/image
compliance and focusing on actual usage of*ebiten.Image
instead. Given that specific performance considerations need to be taken into account anyway (e.g:At()
), maybe some of the methods likeColorModel()
andBounds()
simply are not justified in Ebiten. What are the advantages of complying withgo/image
?The text was updated successfully, but these errors were encountered: