Could use some help with BMP Steganography
What I am intending to do is encode data into the 4 least significant bits of each blue sample of every pixel regardless of bits per pixel in a BMP file. Lets assume 24 bits per pixel however. I am posting the relevant loop which seems to be troublesome. The file gets duplicated however it's an exact copy of the original (confirmed with hex editor). Please advise. I can post more of the code if need be:
Code:
do
{
bmp_temp_ptr = bmp_rd_ptr;
if(!(bmp_rd_bytes = fread(bmp_rd_ptr, 1, bmp_row_size, bmp_rd_file)))
break;
for(bmp_row_index = 0; bmp_row_index < bmp_rd_bytes; bmp_row_index++)
{
switch(color)
{
case BLUE:
if(!done)
{
bmp_secret_bits = *bmp_secret++;
*bmp_temp_ptr = (*bmp_temp_ptr & ~(0x0f)) | (bmp_secret_bits & ~0x0f);
if(bmp_info_header->bpp == 24)
{
bmp_temp_ptr += 3;
bmp_row_index += 3;
*bmp_temp_ptr &= ~(0x0f) | ((bmp_secret_bits << 4) & ~0x0f);
}else
{
}
if(!bmp_secret_size--)
done = 1;
}else
continue;
break;
case GREEN:
break;
case RED:
break;
case ALPHA:
break;
}
bmp_info_header->bpp == 32 ? ++color == 4 ? color = 0 : color : ++color == 3 ? color = 0 : color;
bmp_temp_ptr++;
}
fwrite(bmp_rd_ptr, 1,bmp_rd_bytes, bmp_wr_file);
bmp_rd_total += bmp_rd_bytes;
}while(bmp_rd_total <= bmp_pixel_array_size);