什么是Delphi TDecompressionStream的C#等价物?

时间:2022-10-01 16:59:24

I have some Delphi code that did this needs to be re-coded in C#:

我有一些Delphi代码需要在C#中重新编码:

procedure TDocSearchX.Decompress;
var
BlobStream:TBlobStream;
DecompressionStream:TDecompressionStream;
FileStream:TFileStream;
Buffer:array[0..2047] of byte;
count:integer;
begin
    BlobStream:=TBlobStream.Create(DocQueryDATA,bmRead);
    DecompressionStream:=TDecompressionStream.Create(BlobStream);
    FileStream:=TFileStream.Create(FDocFile,fmCreate);
    while True do
    begin
        Count := DecompressionStream.Read(Buffer, 2048);
        if Count <> 0 then FileStream.Write(Buffer, Count) else Break;
    end;
    Blobstream.Free;
    DecompressionStream.Free;
    FileStream.Free;
end;

The contractor that wrote this is leaving and I need to decompress the image (that is currently stored in the database). I have been able to extract the image to a file but have no idea how to decompress it using C#?

写这个的承包商正在离开,我需要解压缩图像(当前存储在数据库中)。我已经能够将图像提取到文件但不知道如何使用C#解压缩它?

3 个解决方案

#1


It looks like TDecompressionStream probably uses ZLib. Here is a .NET library for ZLIB:

看起来TDecompressionStream可能使用ZLib。这是一个用于ZLIB的.NET库:

http://www.componentace.com/zlib_.NET.htm

#2


To my knowledge there is no .Net Framework equivalent to the TDecompressionStream class. Are you able to write a small converter app in Delphi that decompresses the image? Then you are free to use whatever compression library (e.g. SharpZipLib) supporting .Net within your C# code.

据我所知,没有.Net Framework等同于TDecompressionStream类。您是否能够在Delphi中编写一个解压缩图像的小转换器应用程序?然后,您可以在C#代码中*使用支持.Net的任何压缩库(例如SharpZipLib)。

#3


If you have to keep the same compression already used, roll the Delphi decompression routine into a DLL and use it from C# using PInvoke.

如果必须保持已经使用的相同压缩,请将Delphi解压缩例程转换为DLL并使用PInvoke从C#中使用它。

If you want to replace the compression, write a batch process to extract the Delphi compressed images, decompress them to their original format and re-compress them with your favourite C# library.

如果要替换压缩,请编写批处理以提取Delphi压缩图像,将其解压缩为原始格式,然后使用您喜欢的C#库重新压缩它们。

#1


It looks like TDecompressionStream probably uses ZLib. Here is a .NET library for ZLIB:

看起来TDecompressionStream可能使用ZLib。这是一个用于ZLIB的.NET库:

http://www.componentace.com/zlib_.NET.htm

#2


To my knowledge there is no .Net Framework equivalent to the TDecompressionStream class. Are you able to write a small converter app in Delphi that decompresses the image? Then you are free to use whatever compression library (e.g. SharpZipLib) supporting .Net within your C# code.

据我所知,没有.Net Framework等同于TDecompressionStream类。您是否能够在Delphi中编写一个解压缩图像的小转换器应用程序?然后,您可以在C#代码中*使用支持.Net的任何压缩库(例如SharpZipLib)。

#3


If you have to keep the same compression already used, roll the Delphi decompression routine into a DLL and use it from C# using PInvoke.

如果必须保持已经使用的相同压缩,请将Delphi解压缩例程转换为DLL并使用PInvoke从C#中使用它。

If you want to replace the compression, write a batch process to extract the Delphi compressed images, decompress them to their original format and re-compress them with your favourite C# library.

如果要替换压缩,请编写批处理以提取Delphi压缩图像,将其解压缩为原始格式,然后使用您喜欢的C#库重新压缩它们。