JasonFirth
asked on
Picture Box Problem
Hi All,
I want to create a small app that displays GPS position according NMEA GPS input. The input side I'm ok with. However mapping is a problem. I have so far...
one picturebox which i load with a bitmap map. I set scalemode to 0 and scale properties according to known lat long. whne i move my cursor over the map and show xy correct lon,lat is shown fine.
Next i want to be able to zoom and pan the image. So i select an area proportional to the picturebox size (1/8) according to where the user clicks on the image. Then i use the paintpicture method to copy this to another picturebox where it is displayed as expected.
Now the problem area. When the area is displayed in the second pic box(the pic box the user will see) i need to keep the scaleheight width etc according to where the selection area fits on pic box 1. When I do this I just get a copy of the original image in pic 2??
I have tried copying the cropped image to an imagebox and scaling this accordingly but with no joy?
I need to keep a master image in picturebox 1 as this will be constantly be updated with new points showing current position. The user must work in another window that will zoom and pan around this master image.
Any help suggestions greatly appreciated.
Thanks in advance,
J
Code as follows:
Dim mouse_xup As Double
Dim mouse_yup As Double
Dim mouse_xdown As Double
Dim mouse_ydown As Double
Dim zoomwidth As Double
Dim zoomheight As Double
Private Sub Form_Load()
Dim zoompic As SuperPicCtl
Picture2.ScaleMode = 0
Picture1.ScaleMode = 0
Picture1.Picture = LoadPicture("C:\TEMP\drive 1.bmp")
Picture1.Picture = Picture1.Image
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
Picture1.ScaleHeight = -Picture1.Height 'latdegreedelta
Picture1.ScaleWidth = Picture1.Width 'londegreedelta
Picture1.ScaleLeft = 0 'minlon
Picture1.ScaleTop = Picture1.Height 'max lat
Picture2.ScaleHeight = -Picture1.Height 'latdegreedelta
Picture2.ScaleWidth = Picture1.Width 'londegreedelta
Picture2.ScaleLeft = 0 'minlon
Picture2.ScaleTop = Picture1.Height 'max lat
zoomwidth = Abs(Picture1.ScaleWidth / 4)
zoomheight = Abs(Picture1.ScaleHeight / 4)
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Toolbar1.Buttons(4).Value = 1 Then
ElseIf Toolbar1.Buttons(2).Value = 1 Then
'IF I UNCOMMENT THIS BLOCK I GET A COPY OF ORIG PIC, IF COMMENTED JUST THE CROP AREA IN BOT LEFT PIC2
' Picture2.ScaleHeight = -zoomheight 'latdegreedelta
' Picture2.ScaleWidth = zoomwidth 'londegreedelta
' Picture2.ScaleLeft = X 'minlon
' Picture2.ScaleTop = Y + zoomheight 'max lat
mouse_xdown = X
mouse_ydown = Y
Call Picture2.PaintPicture(Pict ure1, X, Y, zoomwidth, zoomheight, X, Y, zoomwidth, zoomheight)
End If
End Sub
I want to create a small app that displays GPS position according NMEA GPS input. The input side I'm ok with. However mapping is a problem. I have so far...
one picturebox which i load with a bitmap map. I set scalemode to 0 and scale properties according to known lat long. whne i move my cursor over the map and show xy correct lon,lat is shown fine.
Next i want to be able to zoom and pan the image. So i select an area proportional to the picturebox size (1/8) according to where the user clicks on the image. Then i use the paintpicture method to copy this to another picturebox where it is displayed as expected.
Now the problem area. When the area is displayed in the second pic box(the pic box the user will see) i need to keep the scaleheight width etc according to where the selection area fits on pic box 1. When I do this I just get a copy of the original image in pic 2??
I have tried copying the cropped image to an imagebox and scaling this accordingly but with no joy?
I need to keep a master image in picturebox 1 as this will be constantly be updated with new points showing current position. The user must work in another window that will zoom and pan around this master image.
Any help suggestions greatly appreciated.
Thanks in advance,
J
Code as follows:
Dim mouse_xup As Double
Dim mouse_yup As Double
Dim mouse_xdown As Double
Dim mouse_ydown As Double
Dim zoomwidth As Double
Dim zoomheight As Double
Private Sub Form_Load()
Dim zoompic As SuperPicCtl
Picture2.ScaleMode = 0
Picture1.ScaleMode = 0
Picture1.Picture = LoadPicture("C:\TEMP\drive
Picture1.Picture = Picture1.Image
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
Picture1.ScaleHeight = -Picture1.Height 'latdegreedelta
Picture1.ScaleWidth = Picture1.Width 'londegreedelta
Picture1.ScaleLeft = 0 'minlon
Picture1.ScaleTop = Picture1.Height 'max lat
Picture2.ScaleHeight = -Picture1.Height 'latdegreedelta
Picture2.ScaleWidth = Picture1.Width 'londegreedelta
Picture2.ScaleLeft = 0 'minlon
Picture2.ScaleTop = Picture1.Height 'max lat
zoomwidth = Abs(Picture1.ScaleWidth / 4)
zoomheight = Abs(Picture1.ScaleHeight / 4)
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Toolbar1.Buttons(4).Value = 1 Then
ElseIf Toolbar1.Buttons(2).Value = 1 Then
'IF I UNCOMMENT THIS BLOCK I GET A COPY OF ORIG PIC, IF COMMENTED JUST THE CROP AREA IN BOT LEFT PIC2
' Picture2.ScaleHeight = -zoomheight 'latdegreedelta
' Picture2.ScaleWidth = zoomwidth 'londegreedelta
' Picture2.ScaleLeft = X 'minlon
' Picture2.ScaleTop = Y + zoomheight 'max lat
mouse_xdown = X
mouse_ydown = Y
Call Picture2.PaintPicture(Pict
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.