PureBasic Forum
https://www.purebasic.fr/english/

Disabled ButtonImageGadget() not shown OK with JPG files
https://www.purebasic.fr/english/viewtopic.php?f=4&t=76149
Page 1 of 1

Author:  AMpos [ Sat Oct 24, 2020 12:50 am ]
Post subject:  Disabled ButtonImageGadget() not shown OK with JPG files

Code:
OpenWindow(0,200,200,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

UseJPEGImageDecoder():UsePNGImageDecoder()

i=LoadImage(-1,OpenFileRequester("Choose an JPG or PNG file","","",0))

ButtonImageGadget(0,0,0,80,80,ImageID(i))
ButtonImageGadget(1,100,0,80,80,ImageID(i))
DisableGadget(1,1)

Repeat
   event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow


If a ImageButton is disabled with a PNG image, the image is shown in grey color. But a JPG image-button disabled, is shown... a mess.

Tested only in Windows.

Author:  chi [ Sat Oct 24, 2020 2:55 am ]
Post subject:  Re: Disabled ButtonImageGadget() not shown OK with JPG files

The image needs to be 32bit...
Code:
OpenWindow(0,200,200,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

; UseJPEGImageDecoder():UsePNGImageDecoder()
; i=LoadImage(-1,OpenFileRequester("Choose an JPG or PNG file","","",0))

depth = 32;24;

i=CreateImage(#PB_Any, 40, 40, depth, #PB_Image_Transparent)
StartDrawing(ImageOutput(i))
  DrawingMode(#PB_2DDrawing_AllChannels)
  Box(10, 10, 20, 20, RGBA(255, 0, 0, 255))
  Circle(10, 10, 10, RGBA(0, 0, 255, 255))
StopDrawing()

ButtonImageGadget(0,0,0,80,80,ImageID(i))
ButtonImageGadget(1,100,0,80,80,ImageID(i))
DisableGadget(1,1)

Repeat
   event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow

Author:  Saki [ Sat Oct 24, 2020 6:59 pm ]
Post subject:  Re: Disabled ButtonImageGadget() not shown OK with JPG files

Hi, no, this works different
Not a bug

Code:
OpenWindow(0,200,200,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

UseJPEGImageDecoder()
UsePNGImageDecoder()

path$=OpenFileRequester("Choose an JPG or PNG file","","",0)
If path$="" : End : EndIf
i=LoadImage(#PB_Any,path$)

ResizeImage(i, 80, 80)

ii=CreateImage(#PB_Any, 80, 80, 32)
StartDrawing(ImageOutput(ii))
DrawingMode(#PB_2DDrawing_AllChannels)
DrawAlphaImage(ImageID(i), 0, 0)
StopDrawing()

ButtonImageGadget(0,0,0,80,80,ImageID(ii))
ButtonImageGadget(1,100,0,80,80,ImageID(ii))
DisableGadget(1,1)

Repeat
  event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow


Or with colored background, this is recommended
Code:
OpenWindow(0,200,200,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

UseJPEGImageDecoder()
UsePNGImageDecoder()

path$=OpenFileRequester("Choose an JPG or PNG file","","",0)
If path$="" : End : EndIf
i=LoadImage(#PB_Any,path$)

ResizeImage(i, 80, 80)

ii=CreateImage(#PB_Any, 80, 80, 32, #White)
StartDrawing(ImageOutput(ii))
DrawAlphaImage(ImageID(i), 0, 0)
StopDrawing()

ButtonImageGadget(0,0,0,80,80,ImageID(ii))
ButtonImageGadget(1,100,0,80,80,ImageID(ii))
DisableGadget(1,1)

Repeat
  event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow

Author:  AMpos [ Sat Oct 24, 2020 11:54 pm ]
Post subject:  Re: Disabled ButtonImageGadget() not shown OK with JPG files

Thx!

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/