[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pngpp-devel] Steganographic in PNG
From: |
Sebastian Camjayi |
Subject: |
[pngpp-devel] Steganographic in PNG |
Date: |
Sat, 8 Nov 2008 17:38:48 -0200 |
Hi people, i have a problem and maybe you can help me...
I use the library to Hide one message in the image.
For each color component, I set, in the LSB ( Less Significant Bit ) , one bit of the message.
For example:
void PngRGB::Hide(Space* space, Message* msg)
{
png::image<png::rgb_pixel> imageRGB(space->GetFilePath());
fstream fdata(msg->GetFilePath());
long hideBytes = 0;
fdata.seekg(msg->GetHiddenSize());
while(!fdata.eof() && (hideBytes < spaceSize))
{
fdata.read(&dataByte,sizeof(char));
//For each byte of the message, hide in the image components
for(int k=0;k<8;k++)
{
//I get the color component of the current pixel (pixel.red, pixel.green, pixel.blue)
// pixel = image[x][y];
png::byte imgByte = GetColorComponent(imageRGB);
//I set one bit of the messege byte in the Less Significant Bit
imgByte = (imgByte & ~1) | ((dataByte>>(7-k))&1);
// image[x][y] = pixel;
SetNewColorComponentInCurrentPixelCoord(imageRGB ,imgByte);
//Increment color component (if red then now is green)
IncColorComponent(CurrentColorComponent);
//Move to the next pixel.
if(CurrentColorComponent == Red)
IncCurrentPixelPosition(imageRGB);
}
hideBytes++;
}
imageRGB.write(space->GetFilePath());
msg->IncHiddenSize(hideBytes);
fdata.close();
}
Questions:
1) Someone knows a better way to do this?. maybe without access to each pixel.
2) If I write the image with the write function, Will i be able to access the bits hidden in the picture?
3) Can i write in the same path where i am reading?
4) Why the saved image has a size larger than the original?? I need always to the saved image is less than or equal to the
original. Theoretically if I change just a bit, why would it expand the original image?.
Thanks
Sebastian.
- [pngpp-devel] Steganographic in PNG,
Sebastian Camjayi <=