Clear an imageview

schimanski

Well-Known Member
Licensed User
Longtime User
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???

B4X:
  imageview1.Bitmap=Pfeil
  PfeilCanvas.Initialize(imageview)
  DRectPfeil.Initialize(0,0,100,100)
  Pfeilrotation(45)

B4X:
Sub Pfeilrotation(Kursrichtung)
  PfeilCanvas.DrawBitmapRotated(Pfeil,Null,DRectPfeil,Kursrichtung)
  imageview1.Invalidate 
End Sub
 

alfcen

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
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.

Best regards.
 

Attachments

  • DrawNeedleImageView1.zip
    25.3 KB · Views: 633
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
@Schimanski.
I guess it's a function to create a marker for the application "Openstreetmap Tilemapviewer? :)

@Klaus.
Thank you for all your responses to various messages. :cool:

JP
 
Upvote 0
Top