Ejemplo n.º 1
0
        byte[] UnpackChannel(int channel)
        {
            var output    = new byte[m_output.Length / 3];
            var count_key = new ErpKey(m_info.Id ^ 0x68, DefaultKey[6, m_info.KeyIndex, m_info.Id]);
            var pixel_key = new ErpKey(DefaultKey[channel, m_info.KeyIndex, m_info.Id],
                                       DefaultKey[channel + 3, m_info.KeyIndex, m_info.Id]);
            int dst = 0;

            for (;;)
            {
                int px    = m_input.ReadByte();
                int count = m_input.ReadByte();
                if (count < 0)
                {
                    break;
                }
                count ^= count_key.Value ^ 0xE9;
                if (0 == count)
                {
                    break;
                }
                count = Math.Min(count, output.Length - dst);
                byte v = (byte)(px ^ pixel_key.Value);
                while (count-- > 0)
                {
                    output[dst++] = v;
                }

                count_key.Increment();
                pixel_key.Increment();
            }
            return(output);
        }
Ejemplo n.º 2
0
        void UnpackV0()
        {
            var count_key = new ErpKey(m_info.Id ^ 0x68, DefaultKey[6, m_info.KeyIndex, m_info.Id]);
            var r_key     = new ErpKey(DefaultKey[0, m_info.KeyIndex, m_info.Id],
                                       DefaultKey[3, m_info.KeyIndex, m_info.Id]);
            var g_key = new ErpKey(DefaultKey[1, m_info.KeyIndex, m_info.Id],
                                   DefaultKey[4, m_info.KeyIndex, m_info.Id]);
            var b_key = new ErpKey(DefaultKey[2, m_info.KeyIndex, m_info.Id],
                                   DefaultKey[5, m_info.KeyIndex, m_info.Id]);
            var rgb = new byte[3];
            int dst = 0;

            while (dst < m_output.Length)
            {
                m_input.Read(rgb, 0, 3);
                int count = m_input.ReadByte();
                if (count < 0)
                {
                    break;
                }
                count ^= count_key.Value ^ 0xE9;
                if (count > 0)
                {
                    m_output[dst++] = (byte)(rgb[0] ^ b_key.Value);
                    m_output[dst++] = (byte)(rgb[1] ^ g_key.Value);
                    m_output[dst++] = (byte)(rgb[2] ^ r_key.Value);
                    count           = Math.Min((count - 1) * 3, m_output.Length - dst);
                    if (count > 0)
                    {
                        Binary.CopyOverlapped(m_output, dst - 3, dst, count);
                        dst += count;
                    }
                }
                r_key.Increment();
                g_key.Increment();
                b_key.Increment();
                count_key.Increment();
            }
        }
Ejemplo n.º 3
0
        void UnpackV1()
        {
            var count_list = new List <int>();
            var count_key  = new ErpKey(m_info.Id ^ 0x68, DefaultKey[6, m_info.KeyIndex, m_info.Id]);
            int count;

            while ((count = m_input.ReadByte()) >= 0)
            {
                count ^= count_key.Value ^ 0xE9;
                if (0 == count)
                {
                    break;
                }
                count_list.Add(count);
                count_key.Increment();
            }
            int order = m_info.Method - 1;

            for (int i = 0; i < 3; ++i)
            {
                int channel   = ChannelOrder[order, i];
                var pixel_key = new ErpKey(DefaultKey[channel, m_info.KeyIndex, m_info.Id],
                                           DefaultKey[channel + 3, m_info.KeyIndex, m_info.Id]);
                int dst = 2 - channel;
                for (int j = 0; j < count_list.Count; ++j)
                {
                    count = count_list[j];
                    int  px = m_input.ReadByte();
                    byte v  = (byte)(px ^ pixel_key.Value);
                    while (count-- > 0)
                    {
                        m_output[dst] = v;
                        dst          += 3;
                    }
                    pixel_key.Increment();
                }
            }
        }