You've already forked lazarus-ccr
pyramidtiff: removed dependency to codetools to allow same licence as FCL
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3840 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -31,16 +31,13 @@
|
|||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="3">
|
<RequiredPackages Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="MultiThreadProcsLaz"/>
|
<PackageName Value="MultiThreadProcsLaz"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="CodeTools"/>
|
|
||||||
</Item2>
|
|
||||||
<Item3>
|
|
||||||
<PackageName Value="LazUtils"/>
|
<PackageName Value="LazUtils"/>
|
||||||
</Item3>
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="1">
|
<Units Count="1">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
{ Author: Mattias Gaertner mattias@freepascal.org
|
||||||
|
|
||||||
|
License:
|
||||||
|
Modified LGPL2 like FCL
|
||||||
|
}
|
||||||
program pyramidtiff;
|
program pyramidtiff;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
@@ -6,7 +11,7 @@ uses
|
|||||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
cthreads,
|
cthreads,
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
Classes, SysUtils, math, LazFileUtils, CodeToolsStructs, CustApp,
|
Classes, SysUtils, math, LazFileUtils, AvgLvlTree, CustApp,
|
||||||
FPimage, FPReadJPEG, FPReadPNG, FPReadBMP, FPImgCanv, FPCanvas, MTProcs,
|
FPimage, FPReadJPEG, FPReadPNG, FPReadBMP, FPImgCanv, FPCanvas, MTProcs,
|
||||||
PyTiGraphics, FPReadTiff, FPTiffCmn, FPWriteTiff;
|
PyTiGraphics, FPReadTiff, FPTiffCmn, FPWriteTiff;
|
||||||
|
|
||||||
@@ -14,6 +19,13 @@ const
|
|||||||
Version = '1.1';
|
Version = '1.1';
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TFilenameToStringTree }
|
||||||
|
|
||||||
|
TFilenameToStringTree = class(TStringToStringTree)
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TPyramidTiffer }
|
{ TPyramidTiffer }
|
||||||
|
|
||||||
TPyramidTiffer = class(TCustomApplication)
|
TPyramidTiffer = class(TCustomApplication)
|
||||||
@@ -22,7 +34,6 @@ type
|
|||||||
FMinSize: Word;
|
FMinSize: Word;
|
||||||
FOutputPath: string;
|
FOutputPath: string;
|
||||||
FQuiet: boolean;
|
FQuiet: boolean;
|
||||||
//FSkipCheck: boolean;
|
|
||||||
FTileHeight: Word;
|
FTileHeight: Word;
|
||||||
FTileWidth: Word;
|
FTileWidth: Word;
|
||||||
FVerbose: boolean;
|
FVerbose: boolean;
|
||||||
@@ -39,11 +50,11 @@ type
|
|||||||
procedure ReadConfig;
|
procedure ReadConfig;
|
||||||
function CheckIfFileIsPyramidTiled(Filename: string; out ErrorMsg: string): boolean;
|
function CheckIfFileIsPyramidTiled(Filename: string; out ErrorMsg: string): boolean;
|
||||||
function CheckIfStreamIsPyramidTiled(s: TStream; out ErrorMsg: string): boolean;
|
function CheckIfStreamIsPyramidTiled(s: TStream; out ErrorMsg: string): boolean;
|
||||||
function GetReaderClass(Filename: string): TFPCustomImageReaderClass;
|
function GetReaderClass(Filename: string): TFPCustomImageReaderClass; // worker thread
|
||||||
function ConvertDir(InputDir, OutputDir: string; out ErrorMsg: string): boolean;
|
function ConvertDir(InputDir, OutputDir: string; out ErrorMsg: string): boolean; // main thread
|
||||||
procedure ConvertFilesParallel(Index: PtrInt; Data: Pointer; {%H-}Item: TMultiThreadProcItem);
|
procedure ConvertFilesParallel(Index: PtrInt; Data: Pointer; {%H-}Item: TMultiThreadProcItem); // worker thread
|
||||||
function ConvertFile(InputFilename, OutputFilename: string; out ErrorMsg: string): boolean;
|
function ConvertFile(InputFilename, OutputFilename: string; out ErrorMsg: string): boolean; // worker thread
|
||||||
function Convert(Img: TFPCompactImgBase; OutputFilename: string; out ErrorMsg: string): boolean;
|
function Convert(Img: TFPCompactImgBase; OutputFilename: string; out ErrorMsg: string): boolean; // worker thread
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@@ -52,7 +63,6 @@ type
|
|||||||
property TileWidth: Word read FTileWidth write FTileWidth;
|
property TileWidth: Word read FTileWidth write FTileWidth;
|
||||||
property TileHeight: Word read FTileHeight write FTileHeight;
|
property TileHeight: Word read FTileHeight write FTileHeight;
|
||||||
property MinSize: Word read FMinSize write FMinSize;
|
property MinSize: Word read FMinSize write FMinSize;
|
||||||
//property SkipCheck: boolean read FSkipCheck write FSkipCheck;
|
|
||||||
property Verbose: boolean read FVerbose write FVerbose;
|
property Verbose: boolean read FVerbose write FVerbose;
|
||||||
property Quiet: boolean read FQuiet write FQuiet;
|
property Quiet: boolean read FQuiet write FQuiet;
|
||||||
property InputPath: string read FInputPath write FInputPath;
|
property InputPath: string read FInputPath write FInputPath;
|
||||||
@@ -105,6 +115,26 @@ begin
|
|||||||
Result:=l;
|
Result:=l;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CompareFilenameAndFilenameToStringTreeItem(Key, Data: Pointer
|
||||||
|
): integer;
|
||||||
|
begin
|
||||||
|
Result:=CompareFilenames(String(Key),PStringToStringItem(Data)^.Name);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CompareFilenameToStringItems(Data1, Data2: Pointer): integer;
|
||||||
|
begin
|
||||||
|
Result:=CompareFilenames(PStringToStringItem(Data1)^.Name,
|
||||||
|
PStringToStringItem(Data2)^.Name);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFilenameToStringTree }
|
||||||
|
|
||||||
|
constructor TFilenameToStringTree.Create;
|
||||||
|
begin
|
||||||
|
SetCompareFuncs(@CompareFilenameToStringItems,
|
||||||
|
@CompareFilenameAndFilenameToStringTreeItem,false);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TMyCanvas }
|
{ TMyCanvas }
|
||||||
|
|
||||||
procedure TMyCanvas.DoCopyRect(x, y: integer; canvas: TFPCustomCanvas;
|
procedure TMyCanvas.DoCopyRect(x, y: integer; canvas: TFPCustomCanvas;
|
||||||
@@ -285,7 +315,7 @@ var
|
|||||||
ErrorMsg:=CheckOptions(ShortOpts,LongOptions,Opts,NonOpts);
|
ErrorMsg:=CheckOptions(ShortOpts,LongOptions,Opts,NonOpts);
|
||||||
if ErrorMsg<>'' then begin
|
if ErrorMsg<>'' then begin
|
||||||
ShowException(Exception.Create(ErrorMsg));
|
ShowException(Exception.Create(ErrorMsg));
|
||||||
Halt;
|
Halt(1);
|
||||||
end;
|
end;
|
||||||
for i:=0 to NonOpts.Count-1 do
|
for i:=0 to NonOpts.Count-1 do
|
||||||
if NonOpts[i]<>'' then
|
if NonOpts[i]<>'' then
|
||||||
@@ -306,13 +336,13 @@ begin
|
|||||||
// parse parameters
|
// parse parameters
|
||||||
if HasOption('h','help') then begin
|
if HasOption('h','help') then begin
|
||||||
WriteHelp(true);
|
WriteHelp(true);
|
||||||
Halt;
|
Halt(1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// parse parameters
|
// parse parameters
|
||||||
if HasOption('V','version') then begin
|
if HasOption('V','version') then begin
|
||||||
writeln(Version);
|
writeln(Version);
|
||||||
Halt;
|
Halt(0);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
LongOptions.Free;
|
LongOptions.Free;
|
||||||
@@ -433,8 +463,8 @@ function TPyramidTiffer.ConvertDir(InputDir, OutputDir: string; out
|
|||||||
ErrorMsg: string): boolean;
|
ErrorMsg: string): boolean;
|
||||||
var
|
var
|
||||||
FileInfo: TSearchRec;
|
FileInfo: TSearchRec;
|
||||||
Files: TFilenameToStringTree;
|
Files: TStringToStringTree;
|
||||||
Item: PStringToStringTreeItem;
|
Item: PStringToStringItem;
|
||||||
InputFile: String;
|
InputFile: String;
|
||||||
OutputFile: String;
|
OutputFile: String;
|
||||||
FileList: TStringList;
|
FileList: TStringList;
|
||||||
@@ -443,7 +473,7 @@ begin
|
|||||||
ErrorMsg:='';
|
ErrorMsg:='';
|
||||||
InputDir:=AppendPathDelim(InputDir);
|
InputDir:=AppendPathDelim(InputDir);
|
||||||
OutputDir:=AppendPathDelim(OutputDir);
|
OutputDir:=AppendPathDelim(OutputDir);
|
||||||
Files:=TFilenameToStringTree.Create(false);
|
Files:=TStringToStringTree.Create(false);
|
||||||
FileList:=TStringList.Create;
|
FileList:=TStringList.Create;
|
||||||
try
|
try
|
||||||
if FindFirstUTF8(InputDir+AllFilesMask,faAnyFile,FileInfo)=0 then begin
|
if FindFirstUTF8(InputDir+AllFilesMask,faAnyFile,FileInfo)=0 then begin
|
||||||
|
Reference in New Issue
Block a user