Subversion Repositories autosfx

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 daniel-mar 1
unit Unit1;
2
// Demo for reading from Zip Stream by Nikolaj Olsson (nikse@e-mail.dk)
3
// amended April 11, 2005 R.Peters
4
(************************************************************************
5
 Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht,
6
      Eric W. Engler and Chris Vleghert.
7
 
8
   This file is part of TZipMaster Version 1.9.
9
 
10
    TZipMaster is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU Lesser General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    TZipMaster is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU Lesser General Public License for more details.
19
 
20
    You should have received a copy of the GNU Lesser General Public License
21
    along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
    contact: problems@delphizip.org (include ZipMaster in the subject).
24
    updates: http://www.delphizip.org
25
    DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
26
************************************************************************)
27
 
28
 
29
interface
30
 
31
uses
32
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
33
  ExtCtrls, StdCtrls, Buttons, ZipMstr19;
34
 
35
type
36
  TForm1 = class(TForm)
37
    Image1: TImage;
38
    StaticText1: TStaticText;
39
    BtnPic1: TButton;
40
    BtnPic2: TButton;
41
    BtnPic3: TButton;
42
    procedure UnzipToImage(filename : string);
43
    procedure BtnPic3Click(Sender: TObject);
44
    procedure BtnPic1Click(Sender: TObject);
45
    procedure BtnPic2Click(Sender: TObject);
46
    procedure FormCreate(Sender: TObject);
47
  private
48
    ZipMaster1: TZipMaster19;
49
  public
50
    { Public declarations }
51
  end;
52
 
53
var
54
  Form1: TForm1;
55
//  Stream1 : TZipstream;
56
 
57
implementation
58
 
59
{$R *.DFM}
60
 
61
procedure TForm1.UnzipToImage(filename : string);
62
var
63
  Stream1: TMemoryStream;
64
begin
65
  if not ZipMaster1.{Unz}Busy then
66
  begin
67
    ZipMaster1.ZipFileName:= 'resource.zip';
68
    if ZipMaster1.Count > 0 then
69
    begin
70
      ZipMaster1.Password:='password';
71
      Stream1 := ZipMaster1.ExtractFileToStream(filename);
72
      if Stream1 <> nil then
73
      begin
74
        Stream1.Position := 0;      // reset to the beginning of the stream
75
        StaticText1.Caption:='File Size: '+ IntToStr(Stream1.Size);
76
        Image1.Picture.Bitmap.LoadFromStream(Stream1);
77
      end
78
      else
79
        StaticText1.Caption:='extraction error';
80
    end
81
    else
82
      StaticText1.Caption:='resource.zip not found or empty';
83
  end;
84
end;
85
 
86
procedure TForm1.BtnPic3Click(Sender: TObject);
87
begin
88
  UnzipToImage('eye.bmp');
89
end;
90
 
91
procedure TForm1.FormCreate(Sender: TObject);
92
begin
93
  ZipMaster1 := TZipMaster19.Create(self);
94
  ZipMaster1.DLLDirectory := '..\..\DLL\';
95
end;
96
 
97
procedure TForm1.BtnPic1Click(Sender: TObject);
98
begin
99
  UnzipToImage('paintbrush.bmp');
100
end;
101
 
102
procedure TForm1.BtnPic2Click(Sender: TObject);
103
begin
104
  UnzipToImage('Spectrum.bmp');
105
end;
106
 
107
end.