Bits

Graphics32

TBitmap32.Bits

property Bits: PColor32Array; // Read-only

type TColor32Array = array [0..0] of TColor32;

type PColor32Array = ^TColor32Array;

Description

The bits property contains the address of the first (top-left) pixel in a bitmap. If the bitmap is not allocated (width or height is zero), the returned address is nil.

Note, that numbering of rows in Graphics32 starts from the top-most one.

Data is continuously allocated in memory, row by row. You may safely access Width * Height elements, each of them is a 4-byte TColor32 value. For example:

var

  P: PColor32Array;

begin

  P := Bitmap32.Bits;

  for I := 0 to Bitmap32.Width * Bitmap32.Height - 1 do

    P[I] := Gray32(Random(255)); // fill with a random grayscale noise

end;

Note, that in this code no size verification is required, if width or height is zero, their product is zero and the loop will never be executed.

See Also

TCustomMap.Height, PixelPtr, ScanLine, TColor32, TColor32Array, TCustomMap.Width