Possible RGBA bug (all OS's?)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 124
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Possible RGBA bug (all OS's?)

Post by Erlend »

Hello everyone

Tested this code on Ubuntu / Mac and Windows, seems RGBA(255,255,255,255) will result in -1 on
Ubuntu and Mac, while Windows also has this weird anomaly, also check result of all RGBA(0,0,0,0) and the wierd
result of last 19-1 (see column "i") of column "rA"

Can someone else confirm on their systems?

Code: Select all

OpenWindow(0,0,0,500,500,"")
ListIconGadget(0,0,0,400,400,"i",45,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"grey",45)
AddGadgetColumn(0,2,"r",45)
AddGadgetColumn(0,3,"g",45)
AddGadgetColumn(0,4,"b",45)
AddGadgetColumn(0,5,"grayA",45)
AddGadgetColumn(0,6,"rA",45)
AddGadgetColumn(0,7,"gA",45)
AddGadgetColumn(0,8,"bA",45)


For i=0 To 255
  c=255-i
  AddGadgetItem(0,i,Str(c)+""+Chr(10)+""+Chr(10)+""+Chr(10)+"")
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(c,c,c),1)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(c,0,0),2)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(0,c,0),3)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(0,0,c),4)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGBA(c,c,c,255),5)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGBA(c,0,0,255),6)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGBA(0,c,0,255),7)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGBA(0,0,c,255),8)
Next 

Repeat
  event=WaitWindowEvent()  
Until event=#PB_Event_CloseWindow
Best regards
Erlend
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Possible RGBA bug (all OS's?)

Post by infratec »

Your example can not work.

Where is written that the ListIconGadget() or SetGadgetItemColor() can handle RGBA() :?:
They don't use an alpha channel.

Code: Select all

OpenWindow(0,0,0,800,600,"")

If CreateImage(0, 800, 600, 32)
  If StartDrawing(ImageOutput(0))
    ;DrawingMode(#PB_2DDrawing_AllChannels)
    
    For i=0 To 255
      c=255-i
      Box(0, i * 2, 100, 2, RGB(c,c,c))
      Box(100, i * 2, 100, 2, RGB(c,0,0))
      Box(200, i * 2, 100, 2, RGB(0,c,0))
      Box(300, i * 2, 100, 2, RGB(0,0,c))
      Box(400, i * 2, 100, 2, RGBA(c,c,c,255))
      Box(500, i * 2, 100, 2, RGBA(c,0,0,255))
      Box(600, i * 2, 100, 2, RGBA(0,c,0,255))
      Box(700, i * 2, 100, 2, RGBA(0,0,c,255))
    Next i
    
    StopDrawing()
  EndIf
EndIf

ImageGadget(0, 0, 0, 0, 0, ImageID(0))

Repeat
  event=WaitWindowEvent()  
Until event=#PB_Event_CloseWindow
If you enable DrawingMode(#PB_2DDrawing_AllChannels), than the RGB values are white, because they are fully transparent (0)
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Possible RGBA bug (all OS's?)

Post by infratec »

Code: Select all

For i=0 To 255
  c = 255 - i
  Debug RSet(Hex(RGB(c,c,c), #PB_Long), 8, "0")
  Debug RSet(Hex(RGB(c,0,0), #PB_Long), 8, "0")
  Debug RSet(Hex(RGB(0,c,0), #PB_Long), 8, "0")
  Debug RSet(Hex(RGB(0,0,c), #PB_Long), 8, "0")
  Debug RSet(Hex(RGBA(c,c,c,255), #PB_Long), 8, "0")
  Debug RSet(Hex(RGBA(c,0,0,255), #PB_Long), 8, "0")
  Debug RSet(Hex(RGBA(0,c,0,255), #PB_Long), 8, "0")
  Debug RSet(Hex(RGBA(0,0,c,255), #PB_Long), 8, "0")
  Debug ""
Next i
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Possible RGBA bug (all OS's?)

Post by infratec »

Code: Select all

Macro RGBMacro(r, g, b)
  (b << 16 | g << 8 | r)
EndMacro

Macro RGBAMacro(r, g, b, a)
  (a << 24 | b << 16 | g << 8 | r)
EndMacro

Debug RSet(Hex(RGBMacro($12, $34, $56), #PB_Long), 8, "0")
Debug RSet(Hex(RGBAMacro($12, $34, $56, $FF), #PB_Long), 8, "0")
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 124
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: Possible RGBA bug (all OS's?)

Post by Erlend »

Apparently so, because of the results on Linux and Mac with only RGBA(255,255,255,255) being the one to fail
I thought it was NOT related to the listicongadget but RGBA :oops: , thanks for checking :D

Best regards
Erlend
Post Reply