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

Improve icon selection to pick the best-fitting icon size from ICO files #114

Merged
merged 2 commits into from
Oct 3, 2024
Merged

Improve icon selection to pick the best-fitting icon size from ICO files #114

merged 2 commits into from
Oct 3, 2024

Conversation

DarkPro1337
Copy link
Contributor

@DarkPro1337 DarkPro1337 commented Sep 25, 2024

After updating to version 2.0.0, the ScaleWithDpi method for Size consistently sets the tray icon to 16x16 pixels, ignoring system DPI and application DPI awareness. This leads to poorly scaled icons on high-DPI displays.

To fix this, I added the GetBestFitIcon method, which parses the ICO file and selects the most suitable icon based on the current DPI and SmallIconSize. I also removed unnecessary caching in SmallIconSize and simplified it.

Examples:

  • If SmallIconSize is 20x20 and the closest available icon is 22x22, it will choose the larger match.
  • It picks an exact match if available or the largest smaller icon to minimize scaling.

This change addresses incorrect scaling logic and improves icon appearance in the system tray across different DPI settings.

Likely resolves issue #75

Closes #75

- Updated ToIcon to select best-fitting icon from ICO file.
- Added GetBestFitIcon to find the most appropriate icon size.
- Modified SmallIconSize to use system metrics without DPI scaling.
- Remove unnecessary ScaleWithDpi method.
- Enhance icon selection for high-DPI clarity.
- Add error handling for invalid ICO files.
- Ensure proper resource disposal with using statements.
@punker76 punker76 added the Fix label Oct 3, 2024
@punker76 punker76 merged commit acf5773 into hardcodet:develop Oct 3, 2024
1 check passed
@punker76
Copy link
Collaborator

punker76 commented Oct 3, 2024

your changes have been merged, thanks for your contribution 👍

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