RibbonButton.LargeImage Icon Resolution Issues

RibbonButton.LargeImage Icon Resolution Issues

paul.t.macknight
Advocate Advocate
5,888 Views
4 Replies
Message 1 of 5

RibbonButton.LargeImage Icon Resolution Issues

paul.t.macknight
Advocate
Advocate

The attached image shows a handful of test icons I made for some of the tools I plan on developing. My question is why the images get cropped. Despite the images being the same size, they either get placed and scaled properly (as I have read Revit will do for the LargeImage property) but lose clarity, or they retain their original size and become cropped, as shown by the two variations. I attempted to make these icons (currently formatted as .png) with transparency. Are there any tips or tricks that I'm missing that would allow me to use these images at the same resolution/quality as standard Revit Ribbon icons? Does Revit place nice with transparency or do I need to let that go?

 

EDIT: I forgot to mention that I have primarily attempted 32x32 images, as I have read this is the preferred resolution for the LargeImage property, but I have used larger images in an attempt to improve the clarity of icon in Ribbon. All resolutions I've attempted to use have had the above-stated issues.


As a side note, I would also prefer these to be embedded resources (again, .png format, not .bmp), as opposed to resources, and have not yet been able to get a Uri("...") string that will read the image file once I set the Build Action of the image to Embedded Resource. I've gone through every possible solution found here, to no avail: https://forums.autodesk.com/t5/revit-api-forum/ribbon-panel-button-image-from-embedded-resource/m-p/...

 

NOTE: This project is in VB.net, not C#. I translated the above solutions but could have missed something that I was unaware of on a fundamental level.

0 Likes
Accepted solutions (2)
5,889 Views
4 Replies
Replies (4)
Message 2 of 5

paul.t.macknight
Advocate
Advocate
Accepted solution

I have solved the issue with the embedded resources. I utilized the solution found here, but with a key distinction that I found captured in only one post (I do not have the link to provide for it, my apologies). Turns out in VB.net you don't need to include the project folder within the namespace path (i.e. a png file place under a project folder named "Assets", if set to Embedded Resource, should be called by "namespace.imagename.ext" rather than "namespace.Assets.imagename.ext"). This is not the case in C# (folder must be included), and Neither I (until now) nor online translators were aware of this distinction. Since all solutions I could find were written in C# or were translations from C#, simply copying a solution from a "working" solution did not work. It'd be nice to see working solution in both C# and VB.net posted side-by-side unless in response to a question (like mine) asking specifically for one language.

This is not the solution to the main issue from the question above, however, so I will withhold selecting this as an answer until an answer for the primary question is posted.

0 Likes
Message 3 of 5

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Paul,

 

Thank you for your query.

 

Two answers:

 

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 5

paul.t.macknight
Advocate
Advocate

Thanks, that's exactly what I needed!

I tried to do something similar for resizing, but not being as familiar working with images I wasn't sure where to start or what questions to ask to get me to a solution like yours.

Rather than using the line 

BitmapImage bmi = new BitmapImage( new Uri( "icons/cmdx.png", UriKind.Relative ) );

to retrieve the embedded image, I plugged in the solution I mentioned above, which then feeds into the rest of the solution you posted in the second link.

 

0 Likes
Message 5 of 5

chuebner03
Contributor
Contributor

I had similar issues with icon resolution after creating them in Photoshop at 32x32. The solution was to use ICOConvertor.com on the 32x32 pngs i created, selecting 32 pixels and 32 bits, and then saving the resulting .ICO file that was created as a PNG file. Then the resolution issues were fixed and the icons look great. Hope this helps others!

0 Likes