Android Question How to draw on a Bitmap?

Inman

Well-Known Member
Licensed User
Longtime User
I have a Bitmap object loaded with an image file from the cache folder. I don't have any imageview yet, just the Bitmap object. I want to draw a shape (like line or rectange) on this bitmap. I tried the Canvas object but it seem to draw only on Views and on mutable bitmaps, but not on bitmaps loaded from the directory.

How can I draw on this bitmap directly?
 

Informatix

Expert
Licensed User
Longtime User
I have a Bitmap object loaded with an image file from the cache folder. I don't have any imageview yet, just the Bitmap object. I want to draw a shape (like line or rectange) on this bitmap. I tried the Canvas object but it seem to draw only on Views and on mutable bitmaps, but not on bitmaps loaded from the directory.

How can I draw on this bitmap directly?

You can use the Accelerated Surface library to transform this bitmap in a mutable one (AS_ImageUtils class, MakeMutable function).
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Thanks Erel. That worked.

Edit:

Sounds great Informatix. That is one library of yours I never tried out as I am not into game programming. Sounds like I should give it a try.
 
Upvote 0
Top