Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

Canvas.CopyRect query...

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I'm using the following code to copy a portion of one TImage to a second TImage

procedure TForm1.Button2Click(Sender: TObject);
var
  i, x, xx, yy, ww, hh, pos : integer;
  s : string;
begin
  x := 0;
  for i := 1 to Length ( Edit1.Text ) do
  begin
    pos := Ord(  Edit1.Text[ i ] );
    s := Edit1.Text[ i ];
    xx := s_x[ pos ];
    yy := s_y[ pos ];
    ww := s_w[ pos ];
    hh := s_h[ pos ];
    Image2.Canvas.CopyRect( Classes.Rect( x, 0, ww, hh ) , Image1.Canvas,
Classes.Rect( xx, yy, ww, hh ) );
    x := x + xx;
  end;
end;

But the result in Image2 looks stretched. Am I using CopyRect correctly? I'm using this under Mac OS X ( 10.4.11 ), if that makes any difference.

Reply by email

Unknown author
to Unknown author

Oops I cut and pasted a typo.

x:= x + xx should be x := x + ww;

But that still does not fix the problem.

Show quoted text 30 lines
I'm using the following code to copy a portion of one TImage to a second TImage procedure TForm1.Button2Click(Sender: TObject); var i, x, xx, yy, ww, hh, pos : integer; s : string; begin x := 0; for i := 1 to Length ( Edit1.Text ) do begin pos := Ord( Edit1.Text[ i ] ); s := Edit1.Text[ i ]; xx := s_x[ pos ]; yy := s_y[ pos ]; ww := s_w[ pos ]; hh := s_h[ pos ]; Image2.Canvas.CopyRect( Classes.Rect( x, 0, ww, hh ) , Image1.Canvas, Classes.Rect( xx, yy, ww, hh ) ); x := x + xx; end; end; But the result in Image2 looks stretched. Am I using CopyRect correctly? I'm using this under Mac OS X ( 10.4.11 ), if that makes any difference. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to Unknown author
Show quoted text 34 lines
Oops I cut and pasted a typo. x:= x + xx should be x := x + ww; But that still does not fix the problem. On Mon, 27 Oct 2008 20:36:55 -0400, wrote: > I'm using the following code to copy a portion of one TImage to a > second TImage > > procedure TForm1.Button2Click(Sender: TObject); > var > i, x, xx, yy, ww, hh, pos : integer; > s : string; > begin > x := 0; > for i := 1 to Length ( Edit1.Text ) do > begin > pos := Ord( Edit1.Text[ i ] ); > s := Edit1.Text[ i ]; > xx := s_x[ pos ]; > yy := s_y[ pos ]; > ww := s_w[ pos ]; > hh := s_h[ pos ]; > Image2.Canvas.CopyRect( Classes.Rect( x, 0, ww, hh ) , > Image1.Canvas, Classes.Rect( xx, yy, ww, hh ) ); > x := x + xx; > end; > end; > > But the result in Image2 looks stretched. Am I using CopyRect > correctly? I'm using this under Mac OS X ( 10.4.11 ), if that makes > any difference.

Replace Classes.Rect with Classes.Bounds

Mattias

Reply by email