在 DS 上将颜色数据数组保存为 PNG 文件
我正在寻找一个库来将颜色数据数组保存到 PNG 文件。 (这就是全部,对吧?我对 PNG 的内部结构知之甚少。)
这是用于 Nintendo DS 开发的,所以轻量级的东西更好。 我不需要任何其他花哨的功能,例如旋转等。
I'm looking for a library to save an array of colour data to a PNG file. (That's all there is to it, right? I know very little about the internals of a PNG.)
This is for use in Nintendo DS development, so something lightweight is preferable. I don't need any other fancy features like rotation, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要对任何类型的 PNG 文件进行编码,libpng 是最佳选择。
然而,在像 DS 这样的小型设备上,您确实希望以显示硬件期望的格式存储图像数据。 从技术上讲,让 libpng 在该平台上工作是可行的,但它会在加载时间和占用空间方面增加大量开销。
To encode any kind of PNG file, libpng is the way of the walk.
However, on small devices like the DS you really want to store your image data in the format which the display hardware expects. It is technically possible to get libpng working on the platform, but it will add significant overhead, both in terms of loadtimes and footprint.
你看过libpng吗? http://www.libpng.org/pub/png/libpng.html
我不确定内存占用是否可以接受,但您可能应该知道 PNG 文件涉及的不仅仅是颜色数组。 性能可能是 DS 的一个问题。
如果你使用 libpng,你还需要 zlib,如果你使用 DevKitPro,你可能会遇到一些缺失的函数(通过玩代码 5 分钟,看起来它依赖于 pow() ,似乎不在 libnds 中。)我不知道官方 Nintendo SDK 以标准库的方式提供了什么 - 如果您正在使用它,您可能会处于更好的状态。
Have you looked at libpng? http://www.libpng.org/pub/png/libpng.html
I'm not sure whether the memory footprint will be acceptable, but you should probably be aware that PNG files are a lot more involved than just an array of colors. Performance is likely to be a concern on a DS.
If you go with libpng, you'll also need zlib, and if you're using DevKitPro, you'll probably run into some missing functions (from playing with the code for 5 minutes, it looks like it relies on pow() which doesn't seem to be in libnds.) I have no idea what the official Nintendo SDK offers in the way of a standard library - you might be in better shape if that's what you're using.
我设法找到一个支持 PNG(使用 libpng)的库,并允许您只给它原始图像数据。
它称为 LibPicture。 不过它有点大:~1MB。
I managed to find a library that supports PNG (using libpng) and allows you to just give it raw image data.
It's called LibPicture. It's a bit hefty though: ~1MB.