Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What would be the fastest method for doing anti-aliasing for a flash game that is drawn via blitting to a BitmapObject?

A method I thought of would be to make games stage smaller than the BitmapObject that the game is drawn to, and then somehow shrink it to the size of the stage.

Would that method work? If so what would be the fastest and highest quality to shrink the bitmap? Or would there be a completely different way to do it?

share|improve this question
up vote 3 down vote accepted

The simple way is to let Flash do the bitmap resampling for you. Rather than composing the scene with blitting, make a movable object an individual Bitmap added to a parent DisplayObject, give the Bitmap fractional x,y coordinates, and set its pixelSnapping to NEVER. (The default for pixelSnapping is AUTO, which means Flash will round to int coordinates when the Bitmap's scale is close enough to 1.0, which I think is for aesthetic reasons as well as performance.)

I don't know how fast this dynamic resampling will be in arbitrary conditions. You should try it for your case and see if it's fast enough. One complication: I think Flash will use the GPU for this when it can, so simple tests may be misleading.

The much-more-work-but-maybe-faster way is to precompute resampled Bitmaps, like for one Bitmap, generate 16 Bitmaps, one for every .25 pixel offset in the x/y directions, and then blit whichever one is closest to the subpixel position.

share|improve this answer
Processor vs. Memory, the perennial struggle. – Ipsquiggle Sep 4 '10 at 16:39
I think I could use 4 different versions for each sprite. One for each half pixel in each direction. So it will use 4 times the data and not 16 times. – AttackingHobo Sep 4 '10 at 20:54
No actually it would be 9 versions of each sprite – AttackingHobo Oct 10 '10 at 17:38

I think that would work, and that you'd need to make your bitmap twice the screen size (or a higher integer multiplier) for the best quality.

However, that means you have to either draw everything scaled (so no copyPixels) or just work with larger source bitmaps (larger file, more memory usage), and you might be losing more performance than blitting is giving you.

share|improve this answer

I believe that you could add a Bitmap to the stage that is twice the size of the stage, set its scalex and scaley to 0.5, and then blit to its BitmapObject. I'm not sure how the performance would work out on it.

I'm a bit confused as to why you need antialiasing at runtime, though. Can't you antialias your bitmap resources beforehand, and just blit them directly, with alpha merge if necessary?

share|improve this answer
I want the movement to be smooth on the sub-pixel level. Blitting can only draw to whole pixels. So if I shrink it, it should give me less choppy movement. – AttackingHobo Sep 3 '10 at 23:55
This is effectively what subsampling does anyways (only less naively). 0.5 will give you 2x AA, 0.25 will give you 4x, etc. – Ipsquiggle Sep 4 '10 at 0:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.