From 12a7652fe6cf20441dec4aae8156978bf751861f Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 18 Sep 2007 10:47:12 +0000 Subject: pngimage is NOT ( yet ) lazarus compatible It might compile, however the object files are in borland obj format to use this, it will need to be in GCC object file format format Or we can use the lazarus / freepascal png unit if we decide that pngimage IS required ( and we cant use the lazarus unit ) then we should investigate how this developer went with the port. http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&t=3206 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@388 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/lib/PngImage/lazarustest.lpi | 239 +++++++++++++++++++++++++++++++++ Game/Code/lib/PngImage/lazarustest.lpr | 15 +++ Game/Code/lib/PngImage/pngimage.pas | 58 ++++---- Game/Code/lib/PngImage/pngzlib.pas | 41 +++--- 4 files changed, 309 insertions(+), 44 deletions(-) create mode 100644 Game/Code/lib/PngImage/lazarustest.lpi create mode 100644 Game/Code/lib/PngImage/lazarustest.lpr diff --git a/Game/Code/lib/PngImage/lazarustest.lpi b/Game/Code/lib/PngImage/lazarustest.lpi new file mode 100644 index 00000000..4dec8a9e --- /dev/null +++ b/Game/Code/lib/PngImage/lazarustest.lpi @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Game/Code/lib/PngImage/lazarustest.lpr b/Game/Code/lib/PngImage/lazarustest.lpr new file mode 100644 index 00000000..f567b6cb --- /dev/null +++ b/Game/Code/lib/PngImage/lazarustest.lpr @@ -0,0 +1,15 @@ +program lazarustest; + +uses + pngimage in 'pngimage.pas', + pnglang in 'pnglang.pas', + pngzlib in 'pngzlib.pas', + sysutils; + +begin + writeln( 'pngimage is NOT lazarus compatible' ); + writeln( 'It might compile ( not link though ), however the object files are in borland obj format' ); + writeln( 'to use this, it will need to be in GCC object file format format' ); + writeln( 'Or we can use the lazarus / freepascal png unit' ); +end. + diff --git a/Game/Code/lib/PngImage/pngimage.pas b/Game/Code/lib/PngImage/pngimage.pas index ec712737..ecd52c5b 100644 --- a/Game/Code/lib/PngImage/pngimage.pas +++ b/Game/Code/lib/PngImage/pngimage.pas @@ -109,8 +109,15 @@ unit pngimage; interface +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + {Triggers avaliable (edit the fields bellow)} +{$IFNDef FPC} {$DEFINE UseDelphi} //Disable fat vcl units (perfect to small apps) +{$ENDIF} + {$DEFINE ErrorOnUnknownCritical} //Error when finds an unknown critical chunk {$DEFINE CheckCRC} //Enables CRC checking {$DEFINE RegisterGraphic} //Registers TPNGObject to use with TPicture @@ -122,8 +129,17 @@ interface uses - Windows {$IFDEF UseDelphi}, Classes, Graphics, SysUtils{$ENDIF} {$IFDEF Debug}, - dialogs{$ENDIF}, pngzlib, pnglang; + Windows, + {$IFDEF UseDelphi} + Classes, + Graphics, + SysUtils, + {$ENDIF} + {$IFDEF Debug} + dialogs, + {$ENDIF} + pngzlib, + pnglang; {$IFNDEF UseDelphi} const @@ -1249,8 +1265,7 @@ begin if Output = nil then GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize); {Copies the new data} - CopyMemory(Ptr(Longint(Output) + OutputSize - total_out), - @Buffer, total_out); + CopyMemory(pointer(Longint(Output) + OutputSize - total_out), @Buffer, total_out); end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)} {Now tests for errors} else if InflateRet < 0 then @@ -1309,8 +1324,7 @@ begin GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize); {Copies the new data} - CopyMemory(Ptr(Longint(Output) + OutputSize - total_out), - @Buffer, total_out); + CopyMemory(Pointer(Longint(Output) + OutputSize - total_out), @Buffer, total_out); end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)} {Now tests for errors} else if DeflateRet < 0 then @@ -1676,7 +1690,7 @@ function TStream.GetSize: Longint; function TResourceStream.Read(var Buffer; Count: Integer): Cardinal; begin //Returns data - CopyMemory(@Buffer, Ptr(Longint(Memory) + Position), Count); + CopyMemory(@Buffer, pointer(Longint(Memory) + Position), Count); //Update position inc(Position, Count); //Returns @@ -1938,9 +1952,9 @@ begin if Keyword <> '' then CopyMemory(Data, @fKeyword[1], Length(Keyword)); {Compression method 0 (inflate/deflate)} - pByte(Ptr(Longint(Data) + Length(Keyword) + 1))^ := 0; + pByte(pointer(Longint(Data) + Length(Keyword) + 1))^ := 0; if OutputSize > 0 then - CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 2), Output, OutputSize); + CopyMemory(pointer(Longint(Data) + Length(Keyword) + 2), Output, OutputSize); {Let ancestor calculate crc and save} Result := SaveData(Stream); @@ -1969,8 +1983,7 @@ begin {Get text} fKeyword := PChar(Data); SetLength(fText, Size - Length(fKeyword) - 1); - CopyMemory(@fText[1], Ptr(Longint(Data) + Length(fKeyword) + 1), - Length(fText)); + CopyMemory(@fText[1], pointer(Longint(Data) + Length(fKeyword) + 1), Length(fText)); end; {Saving the chunk to a stream} @@ -1984,8 +1997,7 @@ begin if Keyword <> '' then CopyMemory(Data, @fKeyword[1], Length(Keyword)); if Text <> '' then - CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 1), @fText[1], - Length(Text)); + CopyMemory(pointer(Longint(Data) + Length(Keyword) + 1), @fText[1], Length(Text)); {Let ancestor calculate crc and save} Result := inherited SaveToStream(Stream); end; @@ -2819,12 +2831,10 @@ begin {Get current row index} CurrentRow := RowStart[CurrentPass]; {Get a pointer to the current row image data} - Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow * - (ImageHeight - 1 - CurrentRow)); - Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); + Data := pointer(Longint(Header.ImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow)); + Trans := pointer(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); {$IFDEF Store16bits} - Extra := Ptr(Longint(Header.ExtraImageData) + Header.BytesPerRow * - (ImageHeight - 1 - CurrentRow)); + Extra := pointer(Longint(Header.ExtraImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow)); {$ENDIF} if Row_Bytes > 0 then {There must have bytes for this interlaced pass} @@ -3808,9 +3818,8 @@ begin {Get current row index} CurrentRow := RowStart[CurrentPass]; {Get a pointer to the current row image data} - Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow * - (ImageHeight - 1 - CurrentRow)); - Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); + Data := pointer(Longint(Header.ImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow)); + Trans := pointer(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); {Process all the image rows} if Row_Bytes > 0 then @@ -4021,9 +4030,9 @@ begin FOR j := 0 TO fCount - 1 DO with BitmapInfo.bmiColors[j] do begin - DataPtr^ := Owner.InverseGamma[rgbRed]; inc(DataPtr); + DataPtr^ := Owner.InverseGamma[rgbRed] ; inc(DataPtr); DataPtr^ := Owner.InverseGamma[rgbGreen]; inc(DataPtr); - DataPtr^ := Owner.InverseGamma[rgbBlue]; inc(DataPtr); + DataPtr^ := Owner.InverseGamma[rgbBlue] ; inc(DataPtr); end {with BitmapInfo}; {Let ancestor do the rest of the work} @@ -5100,8 +5109,7 @@ begin (X mod (8 div DataDepth)) * DataDepth)); {Setting the new pixel} - ByteData^ := ByteData^ or (ValEntry shl ((8 - DataDepth) - - (X mod (8 div DataDepth)) * DataDepth)); + ByteData^ := ByteData^ or (ValEntry shl ((8 - DataDepth) - (X mod (8 div DataDepth)) * DataDepth)); end {with png.Header} end; diff --git a/Game/Code/lib/PngImage/pngzlib.pas b/Game/Code/lib/PngImage/pngzlib.pas index 12324f2c..3155946a 100644 --- a/Game/Code/lib/PngImage/pngzlib.pas +++ b/Game/Code/lib/PngImage/pngzlib.pas @@ -6,6 +6,10 @@ unit pngzlib; +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + interface type @@ -35,14 +39,12 @@ type reserved: Integer; // reserved for future use end; -function inflateInit_(var strm: TZStreamRec; version: PChar; - recsize: Integer): Integer; forward; -function inflate(var strm: TZStreamRec; flush: Integer): Integer; forward; -function inflateEnd(var strm: TZStreamRec): Integer; forward; -function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; - recsize: Integer): Integer; forward; -function deflate(var strm: TZStreamRec; flush: Integer): Integer; forward; -function deflateEnd(var strm: TZStreamRec): Integer; forward; +function inflateInit_(var strm: TZStreamRec; version: PChar; recsize: Integer): Integer; // forward; +function inflate(var strm: TZStreamRec; flush: Integer): Integer; //forward; +function inflateEnd(var strm: TZStreamRec): Integer; //forward; +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; recsize: Integer): Integer; //forward; +function deflate(var strm: TZStreamRec; flush: Integer): Integer; //forward; +function deflateEnd(var strm: TZStreamRec): Integer; //forward; const zlib_version = '1.1.4'; @@ -97,15 +99,17 @@ const implementation -{$L obj\deflate.obj} -{$L obj\trees.obj} -{$L obj\inflate.obj} -{$L obj\inftrees.obj} -{$L obj\adler32.obj} -{$L obj\infblock.obj} -{$L obj\infcodes.obj} -{$L obj\infutil.obj} -{$L obj\inffast.obj} +{$IFNDef FPC} + {$L obj\deflate.obj} + {$L obj\trees.obj} + {$L obj\inflate.obj} + {$L obj\inftrees.obj} + {$L obj\adler32.obj} + {$L obj\infblock.obj} + {$L obj\infcodes.obj} + {$L obj\infutil.obj} + {$L obj\inffast.obj} +{$ENDIF} procedure _tr_init; external; procedure _tr_tally; external; @@ -146,8 +150,7 @@ function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; function deflateEnd(var strm: TZStreamRec): Integer; external; // inflate decompresses data -function inflateInit_(var strm: TZStreamRec; version: PChar; - recsize: Integer): Integer; external; +function inflateInit_(var strm: TZStreamRec; version: PChar; recsize: Integer): Integer; external; function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; function inflateEnd(var strm: TZStreamRec): Integer; external; function inflateReset(var strm: TZStreamRec): Integer; external; -- cgit v1.2.3