2

みんなおはよう、

私は大学向けのイメージ ステガノグラフィ プロジェクトを作成しています。画像にデータを隠しながら。Int32 である「テキストの長さ」をピクセル単位で書いています。Int32 は 4 バイトなので。各色が1バイトなので、アルファ、レッド、グリーン、ブルーの4バイトで書けると思っていました。次に、画像を bmp 形式で保存します。シングル ステッピングを使用すると、データが適切に分散され、ピクセルに設定されます。

ピクセルを読み返すと問題が発生します。R、G、B は、私が設定した値を持っています。ただし、設定に関係なく、アルファは常に 255 です。

Int32 を 4 バイトに分散するために使用しているコードは次のとおりです。

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);

値を戻すためのコードは

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 がアルファ値の持続を許可していないということですか??? 助けてください。ありがとう。

4

1 に答える 1

1

申し訳ありませんが、Bitmap はアルファ値をサポートしていません。

于 2013-04-18T08:27:05.957 に答える