Hier, ich hoffe du kannst was damit anfangen

Du musst eigentlich nur am Anfang des Codes mit den Werten
screenRatio\Width und
screenRatio\Height
spielen. Das ist deine Bildschirmauflösung an die sich dein Bild (
myRatio) anpasst.
Code: Alles auswählen
Structure AspectRatio
Width.i
Height.i
Ratio.d
EndStructure
Define myRatio.AspectRatio ; 3:2
myRatio\Width = 300
myRatio\Height = 200
myRatio\Ratio = myRatio\Width / myRatio\Height
Define screenRatio.AspectRatio ; 16:9
screenRatio\Width = 400
screenRatio\Height = 225
screenRatio\Ratio = screenRatio\Width / screenRatio\Height
Enumeration 1
#Vert
#Hori
EndEnumeration
If myRatio\Ratio > screenRatio\Ratio
Debug "Mein Verhältnis ist länglicher als das des Bildschirms"
ScaleFactor.f = screenRatio\Width / myRatio\Width
Ausrichtung = #Vert
ElseIf myRatio\Ratio < screenRatio\Ratio
Debug "Das Bildschirmverhältnis ist länglicher als meines"
ScaleFactor.f = screenRatio\Height / myRatio\Height
Ausrichtung = #Hori
ElseIf myRatio\Ratio = screenRatio\Ratio
Debug "Seitenverhätlnisse sind gleich:)"
ScaleFactor.f = screenRatio\Width / myRatio\Width ;ODER: screenRatio\Height / myRatio\Height ... in dem Fall egal
Debug "ScaleFactor" + ScaleFactor
EndIf
myRatio\Width = myRatio\Width * ScaleFactor
myRatio\Height = myRatio\Height * ScaleFactor
OpenWindow(0, 0, 0, screenRatio\Width, screenRatio\Height, "my Screen", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0, 0)
Select Ausrichtung
Case #Hori
x = (screenRatio\Width - myRatio\Width) / 2
Case #Vert
y = (screenRatio\Height - myRatio\Height) / 2
EndSelect
ButtonGadget(0, x, y, myRatio\Width, myRatio\Height, "")
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow