c - Bit extraction and Steganography -


i playing around steganography. trying pull text file image. able read file, bits, have issue extraction of these bits.

int getbits( pixel p) {     return p & 0x03;    }  char extract ( pixel* image ) {     static int postion;     postion = 0;      postion = *image;      postion++;      char curchar;     curchar = '\0';     for(int = 0; i<4; ++i) {         curchar = curchar << 2;         curchar = curchar | getbits(postion);     }     return curchar; } 

pixel unsigned char. have loop calls extract() , fputc(3) return value. feel getting garbage these bits. causes me have massive (1.5 gig) txt files in return.

void decode( pgmtype* pgm, char output[80] ) { file*outstream; int i, length;  outstream = fopen(output, "w");  if(!outstream) {     fatal("could not open"); } for(i=0; < 16; ++i) {     length = length << 2;     length = length | getbits(*pgm->image); } if ((length* 4) < (pgm->width * pgm->height)) {     fatal("file big"); } (i = 0 ;i<length; ++i) {     fputc(extract(pgm->image), outstream);  } fclose(outstream);  } 

you reading first pixel in image - [edit] because while trying use static var keep count, oli points out you're overwriting it.

instead use position track count; hold data in var:

instead extract() should like:

char extract ( pixel* image ) {    static int postion = 0;     pixel data = image[position];     postion++;     // use 'data' processing } 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -