fpvviewer: Adds an uncompressor tool to help uncompress svgz
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2717 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
		
							parent
							
								
									c7504daf94
								
							
						
					
					
						commit
						60bdc5be13
					
				
							
								
								
									
										40
									
								
								applications/fpvviewer/uncompressor/mainform.lfm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								applications/fpvviewer/uncompressor/mainform.lfm
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
			
		||||
object Form1: TForm1
 | 
			
		||||
  Left = 241
 | 
			
		||||
  Height = 121
 | 
			
		||||
  Top = 161
 | 
			
		||||
  Width = 320
 | 
			
		||||
  Caption = 'GZ Uncompressor'
 | 
			
		||||
  ClientHeight = 121
 | 
			
		||||
  ClientWidth = 320
 | 
			
		||||
  LCLVersion = '1.1'
 | 
			
		||||
  object editFileName: TFileNameEdit
 | 
			
		||||
    Left = 8
 | 
			
		||||
    Height = 23
 | 
			
		||||
    Top = 32
 | 
			
		||||
    Width = 264
 | 
			
		||||
    FileName = 'D:\lazarusccr\applications\fpvviewer\examples_files\svgz\tassu_20130329_b.svgz'
 | 
			
		||||
    FilterIndex = 0
 | 
			
		||||
    HideDirectories = False
 | 
			
		||||
    ButtonWidth = 23
 | 
			
		||||
    NumGlyphs = 1
 | 
			
		||||
    MaxLength = 0
 | 
			
		||||
    TabOrder = 0
 | 
			
		||||
  end
 | 
			
		||||
  object Button1: TButton
 | 
			
		||||
    Left = 16
 | 
			
		||||
    Height = 25
 | 
			
		||||
    Top = 80
 | 
			
		||||
    Width = 288
 | 
			
		||||
    Caption = 'Uncompress gz'
 | 
			
		||||
    OnClick = Button1Click
 | 
			
		||||
    TabOrder = 1
 | 
			
		||||
  end
 | 
			
		||||
  object Label1: TLabel
 | 
			
		||||
    Left = 8
 | 
			
		||||
    Height = 15
 | 
			
		||||
    Top = 15
 | 
			
		||||
    Width = 132
 | 
			
		||||
    Caption = 'File to be uncompressed:'
 | 
			
		||||
    ParentColor = False
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										75
									
								
								applications/fpvviewer/uncompressor/mainform.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								applications/fpvviewer/uncompressor/mainform.pas
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,75 @@
 | 
			
		||||
unit mainform;
 | 
			
		||||
 | 
			
		||||
{$mode objfpc}{$H+}
 | 
			
		||||
 | 
			
		||||
interface
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, EditBtn,
 | 
			
		||||
  StdCtrls;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
 | 
			
		||||
  { TForm1 }
 | 
			
		||||
 | 
			
		||||
  TForm1 = class(TForm)
 | 
			
		||||
    Button1: TButton;
 | 
			
		||||
    editFileName: TFileNameEdit;
 | 
			
		||||
    Label1: TLabel;
 | 
			
		||||
    procedure Button1Click(Sender: TObject);
 | 
			
		||||
  private
 | 
			
		||||
    { private declarations }
 | 
			
		||||
  public
 | 
			
		||||
    { public declarations }
 | 
			
		||||
    procedure InflateGZ(AGZFilename: string; ADest: TStream);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  Form1: TForm1;
 | 
			
		||||
 | 
			
		||||
implementation
 | 
			
		||||
 | 
			
		||||
uses zstream;
 | 
			
		||||
 | 
			
		||||
{$R *.lfm}
 | 
			
		||||
 | 
			
		||||
{ TForm1 }
 | 
			
		||||
 | 
			
		||||
