RGBToScreen

Top  Previous  Next

Syntax

UINT = RGBToScreen(col as UINT)

Description

Converts an RGB color to the format used by the currently open screen.

Parameters

col - Color to convert

Return value

The color in the correct pixel format to be directly written to memory.

Remarks

Used for direct memory access. When storing a color directly into buffer memory it must be converted to the correct pixel format first. For 8 bit screens this function is not necessary.

See Also: GETBUFFERPOINTER, GETBUFFERPITCH

Example usage

DEF buffer as POINTER
IF(CREATESCREEN(800,600,32) < 0)
    MESSAGEBOX 0,"Error creating screen","Error"
ENDIF
 
DO
    FillScreen 0
    ' turn the pixel at 100,200 blue
    LockBuffer
    buffer = GetBufferPointer
    pitch = GetBufferPitch
    buffer += (200 * pitch) + (100 * 4)
    #<UINT>buffer = RGBToScreen(RGB(0,0,255))
    Unlockbuffer
    WriteText 0,0,"Press Left MouseButton to Close"
    FLIP
UNTIL GetKeyState(0x01)
CLOSESCREEN
END