Smoother rotated bitmaps?

I'm using al_draw_rotated_bitmap() to draw a rotated bitmap, but it seems to get all pixely when I draw it rotated. Any ideas on how I can smoothen it up? Any flags I can use in allegro? I tried the multisampling, but it didn't seem to effect it.

Any suggestions or thoughts would be appreciated!

Johan Halmén

It's probably a nearest-pixel method. A smoother image you get, if you pick the 4 nearest pixels and weigh them somehow.

It goes somehow like this. Create an empty bitmap that will be the rotated bitmap. Figure out its size. In the rotated bitmap, pixel by pixel, find out the origin in the original bitmap. The origin of the pixels will be float coordinates. And you will find four nearest pixels of each float coordinate. F.i. starting with the coordinate (2.2, 2.3) you have to determin each channel of R, G and B according to the distance to the nearest integer x values and y values. I can return to that if you can't figure it out yourself.

Of course it need a lot of optimizing, remembering not to calculate the same sin and cos values for each pixel.

Dario ff

Try setting these in allegro5.cfg(which should be on the folder where your executable is):

# Can be 'point', 'linear', 'anisotropic'.
# Just a hint, driver doesn't have to obey.

I'm not sure if this helps only with scaling, but I think it solved my jaggies with rotated sprites IIRC.


Those config settings were only used in some 4.9.x versions. You can adjust the filtering with al_set_new_bitmap_flags. Also look at the ex_filter example.

Mark Oates

use al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); before loading your bitmaps. (not before each one, unless you want some with filtering and some without.)

Dario ff said:

Try setting these in allegro5.cfg

No longer in v5.0.0. But already, I've seen the advantage of moving from the cfg to the bitmap flag, as I can now load images (without filtering) from an old 8-bit style game, scale them by 3x onto a new bitmap (on a destination with filtering), then use that destination as the source. The end effect is I can preserve the pixel-look while still getting the delicious filtering on rotations.

Dario ff

Funny, I was planning one day on suggesting on turning the linear filtering into a settable flag, and it seems I've missed when it was implemented. :P


ALLEGRO_MIN_LINEAR worked great! It looks beautiful now :D


Thread #606394. Printed from