请教使用过TVCLZip控件的大侠一个比较简单的问题。(40分)

  • 主题发起人 主题发起人 fxh7622
  • 开始时间 开始时间
F

fxh7622

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用TVCLZip对一个BMP进行压缩,压缩完以后有对这个压缩后的文件解压缩。解压缩以后想将这个BMP图片放在一个TImage控件中,可是发现怎么也放不上去。请哪位大侠帮助。一下是我的代码:
压缩:
procedure TForm1.Button1Click(Sender: TObject);
var
InStream,OutStream:TFileStream;
Size:Integer;
begin
InStream:=TFileStream.Create('C:/test.bmp',fmOpenRead);
Size:=InStream.Size;
OutStream:=TFileStream.Create('C:/11111.zip',fmCreate);
OutStream.Seek(0,soFromEnd);
Size:=OutStream.Size;
VCLZip1.ZLibCompressStream(InStream,OutStream);
Size:=OutStream.Size;
OutStream.Free;
InStream.Free;
end;
解压缩:
procedure TForm1.Button2Click(Sender: TObject);
var
InStream,OutStream:TFileStream;
FOutMem:TMemoryStream;
Ini:TMemIniFile;
begin
InStream:=TFileStream.Create('C:/11111.zip',fmOpenRead);
FOutMem:=TMemoryStream.Create;
VCLZip1.ZLibDecompressStream(InStream,FOutMem);
Image1.Picture.Bitmap.LoadFromStream(FOutMem);
end;
 
没用过mark一下
 
function TPicResourceHelper.GetStreamFromID(
const AID: WideString): Tstream;
var
s: TMemoryStream;
sZn: WideString;
begin
result := nil;
sZn := FromIDToFileName(AID);

if sZn <> '' then
begin
s := TMemoryStream.Create;
if FVCLZip.UnZipToStream(s, sZn) <> 0 then
begin
s.Position := 0;
Result := s;
end
else
s.Free;
end;
end;
 
后退
顶部