There is an image of a map, such as England. Using the Image
component, how to make on OnMouseUp
passing new X, Y
(ShiftState) coordinates to change image coordinates? Just like in Google Maps, only without scaling: change location, move with mouse.
1 answer
Well, if you mean moving the image around the TImage component with the mouse, then this can be done, for example, like this:
var bmp:TBitMap; // ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°, Π·Π°Π³ΡΡΠΆΠ°Π΅ΠΌΠ°Ρ Π² ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ TImage procedure TForm1.FormShow(Sender: TObject); // Π·Π΄Π΅ΡΡ ΠΏΠ΅ΡΠ²ΠΎΠ½Π°ΡΠ°Π»ΡΠ½Π°Ρ Π·Π°Π³ΡΡΠ·ΠΊΠ° begin bmp:=Tbitmap.Create; bmp.LoadFromFile('yourImage.bmp'); // Π·Π°Π³ΡΡΠΆΠ°Π΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ( ΠΌΠΎΠΆΠ½ΠΎ ΠΈ Π² Π΄ΡΡΠ³ΠΎΠΌ ΡΠΎΠ±ΡΡΠΈΠΈ) image1.Canvas.Draw(0,0,bmp); end; procedure TForm1.Image2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if ssleft in shift then // Π΅ΡΠ»ΠΈ Π½Π°ΠΆΠ°ΡΠ° Π»Π΅Π²Π°Ρ ΠΊΠ½ΠΎΠΏΠΊΠ° ΠΌΡΡΠΈ, ΡΠΎ... begin // ΠΎΡΠΈΡΠ°Π΅ΠΌ ΠΊΠ°Π½Π²Ρ ΠΎΡ ΡΠ°Π½Π΅Π΅ Π·Π°Π³ΡΡΠΆΠ΅Π½Π½ΠΎΠ³ΠΎ ΡΠΈΡΡΠ½ΠΊΠ° PatBlt(image1.Canvas.Handle,0,0,image1.ClientWidth,image1.ClientHeight,WHITENESS); // ΠΏΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΡΠ²Π°Π΅ΠΌ ΠΊΠ°Π½Π²Ρ Ρ Π½ΠΎΠ²ΡΠΌΠΈ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΠ°ΠΌΠΈ ΡΠΈΡΡΠ½ΠΊΠ° image1.Canvas.Draw(x,y,bmp); end;
PS
Please do not interfere with all in one pile: Google Maps, Delphi, drawings and motion on the canvas. You are very confused by this people. Simply form your question correctly ...
|