// Display 16 color bars in a pf4bit bitmap // efg, 6 October 1998 procedure TForm1.ButtonPf4bitClick(Sender: TObject); VAR Bitmap: TBitmap; i,j : INTEGER; m : INTEGER; row : pByteArray; // each pixel is a "nibble" (that is, a half byte) begin Bitmap := TBitmap.Create; TRY Bitmap.Width := Image1.Width; Bitmap.Height := Image1.Height; // Should be multiple of 16 Bitmap.PixelFormat := pf4bit; // 16 colors FOR j := 0 TO Bitmap.Height-1 DO BEGIN m := j DIV 16; // 16 bands: 0 .. 15 row := Bitmap.Scanline[j]; FOR i := 0 TO Bitmap.Width DIV 2 - 1 DO // 2 pixels per byte BEGIN row[i] := m + {low nibble pixel} (m SHL 4); {high nibble pixel} END END; Image1.Picture.Graphic := Bitmap FINALLY Bitmap.Free END end;