pngpp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pngpp-devel] Re: Steganographic in PNG


From: Alexander Shulgin
Subject: [pngpp-devel] Re: Steganographic in PNG
Date: Mon, 10 Nov 2008 13:48:33 +0200

On Sat, Nov 8, 2008 at 9:38 PM, Sebastian Camjayi <address@hidden> wrote:
> 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.

Sorry, no time to read your code now--may be later. :)

> 2) If I write the image with the write function, Will i be able to access
> the bits hidden in the picture?

Well... yes.  Why do you think you won't?

> 3) Can i write in the same path where i am reading?

Yes.  After you read the image in png::image<> constructor the file is
no longer touched by png++.  You can do image.write() to the same path
w/o any trouble.

> 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?.

Short answer--because PNG is compressed format.  If you've changed
some pixels in e.g. .bmp file, the size won't change.  With PNG it
might change substantially due to compression technique used: it
normally compresses difference between consecutive image rows.

--
Regards,
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]