C++:使用 fread 和 fwrite 循环复制 bmp,导致输出 bmp 填充输入 bmp 中第一个 bmp 的颜色

发布于 2024-08-13 19:14:57 字数 241 浏览 15 评论 0原文

我不知道为什么,但第一个像素(左下)已正确加载,但其他像素不会加载,并且第一个颜色用于整个图片...

我在循环

fread(&pix,sizeof(pix),1,pictureIn);
fwrite(&pix,sizeof(pix),1,pictureOut);

编辑中有这个:

pix 是三个无符号字符的结构(rgb ),加载文件和信息头似乎没问题

I dunno why, but first pixel (left bottom) is loaded correctly, but the others won't load and the first color is used for whole picture...

I have this in cycle

fread(&pix,sizeof(pix),1,pictureIn);
fwrite(&pix,sizeof(pix),1,pictureOut);

edit:

pix is struct of three unsigned chars (rgb), loading file and info header seems to be ok

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潜移默化 2024-08-20 19:14:57

您使用什么操作系统?我最近在 Win32 下读取二进制文件时遇到问题。事实证明,我忘记将“b”标志传递给 fopen:

pictureIn = fopen ("in.bmp", "rb");
pictureOut = fopen ("out.bmp", "wb");

What OS are you using? I recently had problem with reading binary files under Win32. It turned out that I forgot to pass "b" flag to fopen:

pictureIn = fopen ("in.bmp", "rb");
pictureOut = fopen ("out.bmp", "wb");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文