FormEx drawings flickering

ExcludeReality

Active Member
Licensed User
I recently had a problem with drawings on a form "flickering". See this thread: http://www.b4x.com/forum/questions-help-needed/6302-form-drawings-flickering.html.
The solution was to complete the drawings on a hidden form, then move the image to a visible form.
Unfortunately, this isn't working on a FormEx, using the FormExDesktop library.

When drawing on a hidden FormEx, nothing seems to be happening. It's possible to draw on a regular form, then move the image to a FormEx.
To do this, the FormEx needs to be refreshed, which causes even worse flickering.
I also tried drawing on a Bitmap using the ImageLib, but with the same result.
How can I fix this?

I attached a small example. You can't really see the flickering in the example, but in a more graphics-intense program it becomes quite disturbing.

Thanks.
 

Attachments

  • FormEx Drawing.sbp
    1.5 KB · Views: 227
Last edited:

agraham

Expert
Licensed User
Longtime User
If you don't know what a reference is read the "Object References" section in the "Bitmap memory overview" topic in the help for ImageLibEx. That section describes that a Form (not a FormEx) image, when assigned, actually makes a copy. A FormEx for efficiency doesn't, it just assigns the reference so you are drawing on the same bitmap that is being displayed. To stop the flickering you need to be drawing on a different bitmap to the one being displayed. There are several ways to do this but I would draw on a bitmap and not on another FormEx.

a) Use a new bitmap every time.

b) Use two bitmaps alternately, one being drawn and one being displayed. This is more efficient in use of resources that using a new bitmap every time.

c) Keep one bitmap for drawing on and assign another to FormEx.Image. Draw on the first and copy it with DrawerEx.DrawImage to the second when drawing is complete. This is a bit slower than using two bitmaps alternately due to the copying but is easier to manage.

Have you read the help for Show in the "FormExDesktop basics" topic of the help for FormEx? Drawing on a FormEx is significantly different to drawing on a Form.
 

ExcludeReality

Active Member
Licensed User
Thanks for your reply, I guess I should have read the help file first.

I tried to draw on one bitmap, assign the image to another bitmap, and assign that image to the form. It only works partly, because while I did get the desired effect (drawing is finished before displaying), there's a new problem. It seems that between the drawings, gray rows of different shades appear and disappear instantly.
I know that gray is the default color of a new bitmap, but the bitmap is drawn completely white before displaying, so how can I see them?

This is very difficult to explain in text, so I attached another example.
 

Attachments

  • FormEx Drawing 2.sbp
    3.8 KB · Views: 229
Top