Skip to content
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

Tiles outside the image are created #531

Open
inneke-dc opened this issue Jul 30, 2019 · 8 comments
Open

Tiles outside the image are created #531

inneke-dc opened this issue Jul 30, 2019 · 8 comments

Comments

@inneke-dc
Copy link

I've noticed that sometimes a row or column is set on a tile that is outside of the image's bounds. This originates from TileView.computeAndRenderTilesInViewport(): the grid is too large. This affects the Tile.mDestinationRect. Later in Tile.decode(), this same row and column is used to render a tile with mStreamProvider.getStream(). Is there a reason why these non-existing tiles are rendered?

The problem that I'm experiencing is that in my project the tiles are loaded with http requests, and our client's server returns white tiles for invalid coordinates. True, this is just a bad design and the server should return an error or empty stream, but maybe other people have issues with this as well.

Thank you for maintaining this library the way you do and always being quick to answer, I appreciate it.

@tva-TIS
Copy link

tva-TIS commented Jul 30, 2019

Is it possible that this is linked to the problem I described in #530 ?

@inneke-dc
Copy link
Author

It seems to be the same problem, yes. It's happening when the image does not completely fill the TileView. In that case, additional rows are requested at the bottom to completely fill the view (the top is fine - my image is centered). However, the images I'm using have a larger full scale resolution than the container. You seemed to only have issues with very small images.

@moagrius
Copy link
Owner

with open source projects like this where i have very little time, if you can find or identify the specific issue (in this case, i think the suggestion is that there's something wrong with how the grid is calculated), that'd certainly help me get it fixed, considering the very limited amount of time i have to work on issues. if not, i'll give it a shot next time i can; probably a month or so. sorry for the hassle.

@tva-TIS
Copy link

tva-TIS commented Jul 31, 2019

with open source projects like this where i have very little time, if you can find or identify the specific issue (in this case, i think the suggestion is that there's something wrong with how the grid is calculated), that'd certainly help me get it fixed, considering the very limited amount of time i have to work on issues. if not, i'll give it a shot next time i can; probably a month or so. sorry for the hassle.

Might have some time to look into it myself. Just to be sure: @inneke-dc you are using version 4.0.7 too, right?

@inneke-dc
Copy link
Author

I think I got it but I'm not sure if it will cover all cases. It seemed to fix it for me in a layout where the image is centered in the TileView and where the scaling starts at a 'fitCenter' state:

tileView.setMinimumScaleMode(ScalingScrollView.MinimumScaleMode.CONTAIN) tileView.setScaleLimits(0f, 2f)

When changing the TileView.updateViewport() from

mViewport.right = mViewport.left + getMeasuredWidth(); mViewport.bottom = mViewport.top + getMeasuredHeight();

to

mViewport.right = mViewport.left + Math.min(getMeasuredWidth(), getScaledWidth()); mViewport.bottom = mViewport.top + Math.min(getMeasuredHeight(), getScaledHeight());

just the right amount of rows and columns are created.

I do not know what else will be affected by this however.

@inneke-dc
Copy link
Author

with open source projects like this where i have very little time, if you can find or identify the specific issue (in this case, i think the suggestion is that there's something wrong with how the grid is calculated), that'd certainly help me get it fixed, considering the very limited amount of time i have to work on issues. if not, i'll give it a shot next time i can; probably a month or so. sorry for the hassle.

Might have some time to look into it myself. Just to be sure: @inneke-dc you are using version 4.0.7 too, right?

Yes, I'm using the most recent code.

@tva-TIS
Copy link

tva-TIS commented Jul 31, 2019

mViewport.right = mViewport.left + Math.min(getMeasuredWidth(), getScaledWidth()); mViewport.bottom = mViewport.top + Math.min(getMeasuredHeight(), getScaledHeight());

Tested this with my project too. Solves the issue for small images too.

@moagrius
Copy link
Owner

This is awesome! Thanks so much for digging in. I may need to make some minor tweaks but this looks very promising - I'll try to get his verified (and committed, hopefully) as soon as I get some time (I'll shoot for Mon-Tues of next week - gone all weekend).

Thanks again! Nice open source-ery ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants