What you're trying to do is a common operation for graphics/games.  If 
you're doing a game, I would suggest just doing this in openGL -  you would 
create a texture altas out of 1 large bitmap (say 1024x1024), with your 
individual textures (or frames of a sprite) all packed in.  Then you can 
map from a part of that bitmap to a part of the surface you're drawing to, 
by specifying vertices.  You could then, instead of rotating the entire 
surface, just translate and rotate the destination vertices.

Some resources that help with this will be libgdx (open source graphics 
engine for Android) created by the author of Beginning Android Games, a 
book which was very helpful in explaining these things to me when I wanted 
to do something similar.


On Friday, April 6, 2012 9:07:53 PM UTC-4, elix wrote:
>
> Hi
>
> I was trying to find an appropriate way to draw a portion of a bitmap 
> rotated onto the canvas. 
>
> Rotating canvas does not seem appropriate for my situation; I am working 
> on a game, there will be up to 30 soldiers on the screen. Rotating the 
> whole canvas seperately for each of them does not seem nice.
> I can't apply rotation to a matrix and use it in canvas.drawBitmap(source, 
> matrix, paint) method. It works for the whole bitmap. I need to draw only a 
> portion of bitmap at each frame. I am using sprite animation.
>
> Somethings could be done using Bitmap.createBitmap(...) method but making 
> bitmap creations continuously at each frame isn't nice. While writing these 
> something came to my mind :), may be I could divide the frames into 
> different bitmap objects at initialization phase using this createBitmap 
> method, then apply rotation to these bitmaps using matrix.
>
> Anyway, I will try this but I would be glad to hear better approaches.
>
>
> -- 
>
> Emre
>  

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to