Page 1 of 1

Vector Graphice inaccurate?

Posted: Sun Oct 18, 2015 3:25 pm
by collectordave
Just trying the code below.

get screen DPI.

Resize canvasgadget to a width of 210mm

Drawline 200mm long.

Canvas gadget shows with a width of 200mm and a little bit

the line is drawn with a length of 185mm more or less.

Are the vector graphics functions inaccurate?

Code: Select all


Global Window_0

Global Canvas_0,ScreenDPI

Macro mm2px(mm)
    Round(ScreenDPI/25.4 * mm, #PB_Round_Nearest) 
  EndMacro
  
  Procedure GetScreenDPI()
  
  StartVectorDrawing(CanvasVectorOutput(Canvas_0,#PB_Unit_Pixel))
  ScreenDPI = VectorResolutionX()
  StopVectorDrawing()

EndProcedure

  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_Maximize)
  Canvas_0 = CanvasGadget(#PB_Any, 10, 10,100, 80)
  
  GetScreenDPI()

  ResizeGadget(Canvas_0, 10,10,mm2px(210),80)

  StartVectorDrawing(CanvasVectorOutput(Canvas_0,#PB_Unit_Millimeter))
  MovePathCursor(5,10)
  AddPathLine(200,10)
  StrokePath(1)

  StopVectorDrawing()

Repeat
  
  event = WaitWindowEvent()

Until event = #PB_Event_CloseWindow

Re: Vector Graphice inaccurate?

Posted: Sun Oct 18, 2015 3:55 pm
by mhs
Confirmed

It seems to be a calculation error, the longer the line. If you use 10mm or 1inch it seems to be ok.

Re: Vector Graphice inaccurate?

Posted: Sun Oct 18, 2015 4:06 pm
by wilbert
collectordave wrote:Drawline 200mm long.
The default for AddPathLine is absolute coordinates so you are drawing a 195 mm long line (200 - 5).

Re: Vector Graphice inaccurate?

Posted: Sun Oct 18, 2015 4:25 pm
by collectordave
Just changed drawline code to

Code: Select all

  StartVectorDrawing(CanvasVectorOutput(Canvas_0,#PB_Unit_Millimeter))
  MovePathCursor(10,10)
  AddPathLine(200,10)
  MovePathCursor(200,10)
  AddPathLine(200,100)
  StrokePath(1)
So now realizing that it is absolute coordinates the first horizontal line should be 190mm long. Starting at 10mm from the left edge that should reach a point 200mm from the left edge. It actually reaches a point 190mm from the left edge and is only 180mm in length.

The vertical line should start 10mm from the top edge and reach a point 100mm below the top edge. It only reaches 95mm from the top edge.

This still leaves the canvas gadget sizing. The screen resolution is 96DPI so the calculation finds the number of pixels needed to represent 210mm on the screen and it actually draws to a width of 200mm on screen.

Re: Vector Graphice inaccurate?

Posted: Sun Oct 18, 2015 5:16 pm
by wilbert
I compared OSX against Windows on my Mac.
OSX returns a value of 103 PPI (right), Windows a value of 96 PPI (wrong).
So the problem is that VectorResolutionX() does return the wrong value on Windows.

It seems to be really problematic (impossible ?) on Windows to get information about the physical screen size.
Maybe this helps although I'm not sure if it is supported for non Metro apps http://dwcares.com/actual-size/

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 5:11 am
by collectordave
Tried an online dpi calculator for my screen and it returned 100dpi. Put this in and it works on the canvas sizing. It does appear that windows reports the wrong DPI.

Also looked at the importance of this. Unless you need accurate measurments on screen. As long as the error is the same for all operations then you still get an accurate picture of whatever you are drawing just not real life (scale is off by the error).

The most important time is when the output is printed. Has anyone tried printing accurately? I have done some printing work with the vector graphics but never measured the finished article.

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 7:33 am
by helpy
collectordave wrote:It does appear that windows reports the wrong DPI.
Windows returns the DPI which is set in the Windows settings.
See: http://www.techrepublic.com/blog/window ... i-scaling/

Change the DPI setting in windows and it probably should work.

guido

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 1:59 pm
by collectordave
Thanks. Changed the DPI setting to my actual DPI and it reports back to PB correctly and the screen and gadgets etc are all drawn to scale.

However change the resolution of the screen and the DPI setting does not change so back to square one.

PB is OK just windows reporting a setting instead of the actual DPI at whatever screen resolution set by user.

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 3:35 pm
by helpy
Consider the following:

==> Not each monitor is able to report the hardware resolution of the display!

==> It seems that only Windows 8 and 10 are prepared for reading display resolution
--> https://msdn.microsoft.com/en-us/librar ... nformation
--> https://msdn.microsoft.com/en-us/librar ... on.rawdpix
--> http://blogs.windows.com/windowsexperie ... hancements

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 4:08 pm
by collectordave
Yes

Was reading and searching and found an article explaining this. It is possible under windows 8 hopefully someone can test that with the vector graphics commands?

Re: Vector Graphice inaccurate?

Posted: Mon Oct 19, 2015 4:25 pm
by mhs
I'm using Win 8.1... it's not working with my monitor.

The monitor has 90 dpi and I get a return value of 96.

Re: Vector Graphice inaccurate?

Posted: Sun Nov 08, 2015 8:52 pm
by collectordave
The basic answer is that windows reports a setting. This setting is not updated when the resolution is changed, not even to apply the PPI to DPI scaling factor. Something windows has missed.

There is a difference between PPI and DPI which seems to have confused Microsoft. they seem to be trying to simply satisfy as many people as possible and saying sod it to the truth.