Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Bad scaling with al_set_display_icon()

This thread is locked; no one can reply to it. rss feed Print
Bad scaling with al_set_display_icon()
Bruce Pascoe
Member #15,931
April 2015
avatar

I've recently found that, using al_set_display_icon(), passing a bitmap larger than 32x32 ends with a crummy-looking taskbar icon. From a cursory look at the Allegro source, it seems like it uses memory bitmaps to scale the image to the proper size.

I'm wondering if there's a way I can work around this, as I know there are platforms using icons larger than 32x32 and I still want it to look decent.

SiegeLord
Member #7,827
October 2006
avatar

I was under the impression that that is what al_set_display_icons was for, you'd pass it a whole bunch of icons of different sizes and it'd somehow pick one that looks best.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Bruce Pascoe
Member #15,931
April 2015
avatar

I was hoping I wouldn't have to do that. Currently I have it load a single image file, icon.png, from the game directory to apply to the window, with this I would have to have multiple files (or maybe some sort of icon atlas) and load them all.

That said, I partially worked around it by doing this:
al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
Before loading the icon (as a video bitmap), scaling it down, and then passing that to Allegro. The results aren't optimal, but it does look 100% better than letting Allegro do the scaling in software.

As I'm making a general-purpose game engine, my requirements are a bit different than if I were just making a standalone game--I want to keep things as simple as possible. :)

SiegeLord
Member #7,827
October 2006
avatar

Well, you could create the different sizes programmatically (I guess that's what you're essentially doing) and pass them to that function. Start with a 512x512 icon and then scale it down a few times with whatever high quality method you chose and then pass them to Allegro.

It's an interesting question of whether al_set_display_icon should have configurable icon scaling quality.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Bruce Pascoe
Member #15,931
April 2015
avatar

In case you're curious, this question came about due to my recent discovery that Windows 10 is going to support 768x768 icons, so I was getting ready by scaling up my icons to that size. 8-) Allegro didn't much appreciate me passing that huge image to al_set_display_icon though, it looked like crap. :P

Thomas Fjellstrom
Member #476
June 2000
avatar

Icons tend to look like crap if you scale them too much. To look best, you want to have a few sizes, that then get scaled up or down to the nearest platform supported size (android apps do this a lot, it saves on a bunch of copies of icons, but provides the decent looking results at most display sizes and pixel densities).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

beoran
Member #12,636
March 2011

I think it would be nice if we had an API which can help discover just which sizes ans usages of icons are supported. Maybe something like this:

typedef struct ALLEGRO_ICON_INFO {
   int width;          // Icon width
   int height;         // Icon height
   int usage;          // Flag that describes what the icon is used for, etc.
} ALLEGRO_ICON_INFO;

int al_get_num_icons(ALLEGRO_DISPLAY * disp);
ALLEGRO_ICON_INFO * al_get_icon_info(ALLEGRO_DISPLAY * disp, int index);

Go to: