同时节省了位图的Alpha值不坚持位图、时节、省了、Alpha

2023-09-04 01:06:02 作者:酒心可可

早上好一切,

我想提出一个图像信息隐藏的项目上大学。 虽然藏在图像数据。我写的文本长度,这是一个Int32的像素。作为的Int32是4字节。我想我可以把它写在4个字节Alpha,红,绿,蓝,每个颜色是1个字节。 然后我保存为BMP格式的图像。 我用单步执行和数据得到正确分布和设置在像素。

I am making an Image Steganography project for college. While hiding data in image. I am writing the "Text Length" which is an Int32 in a pixel. As Int32 is of 4 bytes. I thought I could write it in the 4 bytes of Alpha,Red,Green,Blue, as each color is of 1 byte. Then I save the image in bmp format. I used single stepping and data get properly distributed and set in the pixel.

在出现问题时,我回读像素。 R,G,B有自己的价值,我已经设置。但阿尔法始终是255不管它被设置。

The problem arise when I read back the pixel. R,G,B have their value as i had set them. But the alpha is always 255 no matter what it was set.

code

byte R, G, B, A;
int colorValue = messageLength;
int first = colorValue & 255;
//R contains bit 0-7 means the least significant 8 bits
R = (byte)first;
colorValue = colorValue - first;
int second = colorValue & 65535;
colorValue = colorValue - second;
second = second >> 8;
//G contains 8-15
G = (byte)second;
int third = colorValue & 16777215;
colorValue = colorValue - third;
third = third >> 16;
//B contains 16-23
B = (byte)third;
colorValue = colorValue >> 24;
//A contains 24-31
A = (byte)colorValue;
pixelColor = Color.FromArgb(A, R, G, B);
bitmap.SetPixel(location.X, location.Y, pixelColor);

code获取的值恢复为

Code for getting the values back is

byte R, G, B, A;
R = pixelColor.R;
G = pixelColor.G;
B = pixelColor.B;
A = pixelColor.A;

messageLength = A;
messageLength = messageLength << 8;
messageLength += B;
messageLength = messageLength << 8;
messageLength += G;
messageLength = messageLength << 8;
messageLength += R;

有我丢失的东西。难道BMP不允许Alpha值持续??? 请帮忙。 谢谢你。

Is there something I am missing. Is it that BMP does not allow alpha value to persist??? Please help. Thanks.

推荐答案

抱歉地说,位图不支持Alpha值。

Sorry to say that Bitmap doesn't support an alpha value.