hello,

can anyone help me how to encrypt an image that is how the values in the image are read and saved in a file...

I need to load an image and then the program will extract the pixel values and save it in a file and then the values are encrypted and then decrypted...

Can anyone help me how we can encrypt the image...

Recommended Answers

All 7 Replies

The same way you would encrypt / decrypt anything else.
Your E/D code shouldn't care about the source of the data at all. It's just a stream of bytes.

hmm, in fact i need help to find the codes for extracting the values from an image more precisely jpeg in c++...
i found some of the api & codes for the image extraction but its on java the pixelgrabber() function...
can u help me where to find the codes in c++:- some links

Why do you need to extract the image to encrypt it?

So how can we encrypt the image..
is there any simple method...
if you have another idea please let me know...

You open the input file with fopen
You open the output file with fopen
Until EOF, you read each byte with fgetc, encrypt it, and write it with fputc
You close the input file
You close the output file

What part of those steps requires you to have any knowledge of what the file is for?

Hello,

If you want to encode/decode pixel values into an image, I recommend the EasyBMP library (http://easybmp.sourceforge.net/) .

If you are looking to encrypt/decrypt a file, any file, I recommend using the zlib compression library (http://www.zlib.net/)

Addendum, if you are looking to write your own image encoder/decoder, Wotsit's File Format repository is invaluable (http://www.wotsit.org/). Understand that writing a good library will be very hard though.

Also, if you are looking for a comprehensive image library Magick++, the C++ wrapper for ImageMagick, is a very good choice. http://www.imagemagick.org/Magick++/

Also, Cairo (http://cairographics.org/) is a good choice.

commented: I was looking for this a while now! +5

The easiest way to read image pixel by pixel is:
ifstream im("image.bmp",ios::in|ios::binary);//just to open some image as binary file
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;//this two components are in a lib <windows.h>
im.read((char*)(&bfh),sizeof(bfh));
im.read((char*)(&bih),sizoef(bih));
RGBQUAD map[bih.biHeight][bih.biWidth];//just create some map wich will store pixels
for(int i = 0;i<bih.biHeight;i++){
for(int j = 0;j<bih.biWidth;j++){
im.read((char*)(&map[j]),sizeof(RGBQUAD));
//so step by step read exact pixel colors and so on ....
}
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.