Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Properly size the canvas based on image size and rotation angle #275

Merged
merged 4 commits into from Sep 7, 2019

Conversation

agpixdev
Copy link
Contributor

@agpixdev agpixdev commented Sep 3, 2019

The current implementation used for rendering images does not handle correctly images whose width or height exceed a default value (around 300 pixels in width/height). This results in the image being clipped when displayed. This is even more evident when the image is rotated as this increases the effective canvas size requirements.

The changes are fixes for this limitation. The fix is demonstrated in the modified version of the icon.html example. To see the effect, first run the updated version of the example without the fix applied. Then compare with the fix applied.

The icon.html example shows a rotating Linux icon (512x512) with no clipping. Before the change, only the central portion of the icon would be visible.

Linux demo icon comes from http://www.softicons.com/toolbar-icons/programmers-pack-icons-by-iconshock/linux-icon

and is licensed as freeware.
Copy link
Member

@adube adube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the icon.html example from your branch, you'll see that the small icon is clipped.

If you look at the same example from master, it's not clipped.

I haven't looked deeper at why, but would you please take a look to try to figure what's wrong?

Thanks.

@agpixdev
Copy link
Contributor Author

agpixdev commented Sep 5, 2019

OK, will check and get back to you. Thanks @adube !

Include the anchor offset in the canvas width & height determination. Updated example to show effect.
@agpixdev
Copy link
Contributor Author

agpixdev commented Sep 5, 2019

This update now takes into account the anchor offsets, fixing the problem seen.

@adube
Copy link
Member

adube commented Sep 5, 2019

Thanks. I should be able to test the patch again this weekend.

Copy link
Member

@adube adube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is clean. Tested and it works properly now. Thanks for this nice contribution!

@adube adube merged commit dd97877 into mapgears:master Sep 7, 2019
@agpixdev
Copy link
Contributor Author

agpixdev commented Sep 9, 2019

Merci Alexandre ! Thanks for providing and maintaining this library for the community !

@agpixdev agpixdev deleted the rotated-mapicon-pixels-chopped-pr branch September 9, 2019 14:24
@adube
Copy link
Member

adube commented Sep 9, 2019

Thanks :)

Thanks to you and every contributor as well!

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

Successfully merging this pull request may close these issues.

None yet

2 participants