this slowpoke moves

Cut Zone from Image

uses ExtCtrls, jpeg

var
  PDown             : TPoint;
  PActually         : TPoint;
  MouseIsDown       : Boolean;
  
//


procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    PDown := Point(x, y);
  PActually := Point(x, y);
  MouseIsDown := TRUE;
  Image1.Canvas.DrawFocusRect(Rect(x, y, x, y));

end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if MouseIsDown then
  begin
    Image1.Canvas.DrawFocusRect(Rect(PDown.x, PDown.y, PActually.x,PActually.y));
    PActually := Point(x, y);
    Image1.Canvas.DrawFocusRect(Rect(PDown.x, PDown.y, x, y));
  end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   Image1.Canvas.DrawFocusRect(Rect(PDown.x, PDown.y, PActually.x, PActually.y));
  Image1.Canvas.DrawFocusRect(Rect(PDown.x, PDown.y, x, y));
  PActually := Point(x, y);
  MouseIsDown := FALSE;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
var
  TmpBmp : TBitmap;
begin
  Image1.Canvas.DrawFocusRect(Rect(PDown.x, PDown.y, PActually.x, PActually.y));
  TmpBmp := TBitmap.Create;
  with TmpBmp do
  try
    Width := Round(abs(PActually.x - PDown.x));
    Height := Round(abs(PActually.y - PDown.y));
    BitBlt(Canvas.Handle, 0, 0, Width, Height, Image1.Canvas.Handle, PDown.x,
      PDown.y, SRCCOPY);
    Image1.AutoSize := TRUE;
    Image1.Picture.Bitmap.Assign(TmpBmp);
  finally
    Free;
  end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate