GetBufferPitch

Top  Previous  Next

Syntax

UINT  = GetBufferPitch(OPT buffer as POINTER)

Description

Returns the pitch, or bytes per line, of the buffer specified.

Parameters

buffer - Optional. Can be either BACKBUFFER (default) or FRONTBUFFER

Return value

The pitch of the buffer

Remarks

Used for direct memory access of a screen buffer. The buffer must be locked first with the LockBuffer command and unlocked with the UnlockBuffer command after access is completed. You must be sure never to write outside the confines of the buffer.

See Also: LockBuffer, UnlockBuffer, GetBufferPointer

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