Page 2 of 2
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 7:18 pm
by wombats
That is odd. I tested it on Windows and macOS. Does it work if you clear the CanvasGadget on each redraw?
Code: Select all
Procedure SetWindowBackgroundImage(CanvasID.I, ImageID.I)
If StartDrawing(CanvasOutput(CanvasID))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(255, 255, 255))
DrawImage(ImageID(ImageID), 0, 0, GadgetWidth(CanvasID),
GadgetHeight(CanvasID))
StopDrawing()
EndIf
EndProcedure
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 7:24 pm
by Mijikai
Still get the same result.
Edit:
If i change your code like that it works
Code: Select all
UsePNGImageDecoder()
Procedure SetWindowBackgroundImage(CanvasID.I, ImageID.I)
If StartDrawing(CanvasOutput(CanvasID))
DrawImage(ImageID(ImageID), 0, 0, GadgetWidth(CanvasID),
GadgetHeight(CanvasID))
StopDrawing()
EndIf
EndProcedure
Procedure OnWindowResize()
ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0), WindowHeight(0))
SetWindowBackgroundImage(0, 0)
EndProcedure
; Procedure OnCanvasResize()
; SetWindowBackgroundImage(0, 0)
; EndProcedure
If LoadImage(0, #PB_Compiler_Home + "examples/3d/Data/Textures/spheremap.png")
OpenWindow(0, 100, 100, ImageWidth(0), ImageHeight(0),
"Window with background image", #PB_Window_SizeGadget)
CanvasGadget(0, 0, 0, ImageWidth(0), ImageHeight(0), #PB_Canvas_Container)
BindEvent(#PB_Event_SizeWindow, @OnWindowResize(), 0)
;BindGadgetEvent(0, @OnCanvasResize(), #PB_EventType_Resize)
SetWindowBackgroundImage(0, 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 7:34 pm
by wombats
Interesting. I wonder why my code works for me on Windows and macOS and not for you.
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 7:37 pm
by Mijikai
Im currently on Windows 7 x64 using PureBasic is 5.62
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 7:45 pm
by wombats
That would be why. I just tested it in 5.61 and it didn't work properly. I believe some bugs with the CanvasGadget were fixed in recent versions.
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 8:21 pm
by Mijikai
wombats wrote:That would be why. I just tested it in 5.61 and it didn't work properly. I believe some bugs with the CanvasGadget were fixed in recent versions.
Does the code i posted run for you ?
Newer PB versions are unusable for me (unresolved #Null$ memory bug and i use strings always somewhere).
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 8:55 pm
by wombats
Mijikai wrote:wombats wrote:That would be why. I just tested it in 5.61 and it didn't work properly. I believe some bugs with the CanvasGadget were fixed in recent versions.
Does the code i posted run for you ?
Newer PB versions are unusable for me (unresolved #Null$ memory bug and i use strings always somewhere).
Yes, it does. I don't know anything about #Null$.
Re: A simple resizable image as window bg
Posted: Sun Jun 02, 2019 9:39 pm
by Mijikai
wombats wrote:I don't know anything about #Null$.
The Bug:
viewtopic.php?p=531591#p531591