PNG Image Lib , can't compile with D2010

BdLm
BdLm used Ask the Experts™
on
I tried to compile the PNG image lib with delphi 2010 from http://pngdelphi.sourceforge.net  .
Compiler stops, because of can't assign a value to the left side error at this line:

      Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);

compile that lib and run with D7 has been no problem

procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte;
  Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
var
  Col: Integer;
begin
  {Get first column and enter in loop}
  Col := ColumnStart[Pass];
  Dest := pChar(Longint(Dest) + Col * 3);
  repeat
    {Copy this row}
    Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
    Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
    Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src)    )^]; inc(Dest);

    {Move to next column}
    inc(Src, 3);
    inc(Dest, ColumnIncrement[Pass] * 3 - 3);
    inc(Col, ColumnIncrement[Pass]);
  until Col >= ImageWidth;
end;

Open in new window

pngextra.pas
pngimage.pas
pnglang.pas
zlibpas.pas
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Quarter 2010
Expert of the Year 2010

Commented:
pngimage is native to Delphi 2009 and Delphi 2010.

In Codegear\rad studio\<6.0 or 7.0>\lib, there should be

zlib.dcu
zlibconst.dcu
pngimage.dcu
pnglang.dcu

And the library should be available to your IDE.
Expert of the Quarter 2010
Expert of the Year 2010

Commented:
To elaborate, you can add these to your uses clause:

gif, pngImage, jpeg

procedure TForm1.Button1Click(Sender: TObject);
var
  p: TPngImage;
begin
  Image1.Picture.LoadFromFile('C:\tmp.bmp');
  p := TPngImage.Create;
  p.Assign(image1.picture);
  p.SaveTofile('test.png');
end;

Author

Commented:
Thanks for your input!
 
a ) is the unit pngimage from my post above the one which is now part of delphi 2010 , 2009  ????
 
b) We use D7 and d2010 for software development, therefore would like to comple also the "older code" from my post..
 Any ideas on the compiler trouble ???
 
 
Freelance Project Manager
Top Expert 2010
Commented:
Replace pChar by pByte, it will work like a charm
procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte;
  Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pByte);
var
  Col: Integer;
begin
  {Get first column and enter in loop}
  Col := ColumnStart[Pass];
  Dest := pByte(Longint(Dest) + Col * 3);
  repeat
    {Copy this row}
    Dest^ := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
    Dest^ := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
    Dest^ := fOwner.GammaTable[pByte(Longint(Src)    )^]; inc(Dest);

    {Move to next column}
    inc(Src, 3);
    inc(Dest, ColumnIncrement[Pass] * 3 - 3);
    inc(Col, ColumnIncrement[Pass]);
  until Col >= ImageWidth;
end;

Open in new window

Author

Commented:
should I change this code in general of is this change D2010 specific ?
{$if def Delphi 7 }
....... some old code
 
{$endif }

{$if def Delphi 2010 }

.......   the new code  

 
{$endif }
 

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial