You need to rotate all of your images ahead of time and store them in an array. Then you just index the array with the angle you want it to be at.
I made some code for a similar topic, here:
http://www.blitzbasic.com/Community/posts.php?topic=82064#925355
I made some code for a similar topic, here:
http://www.blitzbasic.com/Community/posts.php?topic=82064#925355