作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试隐写术。我正在尝试从图像中提取文本文件。我能够读取该文件,获取这些位,但我在提取这些位时遇到问题。
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;
}
Pixel 是一个无符号字符。我有一个循环调用 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);
}
最佳答案
您实际上只是读取图像中的第一个像素 - [编辑],因为当您尝试使用静态变量来保持计数时,正如 Oli 指出的那样,您会立即覆盖它。
而是使用位置来跟踪您的计数;但将数据保存在另一个变量中:
相反,extract()
应该类似于:
char extract ( pixel* image )
{
static int postion = 0;
pixel data = image[position];
postion++;
// use 'data' for processing
}
关于c - 位提取和隐写术,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6565510/
本文分享自华为云社区《华为大咖说 | 企业应用AI大模型的“道、法、术” ——道:认知篇》,作者:华为云PaaS服务小智。 本期核心观点 上车:AGI是未来5~10年内,每个人都无法回避的技
有人可以解释一下“Forever Frame”技术是如何工作的吗?代码示例会很棒!我浏览了在 Google 中可以找到的所有 Material ,但我仍然不太了解它是如何工作的。 最佳答案 迪伦·希曼
我是一名优秀的程序员,十分优秀!