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}
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
// abstract decoder class to define the base functionality of an encoder/decoder
@@ -229,7 +229,7 @@ type
PLZ77Decoder = ^TLZ77Decoder;
TLZ77Decoder = {$IFDEF NOCLASSES} object(TDecoder) {$ELSE} class(TDecoder) {$ENDIF}
private
FStream: TZState;
FStream: TZStreamRec;
FZLibResult, // contains the return code of the last ZLib operation
FFlushMode: integer; // one of flush constants declard in ZLib.pas
// 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);
begin
FStream.NextInput:=Source;
FStream.AvailableInput:=PackedSize;
FStream.next_in := Source;
FStream.avail_in := PackedSize;
if FAutoReset then FZLibResult:=InflateReset(FStream);
if FZLibResult=Z_OK then
begin
FStream.NextOutput:=Dest;
FStream.AvailableOutput:=UnpackedSize;
FStream.next_out:=Dest;
FStream.avail_out:=UnpackedSize;
FZLibResult:=Inflate(FStream,FFlushMode);
// advance pointers so used input can be calculated
Source:=FStream.NextInput;
Dest:=FStream.NextOutput;
Source:=FStream.next_in;
Dest:=FStream.next_out;
end;
end;
@@ -1851,14 +1851,14 @@ end;
function TLZ77Decoder.GetAvailableInput: integer;
begin
Result:=FStream.AvailableInput;
Result:=FStream.avail_in;
end;
//----------------------------------------------------------------------------------------------------------------------
function TLZ77Decoder.GetAvailableOutput: integer;
begin
Result:=FStream.AvailableOutput;
Result:=FStream.avail_out;
end;
//----------------- TThunderDecoder ------------------------------------------------------------------------------------

View File

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

View File

@@ -540,6 +540,9 @@ function BZ2_bzBuffToBuffDecompress(dest: Pointer; var destLen: Integer; source:
function adler32; external;
function compressBound; external;
//
function InflateInit(var stream: TZStreamRec): Integer;
implementation
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',
tinyPNG in 'tinyPNG.pas',
tinyJPGGIFBMP in 'tinyJPGGIFBMP.pas',
MZLib in 'MZLib.pas',
mckWebBrowser in 'mckWebBrowser.pas',
mckDHTML in 'mckDHTML.pas';

View File

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

View File

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

View File

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