I'm doing a component that is like an "electocardiogram", painting at
canvas.
My problem is i must refresh the "health line" every 100 milliseconds, and
the repainting is slowly, and the canvas is fliking. (because i put te
canvas white, i draw the grid lines and repaint the "health line" with a new
value)
The problem growns when the canvas growns.
Any suggestion ?
thanks,
Joseph Maria Gomez
"Josep Maria Gómez Boada" wrote:
> the repainting is slowly, and the canvas is fliking.
Hi.
If your control is TCustomControl (TWinControl) descendant, you should set its
DoubleBuffer property to True to eliminate flicker.
If your control descends from TGraphicControl then you have to write a
double-buffering mechanism by yourself. In the overriden Paint method create a
bitmap and set its dimensions according to your control dimensions
(GetClientRect). Then redirect all drawing operations into TBitmap.Canvas, and
when you're done, copy the bitmap's canvas content into your control's canvas (I
am using Win API BitBlt function directly in these cases or you can use some
methods contained in TCanvas class).
Hope this helps. Ivo.
Is a TCustomControl and I set doublebuffered to True and seems to do the
same...
The problem is every time i need repaint the "Health line", i must repaint
the background, repaint the grid and
repaint the "health line" with a new value added to simulate the "paper"
movement.
thanks again,
Josep Maria Gomez Boada
Ivo Bauer <Ivo....@upce.cz> escribió en el mensaje de noticias
3A9261F6...@upce.cz...
>
>
> "Josep Maria Gómez Boada" wrote:
>
> > the repainting is slowly, and the canvas is fliking.
>
> Hi.
>
> If your control is TCustomControl (TWinControl) descendant, you should set
its
> DoubleBuffer property to True to eliminate flicker.
>
> If your control descends from TGraphicControl then you have to write a
> double-buffering mechanism by yourself. In the overriden Paint method
create a
> Hope this helps. Ivo.
>
>
HTH,
Bill
What kind of canvas are you using? An images canvas, a paintbox, something
else? The solution to the flicker problem is to paint the complete image to a
background bitmap first and then copy that to the foreground canvas in one
operation. I also suggest to use the PolyLine canvas function to draw your
curve, it is much faster than drawing each line segment with lineto/moveto, or
(Horror!) to set pixels one by one.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.
--
Uwe W. Radu
--
Robert
Josep Maria Gómez Boada wrote in message <3a9244f4_1@dnews>...
"Josep Maria Gómez Boada" wrote:
> Is a TCustomControl and I set doublebuffered to True and seems to do the
> same...
If your control is TCustomControl descendant, setting its DoubleBuffer property
to true should have the same effects as I described in my first comment, thus
eliminating flicker. If you want to improve drawing performance (since you need
to redraw the control in a very short periods of time), you can:
1) start thinking about usign pre-rendered paper background with grid (see
comment from Uwe in this queue) and when painting control image (in Paint
method) only copy corresponding block from background paper bitmap to control
canvas instead of direct rendering each time it is needed.
2) When you don't need to redraw entire control during periodical updates,
bypass the Paint method and draw only a portion of the control that needs to
update directly into canvas.
Good luck, Ivo.
Peter Below (TeamB) <10011...@compuXXserve.com> escribió en el mensaje de
noticias VA.000069d...@antispam.compuserve.com...
> In article <3a9244f4_1@dnews>, Josep Maria Gómez Boada wrote:
> > I'm doing a component that is like an "electocardiogram", painting at
> > canvas.
>
> What kind of canvas are you using? An images canvas, a paintbox, something
Is the CustomControl's canvas property.
> else? The solution to the flicker problem is to paint the complete image
to a
> background bitmap first and then copy that to the foreground canvas in one
I'll tryit.
> operation. I also suggest to use the PolyLine canvas function to draw your
> curve, it is much faster than drawing each line segment with
lineto/moveto, or
I was tryit but the result was the same.
thanks
> Have you looked for ready-made components? I think you will find something
Yes but i can't find nothing similar i need and i prefer to do my self
component.
> problem. Also, there are commercial components at www.swiftsoft.de which
may
> provide the function you seek, and those use all sorts of tricks to manage
> performance.
>
> HTH,
thanks at all.
Josep Maria