Link to home
Start Free TrialLog in
Avatar of BdLm
BdLmFlag for Germany

asked on

PNG Image Lib , can't compile with D2010

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
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

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.
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;

Avatar of BdLm

ASKER

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 ???
 
 
ASKER CERTIFIED SOLUTION
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BdLm

ASKER

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 }