ICO images are fuzzy when used for ribbon images

Ribbon for WPF Forum

Posted 9 years ago by Philipp Schmid
Version: 9.2.0513
Avatar
We have noticed that the ribbon button image seems to be fuzzy when we use Windows Icons (ICO files) as the ImageSourceSmall. When we use PNG files (32x32) the image appears crisp.

Is that a known issue? Is it related to how WPF renders icon files?

Philipp Schmid

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philipp,

When you pass an ICO file to an Image control (which we use in the Ribbon's controls), then it will always pull the first frame or icon. So if your ICO has a 32x32 icon and a 16x16 icon, then the latter icon will never be used. In this case, the 32x32 icon will be scaled down to 16x16, or scaled up depending on where/how it's used.

In 2009.2 build 0513, we added the IconFrameSelector markup extension to our Shared Library. You can use it in place of your ICO uri, like so "{shared:IconFrameSelector <existing Uri>, DesiredHeight=16, DesiredWidth=16}". It will then try to find and use an icon of the specfied size, and fall back to the default behavior if one is not found.

If this doesn't appear to be your issue, then please put together a small sample project that reproduces the issue and email it over to our support address.


Actipro Software Support

Posted 9 years ago by Philipp Schmid
Avatar
I have added the following code to my XAML file:

ImageSourceSmall="{shared:IconFrameSelector /Resources/RibbonImages/NewStage.ico, DesiredHeight=16, DesiredWidth=16}"

but I get this error message when I am trying to compile:

Error 1 The tag 'IconFrameSelector' does not exist in XML namespace 'http://schemas.actiprosoftware.com/winfx/xaml/shared'. Line 100 Position 44. C:\...\MainRibbonControl.xaml 100 44 ESStudio

I have confirmed that my reference is to ActiproSoftware.Shared.Wpf30 version 9.2.513.0. (and I cannot find any occurence of IconFrame in this assembly when viewing it in the Object Explorer).

Is my XAML string incorrect? Am I referencing the wrong assembly?

Philipp
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Philipp,

I apologize, the IconFrameSelector has not been released yet. It will be included in our next maintenance release, which should be out by the end of the week.


Actipro Software Support

Posted 9 years ago by Auðunn Baldvinsson - Tolvumidlun
Avatar
Hi,
I have a follow up question to this. Since I am creating my ribbon group items in code how can I use this from code?

for example, if I have a popupmenu I am adding a button to and set imagesource from ico file. Here item.ImagePath is pointing to an ico file stored as a resource in a dll.
for example /ReferencedAssembly;component/Icons/hangar.ico
                    
                Actipro.Button b = new Actipro.Button();
                b.Label = item.Txt;
                if (string.IsNullOrEmpty(item.ImagePath) == false)
                {
                    Uri u = new Uri("pack://application:,,," + item.ImagePath);
                    b.ImageSourceLarge = (new ImageSourceConverter()).ConvertFrom(u) as ImageSource;
                }
                b.Tag = item.Cmd;

                menu.Items.Add(b);


Thank you

[Modified at 04/16/2010 09:46 AM]
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Auðunn,

You should be able to do something like the following:
b.ImageSourceLarge = (new IconFrameSelector(BitmapFrame.Create(u)) { DesiredHeight = 16, DesiredWidth = 16 }).ProvideValue(null) as ImageSource;


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.