Calibrate 'Screen" to 'Display'

For finished programs
Post Reply
User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Calibrate 'Screen" to 'Display'

Post by Dutchman » Fri Nov 08, 2019 7:48 pm

During development of a Plot program, I became quite frustrated when designing the canvas in metric units, because the dimensions on the monitor showed very large deviations (> 30%) compared to the programmed values.
It became even crazier when it appeared that the images made with the "Screenshot" button had the correct dimensions when viewed in Photoshop.
Then the idea arose that there had to be a difference between "screen" and "display".
Apparently the screen is a image container in memory to which the image or graphic scene is written.
This "screen" serves as a source for composing the image on the monitor, the "display".
Apple has the "Aqua" system that renders the image and apparently also has the option to enlarge or reduce the displayed scene.
In the attached PDF file I have described how indeed the zoom factor between 'screen' and 'display' can be changed.
Callibrate.pdf
(157.36 KiB) Downloaded 5 times
The zoom factor can be determined with the following program.

Code: Select all

'# Calibrate
'by Ton Nillesen, November 2019
'Calibrate Screen Scale to Display in pixels per mm
'
'--- Constants and presets
Font$="Arial Rounded MT Bold"
FontSize=20
Fh=1.55 ' ratio betwwen fontsize and lineheight
Txt$="Enlarge screenwidth to maximum by pulling left and right edges."
DRAW FONT Font$,FontSize
DRAWCOLOR 0,0,1
th=STRHEIGHT Txt$ : tw=1.05*STRWIDTH txt$
Txt$+=CR$+"Then measure length of bar in millimeters and enter it."
SCRSIZE tw+100,100
Margin=40 ' left and right
SubDiv=20 ' pixels per subdivision between ticks
Div=5*subdiv ' pixels between major ticks
Ph=20 ' half tick height
DRAW MANUAL
DRAW COLOR 0,0,0
GOSUB Init
ww,wh=SCRSIZE|2
'
DO '––––––––– Dynamic section –––––––––
  DRAW CLEAR 1,1,1
  sw=SCRWIDTH
  w$=sw$+STRTEXT sw "0"
  INSIGN TEXT 1,w$
  Pixels=sw*SCRSCALE : pixels-=2*margin
  Ruler=div*FLOOR(pixels/div)
  PRINT "Ruler =";ruler;"pixels"
  ruler+=subdiv
  FOR i=0 TO 5 'line width of ruler
    DRAW PIXEL margin,py-i+2,ruler+subdiv,py-i+2
  NEXT i
  x=0
  DO IF x<ruler ' draw ticks
    IF ABS(INT(x/div)-x/div)<1e-6 THEN GOSUB Marker
    FOR j=0 TO 3 
      DRAW PIXEL margin+x-j+2,py+ph,margin+x-j+2,py-ph ' marker width
    NEXT j
   x+=subdiv
  REDO
  rw$="Ruler length="+(STRTEXT x-subdiv "0")+" pixels"
  INSIGN TEXT 2,rw$
  y+=fh*th
  DRAW UPDATE
'--- Get length
  DO
    CPU RELAX
  REDO IF NOT(INEDIT CHANGED 4) AND (sw=SCRWIDTH) ' wait for change
  L$=INEDIT TEXT 4
  Length=STR NUM L$
  IF Length>0
    INSIGN TEXT 3 a$+" "+L$
    INEDIT DELETE 4
  ELSE
    INEDIT TEXT 4 ""
  ENDIF
