Question : can#t Compile PNG Image Lib

not sure how to adjust this code to work with D7 compiler and D2010 compiler
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
{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;
Attachments:
 
version of PNG image lib, for D7 and D2010
 

Answer : can#t Compile PNG Image Lib

same solution as the other problem : replace pChar with pByte
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
{Copy ímages with palette using bit depths 1, 4 or 8}
procedure TChunkIDAT.CopyInterlacedPalette148(const Pass: Byte;
  Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pByte); //<== HERE
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: pByte;  //<== HERE
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 := pByte(Longint(Dest) + (Header.BitDepth * Col) div 8); //<== HERE
   {Copy data}
// Now you can use Src^ and Dest2^ as bytes without casting
   Dest2^ := Dest2^ or
     ( ((Src^ shr CurBit) and BitTable[Header.BitDepth]) shl 
        (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8)));
   {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;
Random Solutions  
 
programming4us programming4us