NOTE: Assumes raising width is raising height and lowering height is lowering width on all functions(maintains aspect ratios). It's pretty much made to maintain coordinate and aspect for anything across all screen sizes. It supports up to 10,000px where it calculates aspect-ratio which is over two-times UHD/4k, so it's good for at least a decade.
Code: Select all
;pass old width and old screen-width for new image width
Procedure.l DynamicWidth(width.l,screenw.l)
ExamineDesktops()
Protected dw=DesktopWidth(0)
ProcedureReturn Round(((((width * 100) / screenw) * dw) / 100),#PB_Round_Nearest)
EndProcedure
;pass old height and old screen-height for new image height
Procedure.l DynamicHeight(height.l,screenh.l)
ExamineDesktops()
Protected dh=DesktopHeight(0)
ProcedureReturn Round(((((height * 100) / screenh) * dh) / 100),#PB_Round_Nearest)
EndProcedure
;pass old x and old screen-width for new x
Procedure.l DynamicX(x.l,screenw.l)
ExamineDesktops()
Protected dx=DesktopWidth(0)
ProcedureReturn Round(((((x * 100) / screenw) * dx) / 100),#PB_Round_Nearest)
EndProcedure
;pass old y and old screen-height for new y
Procedure.l DynamicY(y.l,screenh.l)
ExamineDesktops()
Protected dy=DesktopWidth(0)
ProcedureReturn Round(((((y * 100) / screenh) * dy) / 100),#PB_Round_Nearest)
EndProcedure
;pass new image-width and aspect-ratio to get new image-height
Procedure.l DynamicAspectHeight(image.l,width.l,aspect.f)
Protected i.l
If width<ImageWidth(image)
For i = ImageHeight(image) To 0 Step -1
If StrF(width / i,2) = StrF(aspect,2) : ProcedureReturn i : EndIf
Next
Else
For i = ImageHeight(image) To 10000 Step -1
If StrF(width / i,2) = StrF(aspect,2) : ProcedureReturn i : EndIf
Next
EndIf
EndProcedure
;pass new image-height and aspect-ratio to get new image-width
Procedure.l DynamicAspectWidth(image.l,height.l,aspect.f)
Protected i.l
If ImageHeight(image)<height
For i = ImageWidth(image) To 10000
If StrF(i / height,2) = StrF(aspect,2) : ProcedureReturn i : EndIf
Next
Else
For i = ImageWidth(image) To 0 Step -1
If StrF(i / height,2) = StrF(aspect,2) : ProcedureReturn i : EndIf
Next
EndIf
EndProcedure
;pass old aspect-ratio to get new width for current-height(you want to always use device height but dynamic width)
Procedure.l DynamicScreenWidth(aspect.f)
Protected i.l
ExamineDesktops()
For i = DesktopWidth(0) To 0 Step -1
If StrF(i / DesktopHeight(0),2) = StrF(aspect,2) : ProcedureReturn i : EndIf
Next
EndProcedure