unit2.pas

来自「流的压缩和解压 说明:适用文件压缩、图象压缩等 调用ZLib单元的方法实现」· PAS 代码 · 共 72 行

PAS
72
字号
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, inifiles;

type
  TNewID = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    ET_Exefile: TEdit;
    ET_Chsname: TEdit;
    Panel1: TPanel;
    Image1: TImage;
    ET_Info: TMemo;
    ET_Link: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    SpeedButton1: TSpeedButton;
    OpnDlg: TOpenDialog;
    Label6: TLabel;
    ET_Class: TComboBox;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  NewID: TNewID;

implementation

{$R *.dfm}
uses unit1,ZLib;

const cBufferSize = $4096;

function StreamCompression(mInputStream: TStream; mOutputStream: TStream): Integer;
var
  I: Integer;
  vBuffer: array[0..cBufferSize]of Char;
begin
  Result := -1;
  if not (Assigned(mInputStream) and Assigned(mOutputStream)) then Exit;
  with TCompressionStream.Create(clMax, mOutputStream) do try
    for I := 1 to mInputStream.Size div cBufferSize do begin
      mInputStream.Read(vBuffer, cBufferSize);
      Write(vBuffer, cBufferSize);
    end;
    I := mInputStream.Size mod cBufferSize;
    if I > 0 then begin
      mInputStream.Read(vBuffer, I);
      Write(vBuffer, I);
    end;
  finally
    Free;
  end;
end; { StreamCompression }





end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?