It is currently Mon Sep 23, 2019 1:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 7:18 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
That is odd. I tested it on Windows and macOS. Does it work if you clear the CanvasGadget on each redraw?
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 7:24 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 520
Still get the same result.

Edit:

If i change your code like that it works
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 7:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
Interesting. I wonder why my code works for me on Windows and macOS and not for you.


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 7:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 520
Im currently on Windows 7 x64 using PureBasic is 5.62


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 7:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 8:21 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 520
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 8:55 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
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$.


Top
 Profile  
Reply with quote  
 Post subject: Re: A simple resizable image as window bg
PostPosted: Sun Jun 02, 2019 9:39 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 520
wombats wrote:
I don't know anything about #Null$.


The Bug: https://www.purebasic.fr/english/viewtopic.php?p=531591#p531591


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye