Rotating Bitmap


Well-Known Member
Licensed User
I want to draw an rotating arrow on an imageview, like one of the first versions of GPS4ppc. My idea was to rotate the arrow as bitmap with drawBitmapRotated. The first problem is, that when i draw it on the activity, the arrow is under the imageview. When I draw it on the imageview, I get an error, that the bitmap is not mutable???? And last but not least, is it possible to get the borders of the rotating bitmap transparent? I don't know, if DrawBitmapRotated is the suitable for an rotating arrow.

Thanks for answer..............


Staff member
Licensed User
You can draw on an ImageView:
    ImageView1.Bitmap = LoadBitmap(File.DirAssets, "smiley.gif")
    Activity.AddView(ImageView1, 25%x, 25%y, 50%x, 50%y)
    Dim c As Canvas
    c.DrawCircle(50dip, 50dip, 20dip, Colors.Red, True, 0)

You can have two image views. One with the background and the other with the rotating arrow. Or you can redraw the background yourself like is done in the bouncing smiley example:
Upvote 0


Licensed User
Attached you find an example of a rotating needle or a rotating compass.
The compass and needle are drawn directly onto the Activity.
The surrounding pixels of the needle have bin set transparent in the png file.

I have not yet tested Erel's proposal with an ImageView view. I had also some trouble trying to draw onto an ImageView.

Best regards.


    23.4 KB · Views: 982
  • DrawNeedle.jpg
    22.3 KB · Views: 938
Upvote 0


Licensed User
I think that your code example is given for B4A version 1.

I tried it, but get in line:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]ImageView1.Bitmap = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]LoadBitmap[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]File[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].DirAssets, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Compass.bmp"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT][/SIZE][/FONT]
the error:
Compiling code. Error
Error compiling program.
Error description: Unknown member: bitmap
Occurred on line: 37
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "Compass.bmp")
Word: bitmap

Best regards.
Upvote 0