Bad scaling with al_set_display_icon()
Bruce Pascoe

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.


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.

Bruce Pascoe

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. :)


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.

Bruce Pascoe

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

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).


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.

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

Thread #615517. Printed from