Hello! I draw on an imageview, but it is not possible to clear the image bevor I draw again on it. I thought, that imageview1.Invalidate clears the bitmap???
ImageView.Invalidate refreshes the view.
Assuming you are drawing a compass needle on a compass rose, please try and load the compass rose image before drawing the needle rotated with transparent background. Similar to this:
B4X:
Sub Orientation_OrientationChanged (Azimuth As Float, Pitch As Float, Roll As Float)
Canvas1.DrawBitmap(bitmapRose,Null,DRect)
Canvas1.DrawBitmapRotated(bitmapNeedle,Null,DRect,Azimuth+MDecl)
ImageView1.Invalidate
End Sub
If there is no compass rose image, then try and fill the entire canvas area with an adequate color (Canvas1.DrawColor()) before drawing the needle.
Attached you find an example of drawing a needle on an ImageView.
With two modes:
- turning needle
- turning compass rose
The difference is that there are two ImageViews:
- one for the compass rose
- one for the needle
The NeedleImageView is transparent.
And, in the turning needle mode, to erase the previous needle position I draw a transparent rectangle, needle image size, onto the NeedleImageView.
The compass rose is drawn only one time.
In the turning compass rose mode, the compass rose is redrawn every tick
and the needle is drawn only one time.