F
fcom
Unregistered / Unconfirmed
GUEST, unregistred user!
我又一段代码是用于帧的压缩和解压的,从他人那里down的代码:〉
但是不起作用不知道为什么?
procedure TForm1.Timer1Timer(Sender: TObject);
var a: pointer;
b: cardinal;
c: boolean;
begin
Compressor1.CompressBMP(CaptureBMP1.GetBitmap,a,b,c);
image1.Picture.Assign(Decompressor1.DecompressBMP(a,c));
end;
function TCompressor.CompressBMP(Bitmap: Tbitmap;
out Data: Pointer;
out Size: DWORD;
out IsKey: Boolean): Byte;
var dwHeaderSize,dwBitSize : DWord;
begin
result:=0;
//MemBitmap:=Bitmap;
GetDIBSizes(Bitmap.handle,dwHeaderSize,dwBitSize);
GetDIB(Bitmap.handle,Bitmap.palette,Header^,Bits^);
pNewBits :=ICSeqCompressFrame(pcmpVars,0,Bits,@WasCompressed,@pCompSize);
Size:= LongInt(pCompSize);
//Size := LongInt(dwBitSize);
IsKey:=WasCompressed;
if pNewBits = nil then
result:=1;
Data:= pNewBits;
end;
function TDecompressor.DecompressBMP(Data: Pointer;IsKey: Boolean):TBitmap;
begin
li:=ICDecompress(hic,0,@OutBitmap,Data,@InBitmap,AVIBufferOut);
if li <> 0 then
exit;
li:=StretchDIBits(Can.Handle,0, 0, bmih.biWidth, bmih.biHeight,0, 0, bmih.biWidth, bmih.biHeight,AVIBufferOut, bmi,0,SRCCOPY);
if li = 0 then
exit;
result:=Bitmap;
end;
但是不起作用不知道为什么?
procedure TForm1.Timer1Timer(Sender: TObject);
var a: pointer;
b: cardinal;
c: boolean;
begin
Compressor1.CompressBMP(CaptureBMP1.GetBitmap,a,b,c);
image1.Picture.Assign(Decompressor1.DecompressBMP(a,c));
end;
function TCompressor.CompressBMP(Bitmap: Tbitmap;
out Data: Pointer;
out Size: DWORD;
out IsKey: Boolean): Byte;
var dwHeaderSize,dwBitSize : DWord;
begin
result:=0;
//MemBitmap:=Bitmap;
GetDIBSizes(Bitmap.handle,dwHeaderSize,dwBitSize);
GetDIB(Bitmap.handle,Bitmap.palette,Header^,Bits^);
pNewBits :=ICSeqCompressFrame(pcmpVars,0,Bits,@WasCompressed,@pCompSize);
Size:= LongInt(pCompSize);
//Size := LongInt(dwBitSize);
IsKey:=WasCompressed;
if pNewBits = nil then
result:=1;
Data:= pNewBits;
end;
function TDecompressor.DecompressBMP(Data: Pointer;IsKey: Boolean):TBitmap;
begin
li:=ICDecompress(hic,0,@OutBitmap,Data,@InBitmap,AVIBufferOut);
if li <> 0 then
exit;
li:=StretchDIBits(Can.Handle,0, 0, bmih.biWidth, bmih.biHeight,0, 0, bmih.biWidth, bmih.biHeight,AVIBufferOut, bmi,0,SRCCOPY);
if li = 0 then
exit;
result:=Bitmap;
end;