【发布时间】:2011-09-27 18:35:09
【问题描述】:
我在玩隐写术。我正在尝试从图像中提取文本文件。我能够读取文件,获取位,但我在提取这些位时遇到问题。
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 i = 0; i<4; ++i) {
curChar = curChar << 2;
curChar = curChar | getbits(postion);
}
return curChar;
}
像素是一个无符号字符。我有调用extract() 和fputc(3) 返回值的循环。我觉得我从这些碎片中得到了垃圾。这导致我有大量 (1.5 gig) txt 文件作为回报。
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; i < 16; ++i)
{
length = length << 2;
length = length | getbits(*pgm->image);
}
if ((length* 4) < (pgm->width * pgm->height))
{
fatal("File Too Big");
}
for (i = 0 ;i<length; ++i)
{
fputc(extract(pgm->image), outstream);
}
fclose(outstream);
}
【问题讨论】:
-
速记或隐写术 ?
-
显示调用提取的循环 - 因为您应该证明您正确地循环图像。
-
@borrible 我包含了循环
标签: c bit-manipulation steganography