Page 1 of 1

Different VectorDrawing-Outputs on Mac OS and Windows

Posted: Tue Nov 28, 2017 3:22 pm
by Lebostein
I have tested the Vector-Rendering on Mac OS and Windows. I have found 2 problems:

1. On Mac OS the font rendering on image or canvas is to small. If I render on PDF then the font rendering on Mac OS is correct. The missing scale factor to see the same output on image (or canvas) like PDF (or using Windows) is exactly 1.6

2. On Windows there seems a problem with the dashed lines. The parameters Length.d and StartOffset.d are interpreted a little bit too big, so that the dashes not match the expected size. In my example the Length is exactly 1/2 distance of two horizontal lines, the StartOffset is exactly 1/4 distance of two horizontal lines. With Mac OS it fits exactly, with Windows I see a mismatch.

https://www.dropbox.com/s/93lx5olmssek2 ... tput_2.png

Re: Different VectorDrawing-Outputs on Mac OS and Windows

Posted: Wed Nov 29, 2017 9:51 am
by Lebostein
I think I can specify the Windows bug with dashed lines in more detail. The Length and StartOffset depends on the LineWidth! That should not be. In the example all dashed lines have the same Length and StartOffset parameters, but different line widths. The thicker the line, the closer the result comes to expectations:

Code: Select all

EnableExplicit

Define sheet_width_mm.d = 50.
Define sheet_height_mm.d = 88.
Define distance_mm.d = 8.
Define DPI = 100
Define i, line_width.d

CreateImage(0, 2000, 2000)

If StartVectorDrawing(ImageVectorOutput(0, #PB_Unit_Millimeter))
  ; set the correct DPI
  ScaleCoordinates(DPI / VectorResolutionX(), DPI / VectorResolutionY())
  ; calculate the pixel size of the image related to DPI and sheet size
  Define sheet_width_pixel = ConvertCoordinateX(sheet_width_mm, sheet_height_mm, #PB_Coordinate_User, #PB_Coordinate_Device)
  Define sheet_height_pixel = ConvertCoordinateY(sheet_width_mm, sheet_height_mm, #PB_Coordinate_User, #PB_Coordinate_Device)
  ; background
  VectorSourceColor($FFFFFFFF)
  FillVectorOutput()
  ; horizontal lines
  VectorSourceColor($FF000000)
  For i = 1 To 10
    MovePathCursor(0, i * distance_mm)
    AddPathLine(sheet_width_mm, 0, #PB_Path_Relative)
    StrokePath(0.5, #PB_Path_SquareEnd)
  Next
  ; vertical dashed lines
  VectorSourceColor($FFFF0000)
  For i = 1 To 9
    line_width = 0.05 * i ; from 0.05 to 0.45
    MovePathCursor(sheet_width_mm * 0.1 * i, distance_mm)
    AddPathLine(0, 9 * distance_mm, #PB_Path_Relative)
    DashPath(line_width, distance_mm / 2, #PB_Path_Default, distance_mm / 4)
  Next i
  ; leave
  StopVectorDrawing()
EndIf

UsePNGImageEncoder()
GrabImage(0, 1, 0, 0, sheet_width_pixel, sheet_height_pixel)
SaveImage(1, "test_vd_" + Str(DPI) + ".png", #PB_ImagePlugin_PNG)
Unexpected and buggy output with Windows:
https://www.dropbox.com/s/p1l82tx61w0ks ... vd_100.png

No problems using Mac OS X:
https://www.dropbox.com/s/7458kvmcqddyi ... 00_mac.png

Edit: It seems with Windows the chosen DPI influence the result as well:
https://www.dropbox.com/s/oc8p57710nq0o ... _vd_50.png
https://www.dropbox.com/s/wuh7zg718zn3h ... vd_300.png
https://www.dropbox.com/s/dop0tm0whn52e ... vd_500.png

Re: Different VectorDrawing-Outputs on Mac OS and Windows

Posted: Fri Dec 01, 2017 8:15 am
by Lebostein
I could only test this on Windows XP on a virtual machine (VirtualBox).
Can anyone confirm this with a real Windows XP/7/10?