Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.07.11;
Скачать: CL | DM;

Вниз

памяти в память   Найти похожие ветки 

 
iskatel ©   (2005-06-12 19:42) [0]

есть ли какойнить (бесплатный) компонент для работы с архивами, чтоб мог упаковывать и разпаковывать из памяти в память, без создания файла


 
Ученик   (2005-06-12 20:04) [1]

>iskatel ©   (12.06.05 19:42)  
ZLib в Delphi


 
Antonn ©   (2005-06-13 03:55) [2]

линшее поубирать.

procedure Pack_Memory(var _in:TMemoryStream);
procedure UnPack_Memory(var _in:TMemoryStream);

implementation

procedure Pack_Memory(var _in:TMemoryStream);
var
 TmpStream : TMemoryStream; CmpStream : TCompressionStream;
begin
 TmpStream := TMemoryStream.Create;
 CmpStream := TCompressionStream.Create (clMax, TmpStream);
 application.ProcessMessages;
 _in.Seek (0, 0);
 CmpStream.CopyFrom (_in, _in.Size);
 CmpStream.Free;
 TmpStream.Position:=0;
 _in.Position:=0;
 _in.SetSize(TmpStream.Size);
 _in.CopyFrom (TmpStream, TmpStream.Size);
 TmpStream.Free;
end;

procedure DecompressStream(inpStream, outStream: TMemoryStream);
var
 InpBuf, OutBuf: Pointer;
 OutBytes, sz: Integer;
begin
 InpBuf := nil;
 OutBuf := nil;
 sz     := inpStream.Size - inpStream.Position;
 if sz > 0 then  
   try
     GetMem(InpBuf, sz);
     inpStream.Read(InpBuf^, sz);
     DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
     outStream.Write(OutBuf^, OutBytes);
   finally
     if InpBuf <> nil then FreeMem(InpBuf);
     if OutBuf <> nil then FreeMem(OutBuf);
   end;
 outStream.Position := 0;
end;

procedure UnPack_Memory(var _in:TMemoryStream);
var _out:TMemoryStream;
begin
  _out := TMemoryStream.Create;
  _in.Position:=0;
  DecompressStream(_in, _out);
 _in.Seek(0,0);
 _in.CopyFrom(_out, _out.Size);
  _out.Free;
end;



Страницы: 1 вся ветка

Текущий архив: 2005.07.11;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.027 c
1-1119458401
Oleg Soev
2005-06-22 20:40
2005.07.11
Drag&amp;Drop на панель задач и в трей.


5-1089704607
sergvc
2004-07-13 11:43
2005.07.11
Составной компонент типа TLabeledEdit


14-1118294705
hooch
2005-06-09 09:25
2005.07.11
вопрос модераторам.


14-1117855892
Федрович
2005-06-04 07:31
2005.07.11
Опять тема диплом


1-1119344221
Vikarij
2005-06-21 12:57
2005.07.11
Delphi, Printer