Le code qui donne le rapport pixel/cm et qui affiche un trait de 1 cm de long, prenez vos règles, chez moi, ça marche
Code : Tout sélectionner
Procedure Actualise()
; Calcul du rapport pixel/cm
Rapport.f = Val(GetGadgetText(4)) / ((GetGadgetState(2) + 10) * 2.54) / Cos(ATan(Val(GetGadgetText(5)) / Val(GetGadgetText(4))))
; Affichage du rapport
SetGadgetText(7, StrF(Rapport, 5))
; dessin d'un trait de longueur 1 cm sur l'image
StartDrawing(ImageOutput())
Line(5, 21, 134, 0, RGB(255, 255, 255))
Line(5, 21, Round(Rapport + 0.5, 0), 0, 0)
StopDrawing()
; Actualisation de li'mage
SetGadgetState(8, UseImage(0))
EndProcedure
;- Debut du programe
If OpenWindow(0, 0, 0, 150, 195, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Mesure")
If CreateGadgetList(WindowID())
; Taille de l'écran
TextGadget(1, 3, 3, 144, 15, "Taille de l'écran", #PB_Text_Center)
ComboBoxGadget(2, 3, 18, 144, 500) ; Liste des tailles d'écran
For i = 10 To 30 ; On rempli la liste des tailles
AddGadgetItem(2, -1, Str(i) + " pouces")
Next
SetGadgetState(2, 7)
TextGadget(3, 3, 45, 144, 15, "Résolution", #PB_Text_Center)
; Résolution de l'écran
X = GetSystemMetrics_(#SM_CXSCREEN)
Y = GetSystemMetrics_(#SM_CYSCREEN)
; Calcul du rapport pixel/cm
Rapport.f = X / ((GetGadgetState(2) + 10) * 2.54) / Cos(ATan(Y / X))
; Dimension de l'écran
StringGadget(4, 3, 60, 144, 20, Str(X), #PB_String_Numeric)
StringGadget(5, 3, 80, 144, 20, Str(Y), #PB_String_Numeric)
; Rapport pixel/cm
TextGadget(6, 3, 105, 144, 15, "Rapport pixel / cm", #PB_Text_Center)
StringGadget(7, 3, 120, 144, 20, StrF(Rapport, 5))
; Création de l'image pour afficher un trait de 1 cm de long
CreateImage(0, 144, 30)
StartDrawing(ImageOutput())
FontID = LoadFont(0, "Tahoma", 8, #PB_Font_HighQuality)
Box(0, 0, 144, 30, RGB(0255, 255, 255))
DrawingMode(4)
Box(0, 0, 144, 30, RGB(0, 0, 120))
DrawingMode(1)
FrontColor(0, 0, 0)
DrawingFont(FontID)
Locate(5, 3)
DrawText("1 cm")
Line(5, 21, Round(Rapport + 0.5, 0), 0)
StopDrawing()
; Affichage de l'image
ImageGadget(8, 3, 160, 144, 30, UseImage(0))
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
Select EventGadgetID()
Case 2
Actualise()
Case 4
Actualise()
Case 5
Actualise()
EndSelect
EndIf
Until Event = #WM_CLOSE
EndIf
EndIf