Per zoomare un'immagine uso questo codice:
codice:
procedure TFormFoglioRettangolo.ImgFoglioRettangoloMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer);
var
zoom:double;
begin
ImgProva.AutoSize := False;
ImgProva.ScaleMode := smStretch;
case Button of
mbLeft:
begin
if (ImgProva.width >4147) then
zoom:=1
else zoom:=0.8;
ImgProva.Width := Trunc(ImgProva.Width / zoom);
ImgProva.Height := Trunc(ImgProva.Height / zoom);
end;
mbMiddle:
begin
ImgProva.ScaleMode := smNormal;
ImgProva.AutoSize := True;
end;
mbRight:
begin
if (ImgProva.width <1200) then
zoom:=1
else zoom:=0.8;
ImgProva.Width := Trunc(ImgProva.Width * zoom);
ImgProva.Height := Trunc(ImgProva.Height * zoom);
end;
end;
end;
L'effetto ottenuto è di avere l'immagine ingrandita o rimpicciolita allineata in alto a sinistra, io invece vorrei che l'immagine fosse centrata sul punto dove il mouse ha fatto click per ingrandirla.
Altrimenti si otterrebbe un effetto "disorientante" per chi cerca di ingrandire un particolare che gli interessa.
Penso che dovrei agire sulle coordinate del mouse ma non so proprio come. Qualcuno potrebbe farmi un esempio? Grazie.