procedure TForm1.Button1Click(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  DestStream: TFileStream;
 | 
			
		||||
  lDestFilename: string;
 | 
			
		||||
begin
 | 
			
		||||
  lDestFilename := Copy(editFileName.Text, 1, Length(editFileName.Text)-1);
 | 
			
		||||
  DestStream := TFileStream.Create(lDestFilename, fmCreate);
 | 
			
		||||
  try
 | 
			
		||||
    InflateGZ(editFileName.Text, DestStream);
 | 
			
		||||
  finally
 | 
			
		||||
    DestStream.Free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TForm1.InflateGZ(AGZFilename: string; ADest: TStream);
 | 
			
		||||
var
 | 
			
		||||
  GZStream: TGZFileStream;
 | 
			
		||||
  chunk:string;
 | 
			
		||||
  cnt:integer;
 | 
			
		||||
const
 | 
			
		||||
  CHUNKSIZE=4096;
 | 
			
		||||
begin
 | 
			
		||||
  GZStream := TGZFileStream.Create(AGZFilename, gzopenread);
 | 
			
		||||
  try
 | 
			
		||||
    setlength(chunk,CHUNKSIZE);
 | 
			
		||||
    repeat
 | 
			
		||||
      cnt := GZStream.read(chunk[1],CHUNKSIZE);
 | 
			
		||||
      if cnt<CHUNKSIZE then
 | 
			
		||||
        setlength(chunk,cnt);
 | 
			
		||||
      ADest.Write(chunk[1], Length(chunk));
 | 
			
		||||
    until cnt<CHUNKSIZE;
 | 
			
		||||
  finally
 | 
			
		||||
    GZStream.Free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
end.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										91
									
								
								applications/fpvviewer/uncompressor/uncompressor.lpi
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								applications/fpvviewer/uncompressor/uncompressor.lpi
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,91 @@
 | 
			
		||||
<?xml version="1.0"?>
 | 
			
		||||
<CONFIG>
 | 
			
		||||
  <ProjectOptions>
 | 
			
		||||
    <Version Value="9"/>
 | 
			
		||||
    <PathDelim Value="\"/>
 | 
			
		||||
    <General>
 | 
			
		||||
      <SessionStorage Value="InProjectDir"/>
 | 
			
		||||
      <MainUnit Value="0"/>
 | 
			
		||||
      <Title Value="uncompressor"/>
 | 
			
		||||
      <ResourceType Value="res"/>
 | 
			
		||||
      <UseXPManifest Value="True"/>
 | 
			
		||||
      <Icon Value="0"/>
 | 
			
		||||
    </General>
 | 
			
		||||
    <i18n>
 | 
			
		||||
      <EnableI18N LFM="False"/>
 | 
			
		||||
    </i18n>
 | 
			
		||||
    <VersionInfo>
 | 
			
		||||
      <StringTable ProductVersion=""/>
 | 
			
		||||
    </VersionInfo>
 | 
			
		||||
    <BuildModes Count="1">
 | 
			
		||||
      <Item1 Name="Default" Default="True"/>
 | 
			
		||||
    </BuildModes>
 | 
			
		||||
    <PublishOptions>
 | 
			
		||||
      <Version Value="2"/>
 | 
			
		||||
      <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
 | 
			
		||||
      <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
 | 
			
		||||
    </PublishOptions>
 | 
			
		||||
    <RunParams>
 | 
			
		||||
      <local>
 | 
			
		||||
        <FormatVersion Value="1"/>
 | 
			
		||||
      </local>
 | 
			
		||||
    </RunParams>
 | 
			
		||||
    <RequiredPackages Count="1">
 | 
			
		||||
      <Item1>
 | 
			
		||||
        <PackageName Value="LCL"/>
 | 
			
		||||
      </Item1>
 | 
			
		||||
    </RequiredPackages>
 | 
			
		||||
    <Units Count="2">
 | 
			
		||||
      <Unit0>
 | 
			
		||||
        <Filename Value="uncompressor.lpr"/>
 | 
			
		||||
        <IsPartOfProject Value="True"/>
 | 
			
		||||
        <UnitName Value="uncompressor"/>
 | 
			
		||||
      </Unit0>
 | 
			
		||||
      <Unit1>
 | 
			
		||||
        <Filename Value="mainform.pas"/>
 | 
			
		||||
        <IsPartOfProject Value="True"/>
 | 
			
		||||
        <ComponentName Value="Form1"/>
 | 
			
		||||
        <HasResources Value="True"/>
 | 
			
		||||
        <ResourceBaseClass Value="Form"/>
 | 
			
		||||
        <UnitName Value="mainform"/>
 | 
			
		||||
      </Unit1>
 | 
			
		||||
    </Units>
 | 
			
		||||
  </ProjectOptions>
 | 
			
		||||
  <CompilerOptions>
 | 
			
		||||
    <Version Value="11"/>
 | 
			
		||||
    <PathDelim Value="\"/>
 | 
			
		||||
    <Target>
 | 
			
		||||
      <Filename Value="uncompressor"/>
 | 
			
		||||
    </Target>
 | 
			
		||||
    <SearchPaths>
 | 
			
		||||
      <IncludeFiles Value="$(ProjOutDir)"/>
 | 
			
		||||
      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
 | 
			
		||||
    </SearchPaths>
 | 
			
		||||
    <Linking>
 | 
			
		||||
      <Options>
 | 
			
		||||
        <Win32>
 | 
			
		||||
          <GraphicApplication Value="True"/>
 | 
			
		||||
        </Win32>
 | 
			
		||||
      </Options>
 | 
			
		||||
    </Linking>
 | 
			
		||||
    <Other>
 | 
			
		||||
      <CompilerMessages>
 | 
			
		||||
        <MsgFileName Value=""/>
 | 
			
		||||
      </CompilerMessages>
 | 
			
		||||
      <CompilerPath Value="$(CompPath)"/>
 | 
			
		||||
    </Other>
 | 
			
		||||
  </CompilerOptions>
 | 
			
		||||
  <Debugging>
 | 
			
		||||
    <Exceptions Count="3">
 | 
			
		||||
      <Item1>
 | 
			
		||||
        <Name Value="EAbort"/>
 | 
			
		||||
      </Item1>
 | 
			
		||||
      <Item2>
 | 
			
		||||
        <Name Value="ECodetoolError"/>
 | 
			
		||||
      </Item2>
 | 
			
		||||
      <Item3>
 | 
			
		||||
        <Name Value="EFOpenError"/>
 | 
			
		||||
      </Item3>
 | 
			
		||||
    </Exceptions>
 | 
			
		||||
  </Debugging>
 | 
			
		||||
</CONFIG>
 | 
			
		||||
							
								
								
									
										21
									
								
								applications/fpvviewer/uncompressor/uncompressor.lpr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								applications/fpvviewer/uncompressor/uncompressor.lpr
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
program uncompressor;
 | 
			
		||||
 | 
			
		||||
{$mode objfpc}{$H+}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  {$IFDEF UNIX}{$IFDEF UseCThreads}
 | 
			
		||||
  cthreads,
 | 
			
		||||
  {$ENDIF}{$ENDIF}
 | 
			
		||||
  Interfaces, // this includes the LCL widgetset
 | 
			
		||||
  Forms, mainform
 | 
			
		||||
  { you can add units after this };
 | 
			
		||||
 | 
			
		||||
{$R *.res}
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  RequireDerivedFormResource := True;
 | 
			
		||||
  Application.Initialize;
 | 
			
		||||
  Application.CreateForm(TForm1, Form1);
 | 
			
		||||
  Application.Run;
 | 
			
		||||
end.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								applications/fpvviewer/uncompressor/uncompressor.res
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								applications/fpvviewer/uncompressor/uncompressor.res
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user