M
margec3
when i reconstruct the bitmap from the byte array (memory stream) sent
by the server, i realized the pixels are not exactly the same as the
ones sent from the server, which matters to me because i am doing
image steganography, and i am hiding encrypted data in the R component
of some pixels. i wonder if the compact framework Bitmap class is
doing some quiet conversion, can someone shed some light about this
and it will be even more helpful, if someone can tell me how i can
recover the exact bitmap sent by the server?
thanks a lot!
======================= details
// at server, bitmapStream is a MemoryStream that i put together by
converting a gif file from indexed pixel format to raw (A)RBG format
Bitmap carrierBitmap = new Bitmap(bitmapStream);
// store encrypted data at the 'R' element of pixels at various
positions of carrierBitmap (i am doing image steganography)
// save the worked up bitmap back to memory stream
bitmapStream.Flush();
carrierBitmap.Save(bitmapStream,
System.Drawing.Imaging.ImageFormat.Png);
//******* examine pixels of the first 10 worked up positions of the
result bitmap (to be compared with the one recovered by the client
later)
// convert memory stream to byte array
byte[] embeddedBuf = bitmapStream.ToArray();
// send byte array to pocket PC client
// recover the memory stream at client
Bitmap carrierBitmap = new Bitmap(bitmapStream);
//******* examine pixels of the first 10 positions of the recovered
bitmap, and they're different, not just the R value that i need to
recover the original data with, but G and B too!!
=======================
this is how i converted an image in indexed pixel format (gif file) to
raw (A)RBG format:
public static MemoryStream convertBitmap(string fileName)
{
Bitmap myImage = new Bitmap(fileName);
int imageSize = myImage.Width * myImage.Height;
MemoryStream ms = new MemoryStream(imageSize);
myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Bitmap resultImage = new Bitmap(myImage.Width,
myImage.Height);
Graphics resultG = Graphics.FromImage(resultImage);
resultG.DrawImage(myImage, 0, 0);
ms.Flush();
resultImage.Save(ms,
System.Drawing.Imaging.ImageFormat.Png);
return ms;
}
===========
by the server, i realized the pixels are not exactly the same as the
ones sent from the server, which matters to me because i am doing
image steganography, and i am hiding encrypted data in the R component
of some pixels. i wonder if the compact framework Bitmap class is
doing some quiet conversion, can someone shed some light about this
and it will be even more helpful, if someone can tell me how i can
recover the exact bitmap sent by the server?
thanks a lot!
======================= details
// at server, bitmapStream is a MemoryStream that i put together by
converting a gif file from indexed pixel format to raw (A)RBG format
Bitmap carrierBitmap = new Bitmap(bitmapStream);
// store encrypted data at the 'R' element of pixels at various
positions of carrierBitmap (i am doing image steganography)
// save the worked up bitmap back to memory stream
bitmapStream.Flush();
carrierBitmap.Save(bitmapStream,
System.Drawing.Imaging.ImageFormat.Png);
//******* examine pixels of the first 10 worked up positions of the
result bitmap (to be compared with the one recovered by the client
later)
// convert memory stream to byte array
byte[] embeddedBuf = bitmapStream.ToArray();
// send byte array to pocket PC client
// recover the memory stream at client
Bitmap carrierBitmap = new Bitmap(bitmapStream);
//******* examine pixels of the first 10 positions of the recovered
bitmap, and they're different, not just the R value that i need to
recover the original data with, but G and B too!!
=======================
this is how i converted an image in indexed pixel format (gif file) to
raw (A)RBG format:
public static MemoryStream convertBitmap(string fileName)
{
Bitmap myImage = new Bitmap(fileName);
int imageSize = myImage.Width * myImage.Height;
MemoryStream ms = new MemoryStream(imageSize);
myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Bitmap resultImage = new Bitmap(myImage.Width,
myImage.Height);
Graphics resultG = Graphics.FromImage(resultImage);
resultG.DrawImage(myImage, 0, 0);
ms.Flush();
resultImage.Save(ms,
System.Drawing.Imaging.ImageFormat.Png);
return ms;
}
===========