Page 1 of 1

vector circles are ellipses on some computers

Posted: Fri Sep 16, 2022 1:40 pm
by Mesa
It must be silly but do you have any idea why in few computers, the screen displays an ellipse with the circle function and a circle with the "ellipse" function below ?

All computers have:
OS = Windows
dpiX = 1.0, dpiY=1.0 (96 dpi)
compiled with the option dpi aware or not give the same result.
text zoom = normal = 100%
Resolution: 1024x768 (or any others)

Thanx.

M.

Code: Select all

; OS = Windows
; dpiX=1.0, dpiY=1.0, compiled with the option dpi aware or not.
; zoom 100%
; Resolution: 1024x768

ExamineDesktops()
ResolutionX.d=DesktopWidth(0)
ResolutionY.d=DesktopHeight(0)
Excentricite.d = ResolutionY/ResolutionX
; Excentricite.d = 1.0

If OpenWindow(0, 0, 0, 600, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	CanvasGadget(0, 0, 0, 600, 600)
	
	If StartVectorDrawing(CanvasVectorOutput(0))
		
		
		;cross
		MovePathCursor(300,0)
		AddPathLine(300, 600)
		MovePathCursor(0,300)
		AddPathLine(600, 300)
		StrokePath(1)	
		
		;circle red  -> shown as an ellipse in my screen
		MovePathCursor(300, 300)
		AddPathCircle(300, 300, 200)
		VectorSourceColor(RGBA(255, 0, 0, 255))
		StrokePath(3)
		
		
		;ellipse blue -> shown as a circle !
		MovePathCursor(300, 300)
		AddPathEllipse(300, 300, 300*Excentricite, 300) 
		VectorSourceColor(RGBA(0, 0, 255, 255))
		StrokePath(3)
		
		StopVectorDrawing()
	EndIf
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
Image

Re: vector circles are ellipses on some computers

Posted: Fri Sep 16, 2022 5:43 pm
by netmaestro
Pretty sure that can't happen. It's far more likely that the colors are the culprit here. Colors are probably messed up somehow, maybe endianness. Try some squares on different parts of the screen and see if the colors show right.

Re: vector circles are ellipses on some computers

Posted: Fri Sep 16, 2022 6:17 pm
by Little John
netmaestro wrote: Fri Sep 16, 2022 5:43 pm Pretty sure that can't happen. It's far more likely that the colors are the culprit here. Colors are probably messed up somehow, maybe endianness. Try some squares on different parts of the screen and see if the colors show right.
Another way to verify this is to execute only the commands for drawing the circle or only those for drawing the ellipse.

Re: vector circles are ellipses on some computers

Posted: Sat Sep 17, 2022 11:00 am
by Mesa
Thank netmaestro, believe me it happens. I tried some squares on different parts of the screen and colors are all alright.
It's not a problem of color but a problem of geometry. Because squares are displayed as rectangles.

Thank Little John, i tried your advice, but it's the same problem.

-> Squares are displayed as rectangles and rectangles (using my excentricity variable, see the code under please) are shown as squares.
-> I've used the parametric equation of circle, see the code under please -> same problem.
-> I've used CanvasVectorOutput() with #PB_Unit_Pixel, #PB_Unit_Point, #PB_Unit_Inch and #PB_Unit_Millimeter -> same problem.
-> I've used the windows api with gDrawing_v0.85b2, here viewtopic.php?t=46987 -> same problem.
-> i've used the Bresenham's algorithm and the Andre's algorithm, here https://www.purebasic.fr/french/viewtop ... =6&t=11172 -> same problem.

So, i guess it's not a purebasic problem.
I guess Windows or the graphic card driver do something during the execution of the .exe...
But it's a problem.

Maybe, pixels are displayed as rectangle and not as a square ?
How can i code this thing to know that ?

Code: Select all

; OS = Windows
; dpiX=1.0, dpiY=1.0, compiled with the option dpi aware or not.
; zoom 100%
; Resolution: 1024x768

ExamineDesktops()
ResolutionX.d=DesktopWidth(0)
ResolutionY.d=DesktopHeight(0)
Excentricity.d = ResolutionY/ResolutionX
; Excentricity.d = 1.0

If OpenWindow(0, 0, 0, 600, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	CanvasGadget(0, 0, 0, 600, 600)
	
	If StartVectorDrawing(CanvasVectorOutput(0))
		
		
		;cross
		MovePathCursor(300,0)
		AddPathLine(300, 600)
		MovePathCursor(0,300)
		AddPathLine(600, 300)
		StrokePath(1)	
		
		;red circle  -> shown as an ellipse in my screen
		MovePathCursor(300, 300)
		AddPathCircle(300, 300, 200)
		VectorSourceColor(RGBA(255, 0, 0, 255))
		StrokePath(3)
		
		
		;blue ellipse -> shown as a circle !
		MovePathCursor(300, 300)
		AddPathEllipse(300, 300, 300*Excentricity, 300) 
		VectorSourceColor(RGBA(0, 0, 255, 255))
		StrokePath(3)
		
		;marroon square shown as a rectangle
		AddPathBox(50, 50, 200, 200)
		VectorSourceColor(RGBA(128, 0, 0, 255))
		StrokePath(3)
		
		;Yellow rectangle shown as a square
		AddPathBox(50, 50, 200*Excentricity, 200)
		VectorSourceColor(RGBA(255, 255, 0, 255))
		StrokePath(3)
		
		StopVectorDrawing()
	EndIf
	
	;green Parametric equations of circle  -> shown as an ellipse
	StartDrawing(CanvasOutput(0))
	i.d=0
	Repeat
		a.d=Radian(i)
		x.d = 300 + 195*Cos(a)
		y.d = 300 + 195*Sin(a)
		Circle(x,y,2,#Green)
		i=i+1
	Until i>360
	
	;magenta Parametric equations of ellipse -> shown as a circle
	i.d=0
	Repeat
		a.d=Radian(i)
		x.d = 300 + 190*Cos(a)*Excentricity
		y.d = 300 + 190*Sin(a)
		Circle(x,y,2,#Magenta)
		i=i+1
	Until i>360
	
	
	StopDrawing()
	
	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow
EndIf
Thanks.

M.

Re: vector circles are ellipses on some computers

Posted: Sat Sep 17, 2022 11:17 am
by Little John
That's really strange. :x
Mesa, with which PureBasic version(s) do you encounter this issue?
Does it make a difference, whether in PB 6.00 you use the ASM backend or the new C backend?
(I'm just poking in the fog.)

Re: vector circles are ellipses on some computers

Posted: Sat Sep 17, 2022 11:50 am
by Olli
Could you test this and tell the results ?

Here, I get near 1.75 and 1.75

Code: Select all

Define.d ww,wh,dw,dh,dpiW,dpiH

dw = DesktopWidth(0 & ExamineDesktops() )
dh = DesktopHeight(0)

temp = OpenWindow(#PB_Any, 0,0,1,1,"", #PB_Window_Borderless | #PB_Window_Maximize | #PB_Window_Invisible)

ww = WindowWidth(temp)
wh = WindowHeight(temp)

CloseWindow(temp)

dpiW = dw / ww
dpiH = dh / wh

Debug dpiW
Debug dpiH

Re: vector circles are ellipses on some computers

Posted: Sat Sep 17, 2022 12:04 pm
by mk-soft
I haven't had that yet either ...
Or was it a very long time ago? ... Could be a stretching function of the monitor

Re: vector circles are ellipses on some computers

Posted: Sat Sep 17, 2022 9:33 pm
by netmaestro
Boot into safe mode and try it.

Re: vector circles are ellipses on some computers

Posted: Mon Sep 19, 2022 5:39 pm
by Mesa
Could be a stretching function of the monitor
Bingo !

I've changed the monitor and it works now.

Is there a way to prevent that with purebasic, in your opinion ?
Does WMI can get all characteristics of a monitor ?

Thanks for all, i tested all advices of this thread, nothing works.

M.

Re: vector circles are ellipses on some computers

Posted: Thu Sep 29, 2022 10:14 am
by Caronte3D
In the past some CRT monitors have non-square pixels by construction, maybe thi's the same case.

Re: vector circles are ellipses on some computers

Posted: Fri Sep 30, 2022 4:01 pm
by Mesa
@Caronte3D: I've a lcd monitor, not so old but the screen is stretched because the resolution is 1024x768 (4/3) in a 16/9 monitor and full screen, so circles are ellipses.
When i change the resolution to 1920x1080 (16/9) then everything is correct, circles are circles.

But it's a problem when users have a stretched screen and I don't see how to do without user intervention. :cry:

M.

Re: vector circles are ellipses on some computers

Posted: Fri Sep 30, 2022 5:19 pm
by mk-soft
Solution:
Hello User ... Buy a new monitor 8)

Or add user parameters for calibrate monitor

Re: vector circles are ellipses on some computers

Posted: Fri Sep 30, 2022 9:10 pm
by Caronte3D
mk-soft wrote: Fri Sep 30, 2022 5:19 pm Solution:
Hello User ... Buy a new monitor 8)

Or add user parameters for calibrate monitor
Best solution ever :D