K
kpg
Hi all,
New to CF 3.5 development, trying my hand at it.
I have a simple user control (VB), a gauge control, that displays a bitmap
background and I'm drawing a moving needle on top of it.
Works fine except for a flicker when the control is re-drawn.
I am using a bouble-buffering technique in the paint event as follows:
doubleBuffer = New Bitmap(Width, Height)
Dim g As Graphics = Graphics.FromImage(doubleBuffer)
g.DrawImage(backGroundImage, 0, 0)
g.DrawLine(New Pen(mycolor, 2), X1, Y1, X2, Y2)
g.Dispose()
e.Graphics.DrawImage(doubleBuffer, 0, 0)
The control is updated between 4 to 10 time/second, and this causes a
flicker. I'm sure without double buffering it would be much worse, but it
is still unacceptable.
During the e.graphics DrawImage it seems to first clear the old image then
re-paint the new image, which causes a noticeable flicker. This seems to
defeat the whole purpose of double buffering.
I'm not very familiar with .NET graphics, and while I do understand that
the CF has a much limited capability, there must be a way to achieve
flicker free animation at these frame rates.
Thanks,
kpg
PS
I have yet to try this, but I was considering putting a background on the
form instead of the user control, then have a transparent color in the
control background bitmap (using setcolor), which then would have only the
needle drawn on it. I'm assuming here that the transparent color is simply
not rendered, but I'm uncertain if the needle I then draw would remain on
each frame cycle, requiring a refresh of the underlying image. I am
thinking that any "image persistence" capability is not present in CF?
PPS
....oh, BTW - I have a functional CF DrawArc routine. It was created out of
necessity (I could not find source code for this anywhere) and with some
help from a blog by Dan VanderBoom. It's not real pretty but it does work
well and its small and fast enough. I'm using if for arcs based on
circles, but I think it should work for any ellipses as well. If anyone is
interested I'll post it to a new thread.
New to CF 3.5 development, trying my hand at it.
I have a simple user control (VB), a gauge control, that displays a bitmap
background and I'm drawing a moving needle on top of it.
Works fine except for a flicker when the control is re-drawn.
I am using a bouble-buffering technique in the paint event as follows:
doubleBuffer = New Bitmap(Width, Height)
Dim g As Graphics = Graphics.FromImage(doubleBuffer)
g.DrawImage(backGroundImage, 0, 0)
g.DrawLine(New Pen(mycolor, 2), X1, Y1, X2, Y2)
g.Dispose()
e.Graphics.DrawImage(doubleBuffer, 0, 0)
The control is updated between 4 to 10 time/second, and this causes a
flicker. I'm sure without double buffering it would be much worse, but it
is still unacceptable.
During the e.graphics DrawImage it seems to first clear the old image then
re-paint the new image, which causes a noticeable flicker. This seems to
defeat the whole purpose of double buffering.
I'm not very familiar with .NET graphics, and while I do understand that
the CF has a much limited capability, there must be a way to achieve
flicker free animation at these frame rates.
Thanks,
kpg
PS
I have yet to try this, but I was considering putting a background on the
form instead of the user control, then have a transparent color in the
control background bitmap (using setcolor), which then would have only the
needle drawn on it. I'm assuming here that the transparent color is simply
not rendered, but I'm uncertain if the needle I then draw would remain on
each frame cycle, requiring a refresh of the underlying image. I am
thinking that any "image persistence" capability is not present in CF?
PPS
....oh, BTW - I have a functional CF DrawArc routine. It was created out of
necessity (I could not find source code for this anywhere) and with some
help from a blog by Dan VanderBoom. It's not real pretty but it does work
well and its small and fast enough. I'm using if for arcs based on
circles, but I think it should work for any ellipses as well. If anyone is
interested I'll post it to a new thread.