• 大小: 66KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: C#
  • 标签: LSB  

资源简介

基于C#窗体程序编写的LSB数字水印算法,操作对象为任意的bmp格式图片。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private int flag = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void label1_Click(object sender EventArgs e)
        {

        }

        private void button1_Click(object sender EventArgs e)
        {
            OpenFileDialog filedlg = new OpenFileDialog();
            filedlg.Filter = “位图(*.bmp)|*.bmp“;
            if (filedlg.ShowDialog() == DialogResult.OK)
            {

                textBox1.Text = filedlg.FileName;
                pictureBox1.ImageLocation = textBox1.Text;
            }
        }

        private void button2_Click(object sender EventArgs e)
        {

        }

        private void button4_Click(object sender EventArgs e)
        {
            OpenFileDialog filedlg = new OpenFileDialog();
            filedlg.Filter = “位图(*.bmp)|*.bmp“;
            if (filedlg.ShowDialog() == DialogResult.OK)
            {

                textBox3.Text = filedlg.FileName;
                pictureBox2.ImageLocation = textBox3.Text;

            }
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (textBox1.Text == ““)
                MessageBox.Show(“请先选择图片“ “警告“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
            else if (flag == 0)
                MessageBox.Show(“请先确认需要嵌入的水印信息“ “警告“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
            else
            {
                string s;
                s = textBox2.Text;
                char[] c = new char[s.Length];
                int i j;
                for (i = 0; i < s.Length; i++)
                    c[i] = Convert.ToChar(s[i]);
                int[] temp = new int[(s.Length + 2) * 16];//temp按位存储水印信息对应的字符,+2是给开始和结束的标识符,c#采用Unicode编码占两个字节16位


                for (i = 0; i < 16; i++)
                    temp[i] = Convert.ToInt32(0x0001 & ‘#‘ >> i);
                for (j = 0; j < s.Length; j++)
                    for (i = 0; i < 16; i++)
                        temp[16 * (j + 1) + i] = Convert.ToInt32(0x0001 & c[j] >> i);
                for (i = 0; i < 16; i++)
                    temp[16 * (j + 1) + i] = Convert.ToInt32(0x0001 & ‘#‘ >> i);
                //读取文件     
                FileStream fs = new FileStream(textBox1.Text FileMode.Open FileAccess.ReadWrite);
                BinaryReader r = new BinaryReader(fs);
                BinaryWriter w = new BinaryWriter(fs);
                byte info;
                if (fs.Length < (s.Length + 2) * 16 + 54)
                {
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-09-23 10:34  WindowsFormsApplication1\
     目录           0  2015-10-13 09:16  WindowsFormsApplication1\WindowsFormsApplication1\
     文件         187  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\App.config
     文件       13195  2015-10-12 14:05  WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
     文件        6552  2015-10-13 09:16  WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
     文件        5817  2015-10-12 14:05  WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
     文件         536  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Program.cs
     目录           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\
     文件        1372  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs
     文件        2900  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs
     文件        5612  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx
     文件        1111  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs
     文件         249  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings
     文件        3828  2015-09-23 22:10  WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj
     目录           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\bin\
     目录           0  2015-09-23 22:10  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\
     文件       14848  2015-10-13 09:16  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
     文件         187  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
     文件       30208  2015-10-13 09:16  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
     文件       24224  2015-11-04 13:53  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
     文件         187  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config
     文件         490  2015-07-10 19:01  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
     目录           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\obj\
     目录           0  2015-10-13 09:16  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\
     文件        1453  2015-09-24 09:46  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7233  2015-09-23 10:44  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2015-11-04 13:57  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TempPE\
     文件           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2015-09-23 10:34  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     文件         180  2015-10-12 14:05  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
............此处省略8个文件信息

评论

共有 条评论