Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
Re: Einen Bilderausschnitt aus TImage
3. Mär 2005, 04:35
Delphi-Quellcode:
type
TForm1 = class(TForm)
Image2: TImage;
Button1: TButton;
Image1: TImage;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
StartPoint: TPoint;
EndPoint: TPoint;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
StartPoint.X := X;
StartPoint.Y := Y;
Image1.Canvas.Ellipse(X, Y, X + 5, Y + 5);
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
EndPoint.X := X;
EndPoint.Y := Y;
Image1.Canvas.Ellipse(X, Y, X + 5, Y + 5);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SrcRect, DestRect: TRect;
begin
Image2.Picture := nil;
SrcRect.Left := StartPoint.X;
SrcRect.Top := StartPoint.Y;
SrcRect.Right := EndPoint.X;
SrcRect.Bottom := EndPoint.Y;
DestRect := Rect(0, 0, EndPoint.X - StartPoint.X, EndPoint.Y -
StartPoint.Y);
Image2.Canvas.CopyRect(DestRect, Image1.Canvas, SrcRect);
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|
|
Zitat
|