[源码分享]实用控件三:异常简单的对ImageList的改进----内部图片使用zlib压缩存储(减小你的exe尺寸) ( 积分: 0 )

  • 主题发起人 主题发起人 Another_eYes
  • 开始时间 开始时间
A

Another_eYes

Unregistered / Unconfirmed
GUEST, unregistred user!
没啥可说的,看代码就明白了:
unit ZippedImgLst;

interface

uses
SysUtils, Classes, Controls, zlib;

type
TZippedImageList = class(TImageList)
protected
procedure ReadData(Stream: TStream); override;
procedure WriteData(Stream: TStream); override;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Additional', [TZippedImageList]);
end;

procedure TZippedImageList.ReadData(Stream: TStream);
var
stm: TDecompressionStream;
begin
stm := TDecompressionStream.Create(Stream);
inherited ReadData(stm);
stm.Free;
end;

procedure TZippedImageList.WriteData(Stream: TStream);
var
stm: TCompressionStream;
begin
stm := TCompressionStream.Create(clMax, Stream);
inherited WriteData(stm);
stm.Free;
end;

end.
 
没啥可说的,看代码就明白了:
unit ZippedImgLst;

interface

uses
SysUtils, Classes, Controls, zlib;

type
TZippedImageList = class(TImageList)
protected
procedure ReadData(Stream: TStream); override;
procedure WriteData(Stream: TStream); override;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Additional', [TZippedImageList]);
end;

procedure TZippedImageList.ReadData(Stream: TStream);
var
stm: TDecompressionStream;
begin
stm := TDecompressionStream.Create(Stream);
inherited ReadData(stm);
stm.Free;
end;

procedure TZippedImageList.WriteData(Stream: TStream);
var
stm: TCompressionStream;
begin
stm := TCompressionStream.Create(clMax, Stream);
inherited WriteData(stm);
stm.Free;
end;

end.
 
后退
顶部