git-svn-id: https://svn.code.sf.net/p/kolmck/code@73 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07

This commit is contained in:
dkolmck
2010-10-04 13:58:38 +00:00
parent 4a0aba563a
commit 64799659b0
8 changed files with 25 additions and 5662 deletions

View File

@@ -73,7 +73,7 @@ interface
{$I KOLDEF.INC} {$I KOLDEF.INC}
uses Windows, KOL, {$IFDEF NOT_USE_KOL_ERR}sysutils {$ELSE}Err {$ENDIF}, Errors, uses Windows, KOL, {$IFDEF NOT_USE_KOL_ERR}sysutils {$ELSE}Err {$ENDIF}, Errors,
MZLib {$IFDEF GIF_MMX}, Mmx {$ENDIF}; // general inflate/deflate and LZ77 compression support KolZLibBzip {$IFDEF GIF_MMX}, Mmx {$ENDIF}; // general inflate/deflate and LZ77 compression support
type type
// abstract decoder class to define the base functionality of an encoder/decoder // abstract decoder class to define the base functionality of an encoder/decoder
@@ -229,7 +229,7 @@ type
PLZ77Decoder = ^TLZ77Decoder; PLZ77Decoder = ^TLZ77Decoder;
TLZ77Decoder = {$IFDEF NOCLASSES} object(TDecoder) {$ELSE} class(TDecoder) {$ENDIF} TLZ77Decoder = {$IFDEF NOCLASSES} object(TDecoder) {$ELSE} class(TDecoder) {$ENDIF}
private private
FStream: TZState; FStream: TZStreamRec;
FZLibResult, // contains the return code of the last ZLib operation FZLibResult, // contains the return code of the last ZLib operation
FFlushMode: integer; // one of flush constants declard in ZLib.pas FFlushMode: integer; // one of flush constants declard in ZLib.pas
// this is usually Z_FINISH for PSP and Z_PARTIAL_FLUSH for PNG // this is usually Z_FINISH for PSP and Z_PARTIAL_FLUSH for PNG
@@ -1819,17 +1819,17 @@ end;
procedure TLZ77Decoder.Decode(var Source,Dest: pointer; PackedSize,UnpackedSize: integer); procedure TLZ77Decoder.Decode(var Source,Dest: pointer; PackedSize,UnpackedSize: integer);
begin begin
FStream.NextInput:=Source; FStream.next_in := Source;
FStream.AvailableInput:=PackedSize; FStream.avail_in := PackedSize;
if FAutoReset then FZLibResult:=InflateReset(FStream); if FAutoReset then FZLibResult:=InflateReset(FStream);
if FZLibResult=Z_OK then if FZLibResult=Z_OK then
begin begin
FStream.NextOutput:=Dest; FStream.next_out:=Dest;
FStream.AvailableOutput:=UnpackedSize; FStream.avail_out:=UnpackedSize;
FZLibResult:=Inflate(FStream,FFlushMode); FZLibResult:=Inflate(FStream,FFlushMode);
// advance pointers so used input can be calculated // advance pointers so used input can be calculated
Source:=FStream.NextInput; Source:=FStream.next_in;
Dest:=FStream.NextOutput; Dest:=FStream.next_out;
end; end;
end; end;
@@ -1851,14 +1851,14 @@ end;
function TLZ77Decoder.GetAvailableInput: integer; function TLZ77Decoder.GetAvailableInput: integer;
begin begin
Result:=FStream.AvailableInput; Result:=FStream.avail_in;
end; end;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function TLZ77Decoder.GetAvailableOutput: integer; function TLZ77Decoder.GetAvailableOutput: integer;
begin begin
Result:=FStream.AvailableOutput; Result:=FStream.avail_out;
end; end;
//----------------- TThunderDecoder ------------------------------------------------------------------------------------ //----------------- TThunderDecoder ------------------------------------------------------------------------------------

View File

@@ -503,7 +503,7 @@ var
implementation implementation
uses {$IFDEF NOT_USE_KOL_ERR}Math, {$ELSE}KOLMath, {$ENDIF} MZLib; uses {$IFDEF NOT_USE_KOL_ERR}Math, {$ELSE}KOLMath, {$ENDIF} KolZLibBzip;
const const
PNG = 'PNG'; PNG = 'PNG';

View File

