Lua的LZW减压

时间:2017-05-14 17:52:31

标签: lua gif lzw

如何将Lua中的LZW Compressed Gif数据解压缩为单个Gif帧中每个像素的索引数组? 我目前正在研究Gif解码器,这样我就可以在屏幕上显示任何89a版本的Gif动画,而无需使用某种文件上传方法来进行游戏资产。然而,我唯一还不能读到的是LZW压缩数据。我已经拥有LZW最小代码大小和图像数据中的#Bytes。我从中得到了它们。

我感觉非常愚蠢,但我无法弄清楚我抬起来的其他东西发生了什么,所以请求帮助。

--in a loop for each sub-block
local n,e = 0,1
local max = (2^fbs)-1
--stream is a string containing the reversed binaries in order and combined of each byte in the section
--fbs is first byte size (lzw min code size + 1)
while n<=#stream do --this sub-block
    n=n+fbs-1
    local bits = stream:sub(e,n) --pulls out next section
    if binVal(bits)==max then --checks binary value and increases fbs
        fbs=fbs+1
        max=(2^fbs)-1
    end
    --what do i do with the bytes pulled???
    e=n+1
end

0 个答案:

没有答案