i have problem with my image steganography code as it increases the size of the image after embeding the text.....for example if i load 10 kb pic as a input and embed 1 kb of text file then the resultent file size will be 150 kb aprox....thanks in advance
what is wrong with this piece of code???
public static Bitmap embedText(string text, Bitmap bmp)
{
State s = State.hiding;
int charIndex = 0;
int charValue = 0;
long colorUnitIndex = 0;
int zeros = 0;
int R = 0, G = 0, B = 0;
for (int i = 0; i < bmp.Height; i++)
{
for (int j = 0; j < bmp.Width; j++)
{
Color pixel = bmp.GetPixel(j, i);
pixel = Color.FromArgb(pixel.R - pixel.R % 2,
pixel.G - pixel.G % 2, pixel.B - pixel.B % 2);
R = pixel.R; G = pixel.G; B = pixel.B;
for (int n = 0; n < 3; n++)
{
if (colorUnitIndex % 8 == 0)
{
if (zeros == 8)
{
if ((colorUnitIndex - 1) % 3 < 2)
{
bmp.SetPixel(j, i, Color.FromArgb(R, G, B));
}
return bmp;
}
if (charIndex >= text.Length)
{
s = State.filling_with_zeros;
}
else
{
charValue = text[charIndex++];
}
}
switch (colorUnitIndex % 3)
{
case 0:
{
if (s == State.hiding)
{
R += charValue % 2;
charValue /= 2;
}
} break;
case 1:
{
if (s == State.hiding)
{
G += charValue % 2;
charValue /= 2;
}
} break;
case 2:
{
if (s == State.hiding)
{
B += charValue % 2;
charValue /= 2;
}
bmp.SetPixel(j, i, Color.FromArgb(R, G, B));
} break;
}
colorUnitIndex++;
if (s == State.filling_with_zeros)
{
zeros++;
}
}
}
}
return bmp;
}