@@ -540,6 +540,9 @@ function BZ2_bzBuffToBuffDecompress(dest: Pointer; var destLen: Integer; source:
function adler32; external; function adler32; external;
function compressBound; external; function compressBound; external;
//
function InflateInit(var stream: TZStreamRec): Integer;
implementation implementation
procedure _bz_internal_error(errcode: Integer); cdecl; procedure _bz_internal_error(errcode: Integer); cdecl;

File diff suppressed because it is too large Load Diff

View File

@@ -83,7 +83,6 @@ contains
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas',
tinyPNG in 'tinyPNG.pas', tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas', tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
MZLib in 'MZLib.pas',
mckWebBrowser in 'mckWebBrowser.pas', mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas'; mckDHTML in 'mckDHTML.pas';

View File

@@ -76,7 +76,6 @@ contains
XPMenus in 'XPMenus.pas', XPMenus in 'XPMenus.pas',
tinyPNG in 'tinyPNG.pas', tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas', tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
MZLib in 'MZLib.pas',
mckWebBrowser in 'mckWebBrowser.pas', mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas'; mckDHTML in 'mckDHTML.pas';

View File

@@ -89,7 +89,6 @@ contains
MCKGRushRadioBoxEditor in 'MCKGRushRadioBoxEditor.pas', MCKGRushRadioBoxEditor in 'MCKGRushRadioBoxEditor.pas',
tinyPNG in 'tinyPNG.pas', tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas', tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
MZLib in 'MZLib.pas',
KOLGRushControls in 'KOLGRushControls.pas'; KOLGRushControls in 'KOLGRushControls.pas';
end. end.

View File

@@ -87,31 +87,10 @@ unit tinyPNG;
// probable error. // probable error.
//****************************************************************************** //******************************************************************************
interface interface
uses windows, KOL, MZLib; uses
Windows, KOL, KolZLibBzip;
{$IFDEF MOSTCOMPATIBILITY} {$IFDEF MOSTCOMPATIBILITY}
{$DEFINE csG} {$DEFINE csG}
@@ -253,7 +232,7 @@ var CM: TColorManager;
IP: TImageProperties; IP: TImageProperties;
Header: TPNGChunkHeader; Header: TPNGChunkHeader;
Description: TIHDRChunk; Description: TIHDRChunk;
InflateStream: TZState; InflateStream: TZStreamRec;
RowBuffer: array[Boolean] of PChar; RowBuffer: array[Boolean] of PChar;
RawBuffer: Pointer; RawBuffer: Pointer;
@@ -902,10 +881,10 @@ begin
{$IFNDEF USEHACKS} {$IFNDEF USEHACKS}
result := false; result := false;
{$ENDIF USEHACKS} {$ENDIF USEHACKS}
InflateStream.NextOutput := Buffer; InflateStream.next_out := Buffer;
InflateStream.AvailableOutput := Bytes; InflateStream.avail_out := Bytes;
repeat repeat
if InflateStream.AvailableInput = 0 then begin if InflateStream.avail_in = 0 then begin
IDATSize:=0; IDATSize:=0;
while IDATSize=0 do begin while IDATSize=0 do begin
{$IFNDEF USEHACKS} {$IFNDEF USEHACKS}
@@ -923,16 +902,16 @@ begin
{$ENDIF USEHACKS} {$ENDIF USEHACKS}
end; end;
end; end;
InflateStream.NextInput := CurrentSource; InflateStream.next_in := CurrentSource;
InflateStream.AvailableInput := IDATSize-(Integer(CurrentSource)-Integer(RawBuffer)); InflateStream.avail_in := IDATSize-(Integer(CurrentSource)-Integer(RawBuffer));
ZLibResult := Inflate(InflateStream, Z_PARTIAL_FLUSH); ZLibResult := Inflate(InflateStream, Z_PARTIAL_FLUSH);
CurrentSource := InflateStream.NextInput; CurrentSource := InflateStream.next_in;
if ZLibResult = Z_STREAM_END then begin if ZLibResult = Z_STREAM_END then begin
if (InflateStream.AvailableOutput <> 0) or (InflateStream.AvailableInput<>0) then exit; if (InflateStream.avail_out <> 0) or (InflateStream.avail_in<>0) then exit;
Break; Break;
end; end;
if ZLibResult <> Z_OK then exit; if ZLibResult <> Z_OK then exit;
until InflateStream.AvailableOutput = 0; until InflateStream.avail_out = 0;
{$IFNDEF USEHACKS} {$IFNDEF USEHACKS}
result := true; result := true;
{$ENDIF USEHACKS} {$ENDIF USEHACKS}