GLUT 创建二进制/RAW 图像文件
我对创建二进制/原始图像文件有疑问。
我已经在 Photoshop 中制作了图像,现在我想将其加载到 C 程序中。 我遵循了本教程 http://www.nullterminator.net/gltexture.html 但我不'不知道如何将我自己的图像转换为 .RAW 文件。
谁能帮我解答这个问题吗?
I have question about creating a binary / raw image file.
I've made an image in photoshop and now I want to load that in a C program.
I followed this tutorial http://www.nullterminator.net/gltexture.html but I don't know how to convert my own image to a .RAW file.
Can anyone help me out with this question?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
下载ImageMagick,它是一个命令行实用程序,可以将图像转换为各种方式。而且它支持很多平台。
因此,您可以将 Photoshop 中的文件保存为 PNG 文件,然后运行以下命令将其转换为原始灰度 8 位:
Download ImageMagick, it is a command-line utility that can convert images into all kind of ways. And it supports many platforms.
So you could save your file in Photoshop to for example a PNG file, then run the following command to convert it to raw grayscale 8 bit:
尝试
另存为
并从格式
下拉列表中选择RAW
。有趣的是,它列在Photoshop RAW
的“P”下。我不知道这是否是 GLUT 所需要的正确类型的 RAW...
Try
Save As
and selectingRAW
from theformat
drop-down. Humorously, it is listed under "P" forPhotoshop RAW
.I don't know if it is the right kind of RAW which GLUT requires...
这对我有用,使用教程代码:
多层,对所有层都执行此操作。 (您必须删除 Alpha 通道,否则 GIMP 将写入 RGBA 而不是 RGB,并且您只会看到重复的格子图案而不是图像。)
然后您应该能够保存它,将其移动到程序的目录,并使用该教程中的代码将其读入。
另外,为了避免另一个令人头疼的来源,我建议在找不到文件时添加一条错误消息,例如将行替换
为
This worked for me, with that tutorial code:
multiple layers, do this for all of them. (You MUST remove the alpha channel or else GIMP will write RGBA instead of RGB, and you'll just see a repeating lattice pattern instead of your image.)
Then you should be able to save it, move it to your program's directory, and read it in with the code from that tutorial.
Also, to save yourself another headache source, I suggest adding an error message if the file isn't found, like replace the line
with