Oddly, the square background appears black on the screen but white when I take a screen-shot.
This is the same for both retina and non-retina displays.
The sphere image (sphere.png):
Sierra:10.12.6
High Sierra:10.13.3
Code: Select all
; sphere.pb
; display a sphere on a transparent background
;
Procedure PreMultiply(image)
StartDrawing(ImageOutput(image))
DrawingMode(#PB_2DDrawing_AllChannels)
For j = 0 To ImageHeight(image)-1
For i = 0 To ImageWidth(image)-1
color = Point(i,j)
Plot(i, j, RGBA(Red(color) & $FF * Alpha(color) & $FF / $FF,
Green(color) & $FF * Alpha(color) & $FF / $FF,
Blue(color) & $FF * Alpha(color) & $FF / $FF,
Alpha(color)))
Next
Next
StopDrawing()
EndProcedure
ExamineDesktops()
Enumeration
#WINDOW_SPLASH
#SPLASH_MEMORY
EndEnumeration
UsePNGImageDecoder()
CatchImage(#SPLASH_MEMORY, ?Sphere)
size = ImageWidth(#SPLASH_MEMORY)
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
OpenWindow(#WINDOW_SPLASH, (DesktopWidth(0)-size)/2, (DesktopHeight(0)-size)/2, size, size, "", #PB_Window_BorderLess|#PB_Window_Invisible)
CopyImage(#SPLASH_MEMORY, #WINDOW_SPLASH)
CocoaMessage(0, WindowID(#WINDOW_SPLASH), "setBackgroundColor:", CocoaMessage(0, 0, "NSColor colorWithPatternImage:", ImageID(#WINDOW_SPLASH)))
CocoaMessage(0,WindowID(#WINDOW_SPLASH),"setHasShadow:",#YES)
HideWindow(#WINDOW_SPLASH, #False)
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
PreMultiply(#SPLASH_MEMORY)
OpenWindow(#WINDOW_SPLASH, (DesktopWidth(0)-size)/2, (DesktopHeight(0)-size)/2, size, size,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
SetWindowLongPtr_(WindowID(#WINDOW_SPLASH), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(#WINDOW_SPLASH), #GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TOOLWINDOW)
hDC = StartDrawing(ImageOutput(#SPLASH_MEMORY))
With sz.SIZE
\cx = ImageWidth(#SPLASH_MEMORY)
\cy = ImageHeight(#SPLASH_MEMORY)
EndWith
With BlendMode.BLENDFUNCTION
\SourceConstantAlpha = 255
\AlphaFormat = 1
EndWith
UpdateLayeredWindow_(WindowID(#WINDOW_SPLASH),0,0,@sz,hDC,@ContextOffset.POINT,0,@BlendMode,2)
StopDrawing()
CompilerEndIf
AddKeyboardShortcut(#WINDOW_SPLASH, #PB_Shortcut_Escape,2)
StartTime.q = ElapsedMilliseconds()
Repeat
If WaitWindowEvent(1) = #PB_Event_Menu And EventMenu() = 2
Break
EndIf
Until ElapsedMilliseconds() - StartTime > 10000
CloseWindow(#WINDOW_SPLASH)
End
DataSection
Sphere:
IncludeBinary "sphere.png"
EndDataSection