使用方法如下:
源代码打包上传,欢迎下载使用.
源代码下载地址
http://download.youkuaiyun.com/detail/aerror/3898251
public static function decode(src:ByteArray) : ByteArray
{
if (src == null || src.length < 16)
{
return null;
}
var inStream:InputStream = new InputStream(src);
var propertiesSize:int = 5;
var properties:Vector.<uint> = new Vector.<uint>(propertiesSize);
if (inStream.readVOL(properties, 0, propertiesSize) != propertiesSize)
return null;
var decoder:Decoder = new Decoder();
if (!decoder.SetDecoderProperties(properties))
return null;
var outSize:uint = 0;
for (var i:int = 0; i < 8; i++)
{
var v:int = inStream.read();
if (v < 0)
return null;
outSize |= (v << (8 * i));
}
var ret:ByteArray = new ByteArray();
ret.length = outSize;
var outStream:OutputStream = new OutputStream(ret);
if (!decoder.Code(inStream, outStream, outSize))
return null;
inStream.close();
outStream.close();
ret.position =0;
return ret;
}