private void addMessageButton_Click(object sender, EventArgs e) { if (AddingMessageBox.Text.Length == 0) return; var bytes = BitmapHelper.BitmapToByteRgbMarshal(picture); var lsb = new LsbMethod(bytes, usingBits); lsb.WriteLongInt(prefix); lsb.WriteInt(AddingMessageBox.Text.Length * 2); lsb.WriteString(AddingMessageBox.Text); BitmapHelper.ByteToBitmapRgbMarshal(picture, lsb.Data); pictureBox.Image = picture; lsb = new LsbMethod(BitmapHelper.BitmapToByteRgbMarshal(picture), usingBits); var readPrefix = lsb.ReadLongInt(); if (readPrefix != prefix) { MessageBox.Show("Error occured while adding message.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var readLengthMessage = lsb.ReadInt(); var readMessage = lsb.ReadMessage(readLengthMessage); AddedMessageBox.Text = readMessage; }
private void openButton_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.Cancel) return; AddedMessageBox.Text = String.Empty; AddingMessageBox.Text = String.Empty; picture = BitmapHelper.LoadBitmap(openFileDialog.FileName); pictureBox.Image = picture; var lsb = new LsbMethod(BitmapHelper.BitmapToByteRgbMarshal(picture), usingBits); var readPrefix = lsb.ReadLongInt(); BitmapHelper.ByteToBitmapRgbMarshal(picture, lsb.Data); if (readPrefix != prefix) { MessageBox.Show("Added message not found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var readLengthMessage = lsb.ReadInt(); var readMessage = lsb.ReadMessage(readLengthMessage); AddedMessageBox.Text = readMessage; }