Delphi 026 TrackBar / 06 Zoom picture with trackbar

preview_player
Показать описание
AR : كيفية تكبير الصورة بتراكبار
FR : Comment zoomer une photo avec trackbar
EN : How to zoom a photo with trackbar
ES : Cómo ampliar una foto con la barra de seguimiento
AL : So zoomen Sie ein Foto mit der Spurleiste
RS : Как увеличить фотографию с помощью трек-бара

Rad Studio Delphi TrackBar Image Label

Code Source :

procedure TForm1.FormCreate(Sender: TObject);
begin
bmpmain := TBitmap.Create;

TrackBar1.Min := 10;
TrackBar1.Max := 200;
TrackBar1.Frequency := 10;
TrackBar1.PageSize := 10;
TrackBar1.Position := 100;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
var
Zoom, x, y: Integer;
begin
Zoom := TrackBar1.Position;
if not (Visible or (Zoom = 100)) or (Zoom = 0) then
Exit;

SetMapMode(imgmain.Canvas.Handle, MM_ISOTROPIC);
SetWindowExtEx(imgmain.Canvas.Handle, 100, 100, nil);
SetViewportExtEx(imgmain.Canvas.Handle, Zoom, Zoom, nil);
x := imgmain.Width * 50 div Zoom - bmpmain.Width div 2;
y := imgmain.Height * 50 div Zoom - bmpmain.Height div 2;
imgmain.Canvas.Draw(x, y, bmpmain);
if (x ..... 0) or (y ..... 0) then begin
imgmain.Canvas.Brush.Color := clWhite;
ExcludeClipRect(imgmain.Canvas.Handle, x, y, x + bmpmain.Width, y + bmpmain.Height);
imgmain.Canvas.FillRect(imgmain.Canvas.ClipRect);
end;

Label1.Caption := 'Zoom: ' + IntToStr(TrackBar1.Position) + '%';
end;
Рекомендации по теме
Комментарии
Автор

Bro, your tutorials are very helpful for us I like very much....by the way I have a question if I have scrollbox, inside scrollbox I have image, how do I zoom in and out with mousewheel(fmx).

bikaymeisnam