Skip to content

LockedPixels

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions
BlitzPlus

LockedPixels

LockedPixels:Int32 buffer:Int32=0
Parameter Mode Type Default Description
buffer In Int32 0 Locked buffer. Defaults to the current one.

Returns: The handle of a bank with the pixels.

Description

Gives the pixels of a locked buffer as a bank, so you can read and write them with PeekByte, PokeInt and friends, which is quicker than ReadPixel and WritePixel for many pixels. Change them, call UnlockBuffer and the changes show up in the buffer.

Differences

  • The bank is a copy of the pixels that is written back when the buffer is unlocked, it is not the memory of the graphics card. Nothing is changed before UnlockBuffer.
  • A buffer that Graphics3D made with the depth 30 has 4 bytes for each pixel in the form A2R10G10B10 (a 32 bit number), and one with the depth 64 has 8 bytes for each pixel with 16 bits for each of alpha, red, green and blue from the top (a 64 bit number). See Color depth.

Examples

Graphics 320, 240, 32, 2
win = CreateWindow("Gradient", 20, 20, 280, 190, Desktop(), 3)
cv  = CreateCanvas(10, 10, 256, 100, win)
buf = CanvasBuffer(cv)
LockBuffer buf
bank  = LockedPixels(buf)
pitch = LockedPitch(buf)
For y = 0 To 99
	For x = 0 To 255
		PokeInt bank, y * pitch + x * 4, $FF000000 Or (x Shl 16) Or (y * 2 Shl 8) Or (255 - x)
	Next
Next
UnlockBuffer buf
FlipCanvas cv
Repeat
Until WaitEvent() = $803

Media

LockedPixels

Related Commands

LockedFormat, LockedPitch

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally