Page 1 of 1
[Done] PB v6.21 DrawText Outside of Visible Range
Posted: Mon Jun 23, 2025 9:12 pm
by mk-soft
On Windows, this leads to a crash. On macOS and Linux it works and the new x Position returned correctly.
With PB v6.20, this also works on Windows.
Code: Select all
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
Debug DrawText(-50, 400, "B!", $123456)
StopDrawing()
EndIf
[22:11:44] Waiting for executable to start...
[22:11:43] Executable type: Windows - x64 (64bit, Unicode)
[22:11:44] Executable started.
[22:11:44] [ERROR] Line: 2
[22:11:44] [ERROR] Invalid memory access. (write error at address 1957730877440)
Re: PB v6.21 DrawText Outside of Visible Range
Posted: Thu Jul 03, 2025 6:35 pm
by mk-soft
Workaround until this is repaired
Update v1.01.2
Code: Select all
;-TOP
;- *** PB v6.21 Workaround DrawText by mk-soft, v1.01.2, 03.07.2025 ***
; Link: https://www.purebasic.fr/english/viewtopic.php?t=87121
CompilerIf #PB_Compiler_OS = #PB_OS_Windows And #PB_Compiler_Version = 621
Procedure.d _FixDrawText(x.d, y.d, Text$, FrontColor=-1, BackColor=-1)
Protected r1.d, dx.d
dx = TextWidth(Text$)
If x + dx <= 0.0
;Debug "No DrawText"
ProcedureReturn x + dx
EndIf
If FrontColor <> -1
If BackColor <> -1
r1 = DrawText(x, y, Text$, FrontColor, BackColor)
Else
r1 = DrawText(x, y, Text$, FrontColor)
EndIf
Else
r1 = DrawText(x, y, Text$)
EndIf
ProcedureReturn r1
EndProcedure
Macro DrawText(x, y, Text, FrontColor=-1, BackColor=-1)
_FixDrawText(x, y, Text, FrontColor, BackColor)
EndMacro
CompilerEndIf
;- ***
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Beispiel", #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(300)-100, 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: [Done] PB v6.21 DrawText Outside of Visible Range
Posted: Fri Aug 01, 2025 10:24 am
by Fred
Fixed.
Re: [Done] PB v6.21 DrawText Outside of Visible Range
Posted: Fri Aug 01, 2025 2:09 pm
by diceman
Good to see you back at doing your thing.
