detecting the RGB pixel format mask

Started by kevin, August 02, 2007, 10:42:37 AM

Previous topic - Next topic

kevin

  Use GetSurfaceRGBMask() to detecting the RGB pixel format mask of a surface.
 

PlayBASIC Code: [Select]
 OpenScreen 800,600,16,2   
; OpenScreen 800,600,32,2

; Get the pixel format of this mode, then we just mask our colours against this.
Global RGBFormatMask=GetSurfaceRGBMask(0)



Do
cls rgb(0,0,0)

BoxColour=Rgb(255,0,255) And RGBFormatMask
BoxC 200,200,300,300,true,BoxColour


Mx=mouseX()
My=mouseY()

MouseOverColour=Point(mx,my) And RGBFormatMask

; draw mouse pointer
Dotc MX,MY,RGB(255,255,255)


print Hex$(BoxColour)
print Hex$(MouseOverCOlour)


if MouseOverColour=BoxColour
Print "You hit the box"
endif

Sync
loop





Function GetSurfaceRGBMask(ThisSurface)
; surface 0 is the screen
Depth=GetImageDepth(ThisSurface)

If Depth=15 then Mask=$00f8f8f8
If Depth=16 then Mask=$00f8fcf8
If Depth=24 then Mask=$00ffffff
If Depth=32 then Mask=$00ffffff

EndFunction Mask