Fix DASH thumbnails cropping the incorrect tile for non-square images #1300
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.
The calculation for finding the column a
tileIndex
corresponds to is currentlytileIndex % inputFormat.tileCountVertical
. This should instead betileIndex % inputFormat.tileCountHorizontal
(see this SO answer) to work for non-square images. It works for square images sincetileCountVertical == tileCountHorizontal
, so the same values are produced.Using
tileCountVertical
for non-square images results in either:tileCountVertical
is equal to 1 (sprites with one row of images) it always crops out the first tiletileCountVertical
is larger than 1 it will attempt to crop out a bitmap outside the bounds of the larger bitmap, resulting inBitmap.createBitmap()
throwing an exception.Exception thrown
I have updated
ImageRenderTest
to use a 2x3 image instead of 2x2. Reverting my change will make the updated tests fail, as expected, but please verify they still work as intended.I have created a separate branch that displays thumbnails in the demo app that can be used for testing. Two samples are added, one for the one row case and one for non-squares with more than one row. The videos below are taken from this branch.
Before
Screen_recording_20240420_085532.mp4
After
Screen_recording_20240420_085434.mp4