Rectangle 27 0

delphi How do I draw with scanlines without loading an image first?


PixelFormat
procedure TForm1.FormPaint(Sender: TObject);
var
  bm: TBitmap;
  y: Integer;
  sl: PRGBQuad;
  x: Integer;
begin

  bm := TBitmap.Create;
  try
    bm.SetSize(1024, 1024);
    bm.PixelFormat := pf32bit;
    for y := 0 to bm.Height - 1 do
    begin
      sl := bm.ScanLine[y];
      for x := 0 to bm.Width - 1 do
      begin
        sl.rgbBlue := 255 * x div bm.Width;
        sl.rgbRed := 255 * y div bm.Height;
        sl.rgbGreen := 255 * x div bm.Width;
        inc(sl);
      end;
    end;

    Canvas.Draw(0, 0, bm);
  finally
    bm.Free;
  end;

end;
Note