CompressedLength() 공개 메소드

public CompressedLength ( byte data ) : int
data byte
리턴 int
        static void Test(Compression compression, string originalFile, string report)
        {
            BinaryReader br = new BinaryReader(File.OpenRead(originalFile));
            byte[] file = br.ReadBytes((int)br.BaseStream.Length);
            br.Close();

            int[] offsetsToTest = compression.Scan(file, 0, file.Length, 4, 0, file.Length);
            int i;
            List<int> differentOffsets = new List<int>(50);

            for (i = 0; i < offsetsToTest.Length; i++)
            {
                bool success = true;
                byte[] data = compression.Compress(compression.Decompress(file, offsetsToTest[i]));
                byte[] data2 = new byte[compression.CompressedLength(file, offsetsToTest[i])];
                Array.Copy(file, offsetsToTest[i], data2, 0, data2.Length);
                success = data.Length <= data2.Length;
                /*for (int j = 0; j < data.Length && success; j++)
                        success = data[j] == data2[j];*/
                if (!success)
                    differentOffsets.Add(offsetsToTest[i]);

            }

            if (differentOffsets.Count == 0)
            {
                messagePoster("No differences were found.");
            }
            else
            {
                messagePoster("There is a difference.");
                StreamWriter sw = new StreamWriter(report, false);
                for (int j = 0; j < differentOffsets.Count; j++)
                {
                    sw.WriteLine(Convert.ToString(differentOffsets[j], 16));
                }
                sw.Close();
            }
        }
        static void CompLength(Compression compression, string input, int offset)
        {
            if ((compression.supportedModes & CompressionOperation.CompLength) == CompressionOperation.None)
            {
                messagePoster("Compression type doesn't support length checking.");
                return;
            }
            byte[] file;
            try
            {
                BinaryReader br = new BinaryReader(File.OpenRead(input));
                file = br.ReadBytes((int)br.BaseStream.Length);
                br.Close();
            }
            catch(IOException)
            {
                messagePoster("Error while opening the file.");
                return;
            }

            if (offset > file.Length)
                messagePoster("Offset is larger than the size of the file.");
            else
            {
                int result = compression.CompressedLength(file, offset);
                if (result == -1)
                    messagePoster("Data can't be decompressed");
                else
                    messagePoster("Length of the compressed data is: 0x" + Convert.ToString(result,16));
            }
        }