[Lazarus] TImage Question
Terry A. Haimann
terry at haimann.us
Tue Jul 5 01:15:01 CEST 2016
Thank You, I'll give that a try.
On Mon, 2016-07-04 at 15:51 -0700, leledumbo wrote:
> > Is is possible to select (with the mouse) a portion of an image on
> timage and copy it to the clipboard?
>
> Sure, just make a good use of OnMouseDown, OnMouseUp and TImage properties
> and (sub)methods:
>
> uses
> ClipBrd;
>
> {$R *.lfm}
>
> var
> StartX,StartY,EndX,EndY: Integer;
>
> { TForm1 }
>
> procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
> Shift: TShiftState; X, Y: Integer);
> begin
> StartX := X;
> StartY := Y;
> end;
>
> procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
> Shift: TShiftState; X, Y: Integer);
> var
> bmp: TBitmap;
> w,h: LongInt;
> begin
> EndX := X;
> EndY := Y;
>
> bmp := TBitmap.Create;
> with bmp do
> try
> w := Abs(EndX - StartX);
> h := Abs(EndY - StartY);
> bmp.SetSize(w,h);
> bmp.Canvas.CopyRect(
> Rect(0,0,w,h),
> Image1.Canvas,
> Rect(StartX,StartY,EndX,EndY)
> );
> Clipboard.Assign(bmp);
> finally
> bmp.Free;
> end;
> end;
>
>
>
> --
> View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-TImage-Question-tp4048879p4048881.html
> Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.
More information about the Lazarus
mailing list