Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.056 c
14-1118401829
Тульский
2005-06-10 15:10
2005.07.11
Программирование в MapInfo


14-1118159506
iZEN
2005-06-07 19:51
2005.07.11
Sequence Diagram в UML2.0?


8-1110488154
Okez
2005-03-10 23:55
2005.07.11
видео проигрыватель


3-1117001327
ANB
2005-05-25 10:08
2005.07.11
Как скопировать таблицу из схемы в схему (Oracle)


6-1112691724
_Andrey
2005-04-05 13:02
2005.07.11
popup сообщение




   Наверх