Delphi-Quellcode:
function RandomBitmap(Abmp:
VCL.Graphics.TBitmap;
const AWidth: Integer = 225;
const AHeight: Integer = 225): Boolean;
type
TRGB =
record
b, g, r: Byte;
end;
ARGB =
array [0 .. 1]
of TRGB;
PARGB = ^ARGB;
var
x, y: Integer;
p: PARGB;
begin
Result := False;
if (AWidth = 0)
or (AHeight = 0)
then
Exit(False);
Randomize;
if Abmp =
nil then
Abmp :=
Vcl.Graphics.TBitmap.Create;
try
Abmp.PixelFormat := pf24bit;
Abmp.Width := AWidth;
Abmp.Height := AHeight;
for y := 0
to (Abmp.Height - 1)
do
begin
p := Abmp.ScanLine[y];
for x := 0
to (Abmp.Width - 1)
do
begin
p[x].r := Random(High(Byte));
p[x].g := Random(High(Byte));
p[x].b := Random(High(Byte));
end;
end;
finally
Result := True;
end;
end;
minimal abgeändert, jedenfalls würde es so bei mir aussehen.