[SB 1.30 FINAL] Resize ImageGadget?

Just starting out? Need help? Post your questions and find answers here.
bmon
Posts: 18
Joined: Thu Jun 04, 2015 4:21 pm

[SB 1.30 FINAL] Resize ImageGadget?

Post by bmon »

Howdy ... Does the resizing of gadgets work for image gadgets as well? Here is a short example and thanks for the help!

Code: Select all

EnableExplicit

Enumeration
  #WINDOW_ID
  #IMAGE_ID
  #GADGET_IMAGE_1
  #GADGET_IMAGE_2
EndEnumeration

ExamineDesktops()
If OpenWindow(#WINDOW_ID,0,0,DesktopWidth(0),DesktopHeight(0),"Resize Gadget Test",#PB_Window_BorderLess)
  If CreateImage(#IMAGE_ID,150,150)
    ; DRAW SOMETHING ON THE IMAGE
    StartDrawing(ImageOutput(#IMAGE_ID))
    Box(0,0,150,150,RGB(128,128,128))
    Box(10,10,50,50,RGB(255,0,0))
    Box(50,50,70,70,RGB(0,255,0))
    Circle(95,95,40,RGB(0,0,255))
    StopDrawing()
  EndIf
  
  If IsImage(#IMAGE_ID)
    If ImageGadget(#GADGET_IMAGE_1,100,100,150,150,ImageID(#IMAGE_ID)) = 0
      Debug "Can't create gadget 1"
    EndIf
    
    ; LETS CREATE A SECOND GADGET WITH THE SAME IMAGE AND SIZE AND PLACE IT TO THE RIGHT OF THE FIRST
    If ImageGadget(#GADGET_IMAGE_2,260,100,150,150,ImageID(#IMAGE_ID)) = 0
      Debug "Can't create gadget 2"
    Else
      ; NOW LET'S RESIZE THIS SECOND GADGET BY 50%
      ResizeGadget(#GADGET_IMAGE_2,#PB_Ignore,#PB_Ignore,75,75)
    EndIf
  EndIf
EndIf
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: [SB 1.30 FINAL] Resize ImageGadget?

Post by Fred »

No, an image gadget doens't resize the inner image and doesn't clip it as well.
cameo
Posts: 3
Joined: Fri Jul 25, 2025 4:59 am

Re: [SB 1.30 FINAL] Resize ImageGadget?

Post by cameo »

Fred wrote: Thu Jul 28, 2016 10:11 am No, an image gadget doens't resize the inner image and doesn't clip it as well.
I know this comment was made in 2016, but is it still true, because the simple code below shows that resizing an image gadget in response to resizing a window does resize the image it contains. Any clarification appreciated. Using SB 3.10 beta 2.

Code: Select all

Enumeration
  #Window
  #ImageGadget
  #Image
EndEnumeration

Procedure Loaded(Type, Filename$, ObjectId)
  OpenWindow (#Window,     10, 10, ImageWidth(ObjectId), ImageHeight(ObjectId), "Resize ImageGadget() Test", #PB_Window_SizeGadget)
  ImageGadget(#ImageGadget, 0,  0, ImageWidth(ObjectId), ImageHeight(ObjectId), ImageID(ObjectId))  
EndProcedure

Procedure LoadingError(Type, Filename$, ObjectId)
  Debug Filename$ + ": loading error"
EndProcedure

Procedure SizeWindowHandler()
  ResizeGadget(#ImageGadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window))
EndProcedure

BindEvent(#PB_Event_Loading,      @Loaded())
BindEvent(#PB_Event_LoadingError, @LoadingError())
BindEvent(#PB_Event_SizeWindow,   @SizeWindowHandler(), #Window)

LoadImage(#Image, "Data/SpiderBasicLogo.png")
Post Reply