在 iOS 中使用向量
我正在开发一个简单的 iOS 游戏,它总是绘制 5 到 10 层 32 位 png 图像,这需要足够的内存,以便在启用视网膜时在 iPod touch 4g 上崩溃。在其他设备上它工作得很好。我什至没有收到内存警告。所以我尝试使用较低质量的图像,例如 RGB5_A1 格式,但它看起来非常糟糕,因为我需要 Alpha 透明度和大量渐变。
由于所有图像都是从 Illustrator 导出的,我想也许我可以导出矢量图像并在 iOS 上绘制。从我的研究来看,几乎没有人尝试过这个,我遇到的唯一选择是为 Quartz 实现一个 SVG 解析器。
我错过了什么吗? 我也担心性能,但我找不到任何基准。
I'm working on a simple iOS game that's always drawing 5 to 10 layers of 32bit png images which requires enough memory to crash on the ipod touch 4g when retina enabled. On other devices it works just fine. I'm not even getting memory warnings. So I was trying with lower quality images, like RGB5_A1 format, but it looks really bad because I need alpha transparency and lots of gradients.
Since all the images are exports from Illustrator I was thinking that maybe i could just export a vector image and draw in on iOS. From what i was researching hardly anyone tried this and the only option I've come across was to implement a SVG parser for Quartz.
Did I miss anything?
Also I'm worried about performance, but I couldn't find any benchmarks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不了解游戏细节的情况下,我将根据正常使用做出一些假设......
您不会想为此使用直接矢量图形。坚持使用光栅图形。
如果您谈论的是 PNG 图像的 32 位色彩空间,那么您需要缩小规模。 iOS 使用 24 位图像,其中红、绿、蓝和 alpha 各 8 位。就目前而言,显示的每个像素都有一个额外的字节。
如果您使用的是 Adobe 产品,请将 Illustrator 文件导入 Photoshop 并使用“另存为 Web...”选项。选择 PNG-24 即可完成。
Without knowing specifics of your game, I'm going to make a few assumptions based on normal use...
You are not going to want to use straight vector graphics for this. Stick with your raster graphics.
If you are talking about 32 bit color space for your PNG images, then you need to scale back. iOS uses 24 bit images and that includes 8 bits each for red, green, blue, and alpha. As it stands, you have an extra byte for every pixel shown.
If you are using Adobe products, import the Illustrator file into Photoshop and use the "Save for Web..." option. Choose PNG-24 and you'll be all set.