2

谁能告诉我您是否知道 WM 6 的位图和隐写术存在问题?

我正在做一个项目,我必须在位图中隐藏数字签名。该算法完美无缺,因为直到我将图像放在内存中,位图才包含修改后的字节。但是在我保存图像(Bitmap.Save())并重新打开图像之后,这些字节就会丢失。当我说丢失时,我的意思是它们是拍摄照片时的原始字节。

谢谢你。

这是保存方法:

    {
        if (miSave.Enabled == false)
        {
            MessageBox.Show("Error, no image is opened. ", "Save Error");
        }
        else
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Bitmap|*.bmp|JPEG|*.jpg";

            if (sfd.ShowDialog() == DialogResult.OK)
            {

                if (sfd.FileName != "")
                {
                    Bitmap origImage = pictureBox.GetBitmap();
                    ///just a test to see that the bytes are the modified ones..and they are
                    byte[] origImageByte = ImageProcessing.ConvertBitmapToByteArray(origImage, origImage.Height * origImage.Width +54); 
                    origImage.Save(sfd.FileName, formatOfImage);
                    MessageBox.Show("Succesfully ", "Image Saved");

                }

            }
        }
    }

和开放方法

    {
        if (pictureBox.Visible == false)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();

                dlg.Filter = "Bitmap|*.bmp|JPEG|*.jpg";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Bitmap img = new Bitmap(dlg.FileName);


                    initialSize.Width = img.Width;
                    initialSize.Height = img.Height;

                    imageOpened();//this just does does some enabling buttons nothing more

                    pictureBox.SetBitmap(img, pixelSize);
                    pictureBox.ShowImage(img);

                    trackBar.TrackBarPosition(lblMinVal, lblMaxVal, this.Size);
                }
            }
            catch
            {
                DialogResult res = MessageBox.Show("Failed loading image");
            }
        }

}

4

2 回答 2

0

首先,“最低有效位”实际上是正确的。最低有效位是每个 R、G、B 和可能 A 通道中的最低有效位,每个通道都包含 32 位位图中的一个字节。

其次,您发布了“保存”和“打开”代码——您可以发布您实际更改位图数据的代码吗?如果您没有修改pictureBox 对象中的位,那么您确实只是保存了原始图像,因为 open 方法将数据放在此处。

于 2010-08-11T03:23:45.893 回答
0

您在评论中提到您只是在修改 LSB。我假设您的意思是最低有效字节(而不是最低有效),如果有这样的话。

.Net 中的标准Bitmap是每像素 32 位,R、G 和 B 分量各占 1 个字节,alpha 通道占 1 个字节,这通常被解释为支持透明度的设备中的透明度。

您可能只是在修改 alpha 通道值,并且由于 Compact Framework 图片框不支持透明度(我认为),因此Bitmap看起来与最初完全相同。

尝试修改一些不同的字节,你应该会看到不同。

于 2010-04-07T02:34:23.330 回答