Why in the included Hello World example are the window created with openwindow and the image created with createimage different sizes when the same width and height have been specified?
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0, 0, 200, 200, RGB(255, 255, 255))
For i = 1 To 30
DrawText(Random(200), Random(200), "Hello World!", RGB(Random(255), Random(255), Random(255)))
Next i
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
another noob question - image sizes
Re: another noob question - image sizes
Why do you think the image is a different size?namrepus wrote: Tue May 23, 2023 3:14 am Why in the included Hello World example are the window created with openwindow and the image created with createimage different sizes when the same width and height have been specified?
If you resize the window, you can see the image the right size...
If you're referring to the window being slightly bigger due to borders, well; that's the borders...
-j
You should use code tags
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0, 0, 200, 200, RGB(255, 255, 255))
For i = 1 To 30
DrawText(Random(200), Random(200), "Hello World!", RGB(Random(255), Random(255), Random(255)))
Next i
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: another noob question - image sizes
Because the manual says this for window sizes with the OpenWindow() command:namrepus wrote: Tue May 23, 2023 3:14 amWhy in the included Hello World example are the window created with openwindow and the image created with createimage different sizes when the same width and height have been specified?
So your inner window size and image size are actually both 200 pixels, as shown by modifying your example with a red image border:Manual wrote:InnerWidth, InnerHeight: The required client area, in pixels (without borders and window decorations).
Code: Select all
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0, 0, 200, 200, RGB(255, 255, 255))
For i = 1 To 30
DrawText(Random(200), Random(200), "Hello World!", RGB(Random(255), Random(255), Random(255)))
Next i
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, 200, 200, #Red)
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: another noob question - image sizes
Do you have resolution scaling set to i.e. 125% or 150%? You can try with the scaled sizes:
Code: Select all
#SIZEXY = 400
If OpenWindow(0, 0, 0, #SIZEXY, #SIZEXY, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
scaledX = DesktopScaledX(#SIZEXY)
scaledY = DesktopScaledY(#SIZEXY)
If CreateImage(0, scaledX, scaledY) And StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0, 0, scaledX, scaledY, RGB(255, 255, 255))
For i = 1 To 30
DrawText(Random(scaledX), Random(scaledY), "Hello World!", RGB(Random(255), Random(255), Random(255)))
Next i
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, scaledX, scaledY, #Red)
StopDrawing()
ImageGadget(0, 0, 0, scaledX, scaledY, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: another noob question - image sizes
ok...
My bad.
Evidently it was something specific to my laptop at home as the computer at works shows everything as expected.
thanks for the help everyone.
I have another fun mystery
My bad.
Evidently it was something specific to my laptop at home as the computer at works shows everything as expected.
thanks for the help everyone.
I have another fun mystery

- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: another noob question - image sizes
Indeed, it might be the resolution scaling in that casenamrepus wrote: Wed May 24, 2023 12:48 pm ok...
My bad.
Evidently it was something specific to my laptop at home as the computer at works shows everything as expected.
thanks for the help everyone.
I have another fun mystery![]()
Re: another noob question - image sizes
was indeed screen scaling, thanks... important safety tip...