Draw a raster from the top left of its image bounds - #6496
Open
4RH1T3CT0R7 wants to merge 1 commit into
Open
Conversation
Member
|
Can you rebase this on develop current to see how many of the test failures go away? |
NewRasterFromImage was treating the origin of the source image bounds as a position on the canvas object. An image cut out of a sprite sheet, or one built with image.NewRGBA(image.Rect(150, 200, 300, 400)), was drawn shifted by Bounds().Min - or not drawn at all when the raster happened to be exactly the size of the image, as the painter then read from pixels that are outside the source. Where the two did not overlap at all the generator returned an image.Uniform, whose infinite bounds panic the software scaler. It now always returns the destination it allocated, so the uncovered area is the zero pixels that image was made with. Fixes fyne-io#6461
4RH1T3CT0R7
force-pushed
the
fix/raster-bounds
branch
from
August 28, 2026 14:14
10cdd9e to
c385d8e
Compare
Author
|
Rebased onto current develop, same single commit. Let's see what CI makes of it now. |
Author
|
Everything passes now except platform_tests (stable, ubuntu-latest), and that one only trips the coverage gate at the end, no test fails. develop's own run on 3c6ad39 fails the same way (https://github.com/fyne-io/fyne/actions/runs/32974081173/job/98194438933), so it doesn't look related to this change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On
developthe reproducer in #6461 doesn't just draw in the wrong place, it panics,makeslice: cap out of rangeinsidex/image/draw. When the raster and the image bounds don't overlap the generator returns animage.Uniform, and the scaler tries to allocate from its infinite bounds.The generator was treating
Bounds().Minas a position on the canvas object, so an image cut out of a sprite sheet drew shifted. It now always returns the destination image at the raster size with the source drawn in from its top left, which is the mapping @andydotxyz described on the issue.TestRasterFromImageasserted the old placement and now asserts (0, 0).It's a behaviour change: @dweymouth suggested holding it for 3.0, @andydotxyz replied that the documentation was the wrong part.
canvas.Imagehas the same problem and I've left it alone.Fixes #6461