问题
I have a bitmap loaded in flash, for a 2D game. The bitmap represents a character and is rotating when the user uses the A (left) or D (right) keys. The problem I have is that the border of the image becomes ugly while rotating, you can see "pixels" (you can always see pixels, but I hope you understand what I mean).
How can I fix this in actionscript 3, maybe change the rotation algorithm or "fix" the image after rotation? Or should I save/render the image differently in eg. Photoshop before using it with Flash?
Update: note that the background of the game is constantly changing.
Thanks in advance.
回答1:
use the flash.display.Bitmap::smoothing property ... the langref specifies, it smooth's when scaling, but it works for rotation as well ...
greetz
back2dos
回答2:
If the image is an external load (Loader class), then you can write:
Bitmap(myLoader.content).smoothing=true;
If it's internal (its in the library) you need to right click the library bitmap > properties and enable "Smoothing". Plus, if you are instantiating it as a BitmapData, then you need to do this:
var bmp:BitmapData=new LibraryBitmap(0,0);
var bitmap:Bitmap=new Bitmap(bmp,"auto",true); //the third argument is smoothing
Cheers...
回答3:
You could try a simple antialias along the edges by summing the pixel that is there and the pixel you will be overlaying. You could take a look at Wu antialiasing for an example you could use as a start point.
回答4:
A quick note: Bitmap rotation is slow, so while loading the game, it might be a good idea to take characters that are often rotating, or are common, rotate them to every 1 degree that is possible in the game, use BitmapData.draw, and push it onto an Array (or a Vector in FP10, if possible), and then use those Bitmaps.
YAY, run-on sentences!
Happy Coding! :-)
来源:https://stackoverflow.com/questions/1058187/rotation-in-flash-causing-image-borders-to-look-pixely-how-to-fix