Hello,

I'm developing an osciloscope gui with Lazarus, so I need to draw very basic graphics (just lines to being with) to show the wave format.

I have lots of dots that the hardware sends me (500 of them). What component should I put on my form to draw on it's canvas? TImage or TPaintBox? That is the difference between them?

I've being trying without success since monday ... Can someone provide me an very basic example that will just draw 10 lines on an white empty drawing space??

I could not find a very basic graphical example on the examples folder ... maybe I can add one after I get this stuff working...

I thought I could just write to the canvas, and everything would be ok. I put a TImage on my form, added a OnPaint event to it and wrote:

procedure TForm1.TelaPaint(Sender: TObject);
var
  Bitmap: TBitmap;
  x, y: Integer;
begin
  Bitmap := TBitmap.Create;
  try
    Bitmap.PixelFormat := pf24bit;

    Bitmap.Canvas.Pen.Color := clBlack;
    Bitmap.Canvas.MoveTo(0, 0);
    for x := 0 to 499 do
    begin
      y := Medidas[x];
      Bitmap.Canvas.LineTo(2 * x,y);
    end;

    Tela.Canvas.Draw(0, 0, Bitmap);
  finally
    Bitmap.Free;
  end;
end;

First of all you didn't specify the size of your bitmap. I can't remember the default size but it is very small. So most of your drawing is out of bounds.

Secondly, you must paint the background of your bitmap.

Thirdly, don't use the OnPaint event to draw to a TImage. A TImage is buffered so all you need to do is draw to it from anywhere and the change is there forever. However, if you are constantly redrawing (which will be your case with an osciloscope) then the image will flicker. In this case use the OnPaint event and draw directly to the form's canvas (at least you can do this under Delphi, not sure if in FP). If Lazarus doesn't give you access to the form's canvas, you can try deriving it with the canvas proprety in public and then drawing.

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to