b2dSetImagePixels

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

2D Overlay

Parameters & Returns

Parameters

imageHandle Int
pixels Int[]
width Int
height Int

Returns

Void

Quick Summary

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

Technical Exegesis...

Sets every pixel of the image from an Int array, row by row from the top left: pixels[y * width + x]. Each Int is a colour as $AARRGGBB, with the alpha in the top byte ($FF000000 is solid). width and height must be the image's own size; if they aren't, nothing changes and an error is printed.

Example

Example.bam
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