conversion: pixel -> base units

Share your advanced PureBasic knowledge/code with the community.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

conversion: pixel -> base units

Post by eddy »

Code updated For 5.20+

Code: Select all

; =============
; usefull to make modal dialogbox
; =============

Procedure Pixel2BaseUnits(*pt.POINT)
   baseunit=GetDialogBaseUnits_()
   baseunitX=PeekW(@baseunit)
   baseunitY=PeekW(@baseunit+2)
   *pt\x=(*pt\x)*4/baseunitX
   *pt\y=(*pt\y)*8/baseunitY
EndProcedure 

Code: Select all

pt.POINT
pt\x=100
pt\y=200

Pixel2BaseUnits(@pt)

Debug pt\x
Debug pt\y
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool