endermad
Messages postés4Date d'inscriptionvendredi 8 juin 2007StatutMembreDernière intervention20 juin 2007
-
19 juin 2007 à 12:18
endermad
Messages postés4Date d'inscriptionvendredi 8 juin 2007StatutMembreDernière intervention20 juin 2007
-
20 juin 2007 à 15:37
salut a tous,
j'aimerais afficher des points sur une image(que j'ai au préalable chargée) dans une picturebox. Sur mon pc pas de problème
tout marche j'ai les points qui clignotent et j'ai les textes. Mais dès que je passe le code sur un autre pc les points ne
s'affichent pas.
jmfmarques
Messages postés7668Date d'inscriptionsamedi 5 novembre 2005StatutMembreDernière intervention22 août 201427 19 juin 2007 à 14:02
Bonjour les cracks,
Regardez mieux !
C'est dans les instruction de son If... Then... Else... qu'il a fait une erreur de calcul de coefficient !
Solution : il faut qu'il modifie ce code-là ...
endermad
Messages postés4Date d'inscriptionvendredi 8 juin 2007StatutMembreDernière intervention20 juin 2007 19 juin 2007 à 16:17
ouai dsl j'ai oublié de copier le code...
je me suis servi de morceaux de code disponible sur le site.
Private Sub Form_Load()
' ici je charge ma carte avec une fonction du module
Form1.WindowState = vbMaximized
Call InitialisationPicture(Form1, Pct_Main_Parent, Pct_Main_Child, Img_Photo, _
Hsb_Main_Parent, Vsb_Main_Parent, "F:\projet1.jpg")
'limites de la carte
X1 = Conv_sec("01°58'39,50 O")
X2 = Conv_sec("01°52'98,80 O")
debut_X = X1
Y1 = Conv_sec("52°29'68,80 N")
Y2 = Conv_sec("52°25'99,60 N")
debut_Y = Y1
End Sub
Private Sub Timer1_Timer()
' calcule de l'echelle
Rap_X = Abs(X1 - X2) / Pct_Main_Child.ScaleWidth
Rap_Y = Abs(Y1 - Y2) / Pct_Main_Child.ScaleHeight
' point qui clignote
If Col = vbRed Then
Col = vbCyan
Else
Col = vbRed
End If
Pct_Main_Child.DrawWidth = 4
Pct_Main_Child.FillColor = Col
Pct_Main_Child.Circle (Int((-1.942 * 3600 - debut_X) / Rap_X), Int((-52.466 * 3600 + debut_Y) / Rap_Y)), 3, Col
End Sub
merci encore
Vous n’avez pas trouvé la réponse que vous recherchez ?
jmfmarques
Messages postés7668Date d'inscriptionsamedi 5 novembre 2005StatutMembreDernière intervention22 août 201427 20 juin 2007 à 09:16
Ouais...
et aussi :
- le scalemode
- les fonctions de conversion (pour le cas où les coordonnées de X et Y seraient en dehors de l'affichage !...notamment si la résolution du PC client est plus petite que celle du PC de développement...)
Bref : en l'état de ce qui nous est dit : nous voilà bien avancés !!!
endermad
Messages postés4Date d'inscriptionvendredi 8 juin 2007StatutMembreDernière intervention20 juin 2007 20 juin 2007 à 11:12
voila pour la partie initialisationPicture :
Public Sub InitialisationPicture(UserForm As Form, Pct_Parent As PictureBox, Pct_Child As PictureBox, _
Img_Photo As Image, Hsb_Parent As HScrollBar, Vsb_Parent As VScrollBar, _
PathOfThePicture As String)
'-----------------------------------------------------------------------------------
'Initialisation Of the different picture box, image, and scroll bar
'-----------------------------------------------------------------------------------
'Location of the picture box child, image
'Note that reference is made to the top left corner of Pct_Parent (ie, origin)
Pct_Child.Move 0, 0
'Location of the Horizontal scroll bar
Hsb_Parent.Visible = True
Hsb_Parent.Top = Pct_Parent.Top + Pct_Parent.Height
Hsb_Parent.Left = Pct_Parent.Left
Hsb_Parent.Width = Pct_Parent.Width
'Location of the Vertical scroll bar
Vsb_Parent.Visible = True
Vsb_Parent.Top = Pct_Parent.Top
Vsb_Parent.Left = Pct_Parent.Left + Pct_Parent.Width
Vsb_Parent.Height = Pct_Parent.Height
'-----------------------------------------------------------------------------------
'Get the Photo of the image and load it in the control image
'-----------------------------------------------------------------------------------
'The trick here is to load the picture in a control Image so that we can get it in
'a control Picture box By using PaintPicture
'load picture into the image control
Img_Photo.Picture = LoadPicture(PathOfThePicture)
'As the Img_Photo is the initial picture, we want to preserve its original
'dimension
Img_Photo.Stretch = False
'Make the control image not visible during execution
Img_Photo.Visible = False
'-----------------------------------------------------------------------------------
'Redim the size of the child picture box
'-----------------------------------------------------------------------------------
'Resize the Pct_Child to the size of the image
Pct_Child.AutoSize = True
Pct_Child.Width = Img_Photo.Width
Pct_Child.Height = Img_Photo.Height
'Get scale on the Child picture box
Pct_Child.ScaleWidth = Pct_Child.Width
Pct_Child.ScaleHeight = Pct_Child.Height
'-----------------------------------------------------------------------------------
'Load the picture in the child picture box
'-----------------------------------------------------------------------------------
'Set Autoredraw in order to paint a pemanent Picture
Pct_Child.AutoRedraw = True
'Load the picture in the picture box
'This is the default picture, we don't specify width1 and height1 of Paint Picture
Pct_Child.PaintPicture Img_Photo.Picture, 0, 0
'Set if back to False
Pct_Child.AutoRedraw = False
'-----------------------------------------------------------------------------------
'Once the Picture is loaded, Update the Value of the Scroll bar
'-----------------------------------------------------------------------------------
Call ResizeScrollBar(Pct_Parent, Pct_Child, Img_Photo, _
Hsb_Parent, Vsb_Parent)
End Sub
'==================================================================================
'2. Function: ResizeScrollBar
'==================================================================================
Public Sub ResizeScrollBar(Pct_Parent As PictureBox, Pct_Child As PictureBox, _
Img_Photo As Image, Hsb_Parent As HScrollBar, Vsb_Parent As VScrollBar)
'-----------------------------------------------------------------------------------
'Once picture is loaded, initialisation of the scroll bars
'-----------------------------------------------------------------------------------
'check to Make Vertical scroll bar visible
If Pct_Child.ScaleHeight > Pct_Parent.ScaleHeight Then
Vsb_Parent.Visible = True
Else
Vsb_Parent.Visible = False
End If
'check to Make Horizontal scroll bar visible
If Pct_Child.ScaleWidth > Pct_Parent.ScaleWidth Then
Hsb_Parent.Visible = True
Else
Hsb_Parent.Visible = False
End If
'==================================================================================
'3.a Function: MovePictureVertically
'==================================================================================
Public Sub MovePictureVertically(Pct_Child As PictureBox, Vsb_Parent As VScrollBar)
'Change the top position of the Child picture where the origin is the top left
'corner of the parent picture box using the Vertical scroll bar
Pct_Child.Top = -Vsb_Parent.Value
End Sub
'==================================================================================
'3.b Function: MovePictureHorizontally
'==================================================================================
Public Sub MovePictureHorizontally(Pct_Child As PictureBox, Hsb_Parent As HScrollBar)
'Change the Left position of the Child picture where the origin is the top left
'corner of the parent picture box using the Horizontal scroll bar
Pct_Child.Left = -Hsb_Parent.Value
End Sub
'==================================================================================
'4. Function: FitChildToParentScreen
'==================================================================================
Public Sub FitChildToParentScreen(Pct_Parent As PictureBox, Pct_Child As PictureBox, _
Img_Photo As Image, Hsb_Parent As HScrollBar, Vsb_Parent As VScrollBar)
'Declare public Variables used by the subroutine FitChildToParentScreen
Dim ZoomCoefWidth As Double
Dim ZoomCoefHeight As Double
'Get Zoom coefficient in X & Y dir
ZoomCoefWidth = Pct_Parent.ScaleWidth / Pct_Child.ScaleWidth
ZoomCoefHeight = Pct_Parent.ScaleHeight / Pct_Child.ScaleHeight
'Then apply Zoom with these ratios
Call Zoom(Pct_Parent, Pct_Child, Img_Photo, Hsb_Parent, Vsb_Parent, _
ZoomCoefWidth, ZoomCoefHeight, FlagDrawGrid)
End Sub
'==================================================================================
'5. Function: Zoom
'==================================================================================
Public Sub Zoom(Pct_Parent As PictureBox, Pct_Child As PictureBox, Img_Photo As Image, _
Hsb_Parent As HScrollBar, Vsb_Parent As VScrollBar, RatioX As Double, _
RatioY As Double, DrawGrid As Boolean)
'-----------------------------------------------------------------------------------
'Declare Variables used by the subroutine Zoom
'-----------------------------------------------------------------------------------
'These are used to recenter the Picture after Zooming
Dim PhotoBWPx As Double 'Width of Photo in Pixels before Zoom
Dim PhotoBHPx As Double 'Height of Photo in Pixels before Zoom
Dim PhotoAWPx As Double 'Width of Photo in Pixels after Zoom
Dim PhotoAHPx As Double 'Height of Photo in Pixels after Zoom
'-----------------------------------------------------------------------------------
'Apply Zoom to the Child picture box, ie, Increase or decrease its size
'-----------------------------------------------------------------------------------
'Set Autoredraw to true in order to paint a pemanent Picture
Pct_Child.AutoRedraw = True
'Get size before zooming
PhotoBWPx = Pct_Child.Width
PhotoBHPx = Pct_Child.Height
'resize the child picture box to the size of the image
Pct_Child.Width = Pct_Child.Width * RatioX
Pct_Child.Height = Pct_Child.Height * RatioY
'Get size After zooming
PhotoAWPx = Pct_Child.Width
PhotoAHPx = Pct_Child.Height
'-----------------------------------------------------------------------------------
'Now, paste the photo with Zoom applyied
'-----------------------------------------------------------------------------------
'Clean before pasting the new picture
Pct_Child.Cls
'Load the picture in the picture box
Pct_Child.PaintPicture Img_Photo.Picture, 0, 0, PhotoAWPx, PhotoAHPx
'Set it back to False
Pct_Child.AutoRedraw = False
'-----------------------------------------------------------------------------------
'Recenter the image due to zoom
'-----------------------------------------------------------------------------------
Call RecenterPicture(Pct_Parent, Pct_Child, Pct_Child.Left - ((PhotoAWPx - PhotoBWPx) / 2), _
Pct_Child.Top - ((PhotoAHPx - PhotoBHPx) / 2))
'-----------------------------------------------------------------------------------
'Resize scroll bar
'-----------------------------------------------------------------------------------
'Now that the picture is Zoomed, resize Scroll bar
Call ResizeScrollBar(Pct_Parent, Pct_Child, Img_Photo, Hsb_Parent, Vsb_Parent)
'-----------------------------------------------------------------------------------
'Reinitialisation of the values of the scrollbar
'-----------------------------------------------------------------------------------
'Get the new values for the scrollbar
Hsb_Parent.Value = -Pct_Child.Left
Vsb_Parent.Value = -Pct_Child.Top
'If it is a Zoom out and that the Child picture box is smaller that the parent
'picture box, then put it in the top left corner
If Hsb_Parent.Value < 0 Then
Hsb_Parent.Value = 0
Pct_Child.Left = 0
End If
If Vsb_Parent.Value < 0 Then
Vsb_Parent.Value = 0
Pct_Child.Top = 0
End If
et pour le calcul des coordonnees pour l'instant j'ai juste essayer avec les points suivants :
Pour la résolution de l'écran j'ai testé mais ca n'a rien changé.
Pour la conversion :
Public Function Conv_sec(Data As String) As Double
' Conversion d'une position en degrés,minute,seconde vers secondes( - si latitude Sud ou Longitude Ouest)
Dim degres As Single
Dim Minute As Single
Dim Seconde As Single
Dim sens As Boolean
Dim tmp As String
Dim ret As Integer
On Local Error Resume Next
tmp = Data
sens = False
If InStr(tmp, "O") Or InStr(tmp, "S") Or InStr(tmp, "W") Then
sens = True
End If
tmp = Trim(Left$(tmp, Len(tmp) - 1))
ret = InStr(tmp, "°")
degres = Val(Left(tmp, ret - 1))
tmp = Mid$(tmp, ret + 1)
ret = InStr(tmp, "'")
Minute = Val(Left(tmp, ret - 1))
tmp = Mid$(tmp, ret + 1)
Seconde = tmp
Conv_sec = (degres * 3600) + (Minute * 60) + Seconde
Conv_sec = Int(Conv_sec * 100) / 100
If sens = True Then
Conv_sec = 0 - Conv_sec
End If
End Function