public override void Write(byte[] buffer, int offset, int count) { if (count > Length - Position) { throw new IndexOutOfRangeException(); } for (var i = 0; i < count; i++) { for (var j = 0; j < 8; j++) { WriteBit((int)Position * 8 + j, BitHelper.GetBit(buffer[offset + i], j)); } Position++; } }
private void Encrypt(JBLOCK[][][] coefficients, byte[] data) { var l = JpegHelper.GetLength(coefficients); Console.Out.WriteLine($"Capacity = {l / 8}"); Console.Out.WriteLine("Used = {0}", data.Length); for (var i = 0; i < data.Length; i++) { for (var j = 0; j < 8; j++) { var block = JpegHelper.GetBlock(coefficients, i * 8 + j); block[0] = EncryptShort(block[0], BitHelper.GetBit(data[i], j)); } } }
/// <summary> /// Function maps current brick code to roteted one /// </summary> /// <param name="left">true - rotate left, false - rotate right</param> /// <returns>roteted brick code</returns> public int RotateBrick(bool left) { int newCode = 0; if (left) { for (int i = 0; i < rotateLeftMap.Length; i++) { newCode |= BitHelper.GetBit(BrickCode, rotateLeftMap[i]) << i; } } else { for (int i = 0; i < rotateLeftMap.Length; i++) { newCode |= BitHelper.GetBit(BrickCode, i) << rotateLeftMap[i]; } } return(newCode); }