b2dSetImagePixels

Category: 2D Overlay

Syntax:

b2dSetImagePixels:Void(imageHandle:Int, pixels:Int[], width:Int, height:Int)


Parameters

Returns

Void



Summary

Copies a whole Int array into an image in one call: one $AARRGGBB Int per pixel.

View detailed documentation online



Example
Global pix:Int[76800]                  ; 320 x 240

Function Main()
    b2dGraphics(640, 480, BBR_WINDOW_MODE_WT)
    Local img:Int = b2dCreateRenderTarget(320, 240, 0, 0, 0, 1.0)
    b2dSetImageSmooth(img, False)
    Local x:Int, y:Int, frame:Int
    While inpIsKeyDown(VKEY_ESCAPE) = False
        sysUpdateEvents()
        For y = 0 To 239
            For x = 0 To 319
                pix[y * 320 + x] = $FF000000 + (((x + frame) BitXor y) BitAnd 255)
            Next
        Next
        b2dSetImagePixels(img, pix, 320, 240)
        b2dCls()
        b2dDrawImageQuad(img, 0, 0, 640, 0, 640, 480, 0, 480)
        b2dFlip()
        frame = frame + 1
    Wend
    Return False
EndFunction

BambooBasic © 2026 Michael Denathorn