![]() |
DPI issues with PNG icons and XTP 20.1 |
Post Reply ![]() |
Author | |
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() Posted: 21 September 2021 at 9:10am |
Hi,
Has anyone gotten their application look OK using bitmap icons in the ribbon using XTP 20.1? With DPI image scaling enabled I don't get any 'large' icons (Paste button should have been a large icon - xtpButtonIconAndCaptionBelow - but here displayed as xtpButtonIconAndCaption regardless of width of the application and reduction mode). Using the RibbonExample I have not found the combination to make the icons look good (well, as good as the can being stretched from 32px version). I have 250% scaling on my screen ![]() |
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
astoyan ![]() Admin Group ![]() ![]() Joined: 24 August 2013 Status: Offline Points: 300 |
![]() ![]() ![]() ![]() ![]() |
Try to add this line at some place before any UI is created:
XTPDpiHelper()->EnableDpiBitmapScaling(); The behavior of bitmap scaling has changed by default in version 20.1, that line enables it globally.
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
Hi, thanks for the reply.
I tried the solution but still no improvements - no icons are shown with style xtpButtonIconAndCaptionBelow by default. I add ribbon icons as xtpControlButton. Previously they were rendered xtpButtonIconAndCaptionBelow if there was room enough (if the application was wide enough) If I specify xtpButtonIconAndCaptionBelow style, then they are displayed in that way, but no longer collapse in a good way. Also with this style they icon become larger than previously. |
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 871 |
![]() ![]() ![]() ![]() ![]() |
We do our own scaling using WIC (Windows Imaging Component) which does a pretty good job. WIC has now added cubic filtering too. We load our 16x16 and 32x32 icons into the image manager. Then I examine the system DPI and if > 100 (might be 125), we take each glyph and run it through WIC to scale it and then give it to the image manager too. I have a 4k monitor as part of my 3 monitor desktop config and use it as primary and set to 200%. So, I am always scaling our 32x32 icons to 64x64 and so far we have not found a reason to create a set of 64x64 icons. At some point, even WIC will fail to produce images that are good enough but so far we have had no complaints. Now, when will I get that 8k monitor so I can find out how it works scaling 32x32 to 128x128? Rats. Boss says "Not anytime soon." Historically, WIC, if driven properly, has worked better than any GDI scaling even when one enables halftone filtering. It isn't too hard to use. Our display guy has some template wrappers around WIC that make the calls I use one liners.
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
Thanks for your tip with WIC - I will check it out!
However, I don't think it will solve my problems for now. We have a show stopper problem with 19.3 and the property grid control. Looks like it has been fixed in 20/20 but then I have another show stopper easily reproduced with RibbonMDISample: just modify CMainFrame::LoadIcons() to always call LoadRasterIcons() and nothing more: I want the ribbon icons have the style icon and caption below - the default style when there is enough room. I hope there is an easy fix, since it looks like I am the only one complaining about this? ![]() |
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
maureencurtis ![]() Newbie ![]() ![]() Joined: 26 November 2021 Location: USA/Chicago Status: Offline Points: 1 |
![]() ![]() ![]() ![]() ![]() |
I initially had everything right and convenient.
|
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 871 |
![]() ![]() ![]() ![]() ![]() |
I usually find the painting code and step thru it when I have an icon or other issue. You can also add code to get the icon size and/or the icon set and see what sizes are available. Also, we don't rely on defaults as they change over time so when we want a large icon and caption below we explicitly set the style for icon and caption below on any control we want it on.. Not at work so I'm not able to run the sample I have (has the same look when I set raster icons as your image) and debug the CJ code right now. I think I find some API like "drawcontrolparent". Usually takes me a few searches before I recognize the code and set a BP that trips.
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
... ok.. so I have 250% scaling on my primary monitor, and I am not using XAML icons... In CXTPRibbonGroup::OnBeforeCalcSize(CDC* pDC), GetRibbonBar()->GetLargeIconSize(FALSE/*bAutoSize*/); is called with FALSE indicating we want the size of large icons not adjusted for DPI. However, this function returns CSize(80, 80) (= 32 * 2.5) for me which is not what is wanted since the return value should not have been scaled for DPI. Looking at CSize CXTPCommandBar::GetLargeIconSize(BOOL bAutoSize) we see that if m_pOptions->szIcons is empty, the return value will be 2 * XTPSystemMetrics()->GetSmallIconSize() regardless the value of bAutoSize. Back to CXTPRibbonGroup::OnBeforeCalcSize we see that pControl->GetImageManager()->IsPrimaryImageExists will return false because an icon with the size {80, 80} does not exists in the icon set. And then, when IsPrimaryImageExists returns false the next statement pControl->m_buttonRibbonStyle will be set to xtpButtonIconAndCaption instead of xtpButtonIconAndCaptionBelow since it thinks that no image should be drawn. (But later in the code an image will be drawn anyway.) If I modify GetLargeIconSize to the following it seems like it works.
😴 |
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
dbrookes ![]() Groupie ![]() Joined: 30 August 2019 Location: Australia Status: Offline Points: 70 |
![]() ![]() ![]() ![]() ![]() |
Can anyone confirm if this has been fixed in the 20.2 release? I'm too lazy to download it :)
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
No, it is not fixed in the 20.2 release.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
... and it is not fixed in the 20.3 release.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
... and it is not fixed in the 22.0 release.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
... and it is not fixed in the v24.0.0 (Beta 1) release.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
agontarenko ![]() Admin Group ![]() Joined: 25 March 2016 Status: Offline Points: 275 |
![]() ![]() ![]() ![]() ![]() |
Hello,
I've checked RibbonMDISample and found that not all images are scaled when "Enable DPI Icons Scaling" option enabled. I changed next function void CMainFrame::OnDpiIconsScaling() I added line, that discribed by my collegue in this forum thread XTPDpiHelper()->EnableDpiBitmapScaling(); after all images are scaled as expected. So, I problem with DPI scaling png images was solved. Regards, Artem Gontarenko ![]() |
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
But notice on your screenshot that the layout is wrong. The icons are displayed using style (xtpButtonIconAndCaption) even though there is plenty of space and they are added as
pGroupFile->Add(xtpControlButton, ID_FILE_NEW); pGroupFile->Add(xtpControlButton, ID_FILE_OPEN); pGroupFile->Add(xtpControlButton, ID_FILE_CLOSE);
When you use SVG icons the style becomes xtpButtonIconAndCaptionBelow. Compare with this screenshot: this is how I want the layout but it is no longer possible after 19.3. (Here I have applied the workaround I posted couple of years ago). ![]() |
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
Artem -if you look in my post from Posted: 2021 November 12 at 1:15am an 2021 November 27 at 11:08pm - after the 19.3 release it is no longer possible to have a large icon with the caption below if you use PNG images for the ribbon.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
agontarenko ![]() Admin Group ![]() Joined: 25 March 2016 Status: Offline Points: 275 |
![]() ![]() ![]() ![]() ![]() |
Hello, So if you use different DPIs, you should be add PNG for each DPI. For example: PNG icon 16x16 will be used with 100%DPI and PNG icon 32x32 will be used with 200%DPI etc. See please MultiLangRibbon as example. And you can to use XAML/SVG icons to exclude DPI scale problems. Regargs, Artem Gontarenko
|
|
![]() |
|
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() |
I think you missed the point again. I can't use XAML/SVG icons basically because then someone has to generate them for me and that is not happening. Using the MDI Ribbon Look at the difference between the Office 2016 theme and Office 2007 theme. In the Office 2007 theme the New, Open, Close button are stacked ontop of each other even though there is space, and even though if I would change the code to below. This is a regression since XTP 19.3.
![]() The buttons above are not adhering to xtpButtonIconAndCaptionBelow style. I am using 2013 theme myself, but same thing there.
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
agontarenko ![]() Admin Group ![]() Joined: 25 March 2016 Status: Offline Points: 275 |
![]() ![]() ![]() ![]() ![]() |
Hello, CSize szIcons; // Size of the normal icons. CSize szLargeIcons; // Size of the large icons. By default it 0. You need to change them and icon size will be obtained from CXTPCommandBarsOptions inCXTPCommandBar::GetLargeIconSize function. So icon size will be same as PNG icon size. ![]() Regards, Artem Gontarenko
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |