real time image rotation

BlitzPlus Forums/BlitzPlus Programming/real time image rotation

bloos_magoos(Posted 2013) [#1]
I know that everybody can do it. Everybody except for me :(

I want to be able to take any image and rotate it in real time, like for example to face the direction the player is walking (think SAS Zombie Assault).

Im pretty sure that the way most people do it is to create an image, and render a rotated image on each frame. So there would be 360 frames, each rotated one degree.

However, I have no idea how to do that. Plus isn't RotateImage() very slow? I do not know.

Thanks


xlsior(Posted 2013) [#2]
In general, blitzplus is ill-suited for this:

In a mode modern language like BitzMax which does 2D-in-3D it's completely off-loaded to the GPU: there is zero overhead to draw an image at whatever rotation angle verses drawing it straight. Just specify the degrees of rotation, draw, and done. alphablending for anti-aliased edges, etc. as well.

In blitzplus, there's no such way: it's the CPU that pushes each and every pixel to the video memory. Any rotations will have to be calculated and drawn by the processor, which takes a significant am ount of time,
Also, since Blitzplus doesn't do alpha-blending/ transparancies out of the box,the edges of the rotated images tend to look pretty bad and jaggy unless you yourself calculated antialias info. Again, significant overhead.

The most realistic method to use in blitzplus is to pre-calculated the rotated images: Either you can create the rotations in your paint program and save the different versions all to disk, OR you can have blitzplus do it itself -- either ahead of time in a custom program that you create to take an image, use the slow rotateimage() to draw it to the screen, do a grabimage to read it back, and do a saveimage to store it to disk so it's ready to be used next time.

also, depending on what you're trying to accomplish, and the size of your images, you may not need 360 versions or everything (which would require a signficant amount of memory to hold)
See what it looks like first with 8 rotations, or 16 rotations, or 32 rotations, or...

but in the end there is no way around it: real-time rotations are simply not a strongpoint of a 2D-in-2D language like Blitzplus, but they couldn't be easier in a 2D-in-3D language like BlitzMax.