?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Zlib;
type
TForm1 = class(TForm)
Button1: TButton;
Edit_dxg: TEdit;
Button2: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
procedure CompressStream(inpStream, outStream: TStream);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ms1,ms2:TMemoryStream;
begin
ms1 := TMemoryStream.Create;
ms2 := TMemoryStream.Create;
try
try
ms1.LoadFromFile(OpenDialog1.FileName);
CompressStream(ms1, ms2);
if SaveDialog1.Execute then ms2.SaveToFile(SaveDialog1.FileName);
finally
ms1.Free;
end;
finally
ms2.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then Edit_dxg.Text:=OpenDialog1.FileName;
end;
procedure Tform1.CompressStream(inpStream, outStream: TStream);
var
InpBuf, OutBuf : Pointer;
InpBytes, OutBytes: Integer;
begin
InpBuf := nil;
OutBuf := nil;
try
GetMem(InpBuf, inpStream.Size);
inpStream.Position := 0;
InpBytes := inpStream.Read(InpBuf^, inpStream.Size);
CompressBuf(InpBuf, InpBytes, OutBuf, OutBytes);
outStream.Write(OutBuf^, OutBytes);
finally
if InpBuf <> nil then
FreeMem(InpBuf);
if OutBuf <> nil then
FreeMem(OutBuf);
end;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -