Stream.Write(Header, SizeOf(Header));
Filled := Boolean(Width mod 2);
if PixelFormat = pf8bit then
begin
try
for Y := 0 to Height - 1 do
begin
Line := ScanLine[Y];
Stream.WriteBuffer(Line^, Width);
if Filled then
begin
I := 0;
Stream.WriteBuffer(I, 1);
end;
end;
GetPaletteEntries(Palette, 0, 256, Pal.palPalEntry);
for I := 0 to 255 do
begin
Palarray[3*I] := Pal.palPalEntry[I].peRed;
Palarray[3*I+1] := Pal.palPalEntry[I].peGreen;
Palarray[3*I+2] := Pal.palPalEntry[I].peBlue;
end;
I := $C;
Stream.WriteBuffer(I, 1);
Stream.WriteBuffer(Palarray, SizeOf(Palarray));
finally
end;
end
else
begin
try
GetMem(RLine, Width);
GetMem(GLine, Width);
GetMem(BLine, Width);
for Y := 0 to Height - 1 do
begin
Line := ScanLine[Y];
for X := 0 to Width - 1 do
begin
RLine^ := Line^;
Inc(RLine);
Inc(Line);
GLine^ := Line^;
Inc(GLine);
Inc(Line);
BLine^ := Line^;
Inc(BLine);
Inc(Line);
end;
Dec(BLine, Width);
Stream.WriteBuffer(BLine^, Width);
if Filled then
begin
I := 0;
Stream.WriteBuffer(I, 1);
end;
Dec(GLine, Width)
Stream.WriteBuffer(BLine^, Width);
if Filled then
begin
I := 0;
Stream.WriteBuffer(I, 1);
end;
Dec(RLine, Width);
Stream.WriteBuffer(BLine^, Width);
if Filled then
begin
I := 0;
Stream.WriteBuffer(I, 1);
end;
end;
finally
if Assigned(RLine) then FreeMem(RLine);
if Assigned(GLine) then FreeMem(GLine);
if Assigned(BLine) then FreeMem(BLine);
end;
end;
end;