REDO IF (Length<=0)
'
CLS '––––––––– Display –––––––––
Ruler-=subdiv ' number of subdivs=size-1
PRINT "Display width =";sw;"points"
PRINT "Ruler =";ruler;"pixels"
PRINT "Length ruler =";length;"millimeter"
l$=STRTEXT Length "0.00"
Res$=STRTEXT ruler/length "0.000"
Res2$=STRTEXT 25.4*ruler/length "0.0"
PRINT "Resolution = "+Res$+" ppmm"
PRINT "           = "+Res2$+" dpi"
s1=ruler/(SCRSCALE*72) 
PRINT "On 'Screen' ruler = "+STRTEXT s1 "0.000 inch"
s2=length/25.4
PRINT "On 'Display' ruler = "+STRTEXT s2 "0.000 inch"
PRINT "Zoom = "+STRTEXT s2/s1 "0.000"
SCRSIZE ww, wh
END
'
'======== Subroutines ==============
Marker:
FOR j=0 TO 3 
  DRAW PIXEL margin+x-j+2,py+2*ph,margin+x-j+2,py-2*ph ' marker width
NEXT j
RETURN
'
Init:
'--- Message
y=10
INSIGN SET 0,txt$,10,10,tw+5,2*fh*th ' 2 lines
INSIGN FONT 0,Font$,FontSize
INSIGN FCOLOR 0,1,0,0
y+=2*fh*th
'--- Width
y+=10
sw$="Display width=" ' text in width
ww=1.05*(STRWIDTH sw$+"0000")
INSIGN SET 1,"",10,y,ww,fh*th ' 2 lines
INSIGN FONT 1,Font$,FontSize
INSIGN FCOLOR 1,  0,0,0
INSIGN BCOLOR 1,  1,1,1
'--- Ruler y
y+=2*fh*th
py=SCRSCALE*y
y+=0.5*fh*th
'---- length
rw$="Ruler length="+" 0000 "+" pixels"
rw=1.05*STRWIDTH rw$
y+=10
INSIGN SET 2,"",10,y,rw,fh*th ' 2 lines
INSIGN FONT 2,Font$,FontSize
INSIGN FCOLOR 2, 0,0,0
INSIGN BCOLOR 2, 1,1,1
y+=2*fh*th
'--- Get length
a$=" Length of ruler in millimeters ="
aw=1.05*STRWIDTH a$+"00"
y+=10
ew=60 'edit width
INSIGN SET 3,a$,10,y,aw+ew,1.2*fh*th ' 2 lines
INSIGN FONT 3,Font$,FontSize
INSIGN FCOLOR 3, 1,1,0
INSIGN BCOLOR 3, 0,0,1
INEDIT SET 4,"",aw,y+6,ew
DRAW SIZE 5
DRAW COLOR 1,0,0
RETURN
.
%22Calibrate%22 display.JPG
%22Calibrate%22 display.JPG (52.71 KiB) Viewed 149 times
.
Apple has probably also created a system constant that indicates the zoom factor, but I don't have the ability to figure it out.
Last edited by Dutchman on Fri Nov 08, 2019 9:47 pm, edited 2 times in total.
It is still a long way to go

User avatar
kibernetik
Site Admin
Posts: 131
Joined: Tue Aug 06, 2019 3:03 pm

Re: Calibrate 'Screen" to 'Display'

Post by kibernetik » Fri Nov 08, 2019 8:21 pm

Mine data is:

Code: Select all

Display width = 1440 points
Ruler = 2800 pixels
Length ruler = 278 millimeter
Resolution = 10.072 pixels per mm = 255.8 dpi
           = 255.8 dpi
On 'Screen' ruler = 19.444 inch
On 'Display' ruler = 10.945 inch
Zoom = 0.563

User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Re: Calibrate 'Screen" to 'Display'

Post by Dutchman » Fri Nov 08, 2019 9:42 pm

I have made some minor corrections in the code and the "manual".
My results for "More space"

Code: Select all

Display width = 3148 points
Ruler = 6200 pixels
Length ruler = 578 millimeter
Resolution = 10.727 ppmm
           = 272.5 dpi
On 'Screen' ruler = 43.056 inch
On 'Display' ruler = 22.756 inch
Zoom = 0.529
Strange is that the display specification is : Resolutie: 5120 x 2880 Retina
and on that display of 5120 pixels I can draw a 'ruler' of 6200 pixels.
I have more questions than answers :D
It is still a long way to go

Post Reply