{Copy ímages with palette using bit depths 1, 4 or 8}
procedure TChunkIDAT.CopyInterlacedPalette148(const Pass: Byte;
Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
const
BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF);
StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0);
var
CurBit, Col: Integer;
Dest2: PChar;
begin
{Get first column and enter in loop}
Col := ColumnStart[Pass];
repeat
{Copy data}
CurBit := StartBit[Header.BitDepth];
repeat
{Adjust pointer to pixel byte bounds}
Dest2 := pChar(Longint(Dest) + (Header.BitDepth * Col) div 8);
{Copy data}
{$IFDEF VER210}
Dest2^ := Dest2^ or
( ((Byte(Src^) shr CurBit) and BitTable[Header.BitDepth])
shl (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8))); /// <- bug using Delphi 2010 ....
{$else}
Byte(Dest2^) := Byte(Dest2^) or
( ((Byte(Src^) shr CurBit) and BitTable[Header.BitDepth])
shl (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8)));
{$endif}
{Move to next column}
inc(Col, ColumnIncrement[Pass]);
{Will read next bits}
dec(CurBit, Header.BitDepth);
until CurBit < 0;
{Move to next byte in source}
inc(Src);
until Col >= ImageWidth;
end;
|