示例#1
0
        public static void WriteFileHead(ref Bitmap image, int dataBitLength, out int?x, out int?y)
        {
            x = 0;
            y = 0;
            List <byte> bitsData = DataConverter.Integer2Bits(dataBitLength);

            byte[] data = DataConverter.Bits2Bytes(bitsData).ToArray();
            WriteFileBody(ref image, data, (int)x, (int)y);
            x = 0;
            y = 32;
        }
        public void Bits2BytesTest()
        {
            List <byte> bits = new List <byte>()
            {
                1, 0, 0, 0, 0, 0, 0, 0,
                1, 1, 0, 0, 0, 0, 0, 0,
            };

            byte[]      expected = new byte[] { 1, 3 };
            List <byte> actual   = DataConverter.Bits2Bytes(bits);

            CollectionAssert.AreEqual(expected, actual);
        }
示例#3
0
        public static byte[] ReadFileBody(Bitmap image, int dataBitLength, int x, int y)
        {
            try
            {
                List <byte> colorReds = ExtractColorReds(image, dataBitLength, x, y);
                List <byte> bits      = ExtractBitsFromColorRedsLsb(colorReds);
                List <byte> bytes     = DataConverter.Bits2Bytes(bits);

                return(bytes.ToArray());
            }
            catch (Exception)
            {
                throw new PasswordWrongException();
            }
        }