开发者

How can I do LZW decoding in Java?

I have a database which contains picture data stored as a binary blob. The documentation says the data is encoded using LZW开发者_如何学Go. I thought that I could decode it using the Zip or GZip input streams found in the Java library, but it didn't work - I got an exception that said the format of the data is not correct.

From what I've read, the library uses DEFLATE, which is not LZW. Also, I've read about some licensing problems for using the LZW algorithm.

What can I use to decode the data? Is there a library? Do I have to implement it myself? What about the licensing problems?


I know the question is old, but I just wanted to add a great resource about LZW:

http://www.matthewflickinger.com/lab/whatsinagif/lzw_image_data.asp

It's more specifically about the use of LZW in GIF images, but it explains the compression and decompression algorithms pretty well.


Here are a couple of links:

  • http://www.cs.sfu.ca/CC/365/li/squeeze/LZW.html

  • http://u.cs.biu.ac.il/~freskom1/AlgProg1/Progs/LZW.java

  • http://www.codeproject.com/KB/java/lzw.aspx

And there are others.

Indeed if the images are LZW compressed TIFF files, The Java Advanced Imaging API apparently supports decoding directly (though not encoding it seems).


You can also try with 7-Zip JBinding which uses the 7zip library internally. It's quite easy to use.


I went through a surprising amount of LZW implementations before finding one that worked for my case.

UncompressedInputStream from the BioJava project worked for me, when I needed to unpack a .pax file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