/// <summary> /// Old Decompress method not using .NET compressor /// </summary> /// <param name="Data"></param> /// <returns></returns> public byte[] DecompressOld(byte[] Data) { byte[] decompressedPixelData = new byte[UncompressedLength]; // ZLIB if (version > BgfFile.VERSION9) { // init streams MemoryStream destStream = new MemoryStream(decompressedPixelData, true); ZOutputStream destZ = new ZOutputStream(destStream); // decompress destZ.Write(Data, 0, Data.Length); destZ.Flush(); destZ.finish(); // cleanup destStream.Dispose(); destZ.Dispose(); } // CRUSH else { #if WINCLR && X86 // decompress Crush32.Decompress(Data, 0, decompressedPixelData, 0, (int)UncompressedLength, CompressedLength); #else throw new Exception(ERRORCRUSHPLATFORM); #endif } // set decompressed array to pixeldata return(decompressedPixelData); }
/// <summary> /// Returns a decompressed byte[] of PixelData argument /// </summary> /// <param name="Data"></param> /// <returns></returns> public byte[] Decompress(byte[] Data) { byte[] decompressedPixelData = new byte[UncompressedLength]; // ZLIB if (version > BgfFile.VERSION9) { // init sourcestream MemoryStream srcStream = new MemoryStream(Data, false); // must skip two bytes not part of deflate but used by zlib srcStream.ReadByte(); srcStream.ReadByte(); // init .net decompressor DeflateStream destZ = new DeflateStream(srcStream, CompressionMode.Decompress); // decompress destZ.Read(decompressedPixelData, 0, UncompressedLength); // cleanup destZ.Dispose(); srcStream.Dispose(); } // CRUSH else { #if WINCLR && X86 // decompress Crush32.Decompress(Data, 0, decompressedPixelData, 0, (int)UncompressedLength, CompressedLength); #else throw new Exception(ERRORCRUSHPLATFORM); #endif } // set decompressed array to pixeldata return(decompressedPixelData); }