If you use SetWindowColor() to change the window's background color
this code won't detect the changed background color of a window or
gadget. You would have to define your own GTK style and apply it to
window and gadgets for this code to work.
I have tried a somewhat different approach by grabbing the window
background under the ImageGadget and combining it with a transparent
PNG image:
Code: Select all
ImportC "-lz" : EndImport
UsePNGImageDecoder()
Define Filename.S
InitNetwork()
ReceiveHTTPFile("http://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/300px-PNG_transparency_demonstration_1.png", GetCurrentDirectory() + "WikipediaTransparentTestImage.png")
If LoadImage(0, GetCurrentDirectory() + "WikipediaTransparentTestImage.png")
  OpenWindow(0, 100, 100, ImageWidth(0) + 25, ImageHeight(0) + 25, "Display transparent PNG image")
  SetWindowColor(0, RGBA(226, 199, 182, 255))
  ; ----- Wait until background color is applied
  Delay(20)
  While WindowEvent() : Wend
  ; ----- Grab background from window
  StartDrawing(WindowOutput(0))
    GrabDrawingImage(1, 10, 10, ImageWidth(0), ImageHeight(0))
  StopDrawing()
  ; ----- Draw transparent PNG image into background image
  StartDrawing(ImageOutput(1))
    DrawAlphaImage(ImageID(0), 0, 0, 255)
  StopDrawing()
  ImageGadget(0, 10, 10, ImageWidth(0), ImageHeight(0), ImageID(1), #PB_Image_Border)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
      Case  #PB_Event_Gadget
        If EventGadget() = 0
          If EventType() = #PB_EventType_LeftClick
            Debug "Left click onto image detected!"
          EndIf
        EndIf
    EndSelect
  ForEver
EndIfand OpenSuSE 12.1.
