Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Smoother rotated bitmaps?

Credits go to Dario ff, Elias, Johan Halmén, and Mark Oates for helping out!
This thread is locked; no one can reply to it. rss feed Print
Smoother rotated bitmaps?
TrieBr
Member #12,157
July 2010

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
Member #1,550
September 2001

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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Dario ff
Member #10,065
August 2008
avatar

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.
min_filter=linear
mag_filter=linear

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

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Elias
Member #358
May 2000

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.

--
"Either help out or stop whining" - Evert

Mark Oates
Member #1,146
March 2001
avatar

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.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Dario ff
Member #10,065
August 2008
avatar

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

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

TrieBr
Member #12,157
July 2010

ALLEGRO_MIN_LINEAR worked great! It looks beautiful now :D

Thanks!

Go to: