且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在iPhone上将.png转换为PVRTC *

更新时间:2022-05-12 05:50:22

我没有在网上看到有关如何手动构建PVRTC图像的任何信息,据我所知,iPhone内置的内容不支持(并且它不会'需要读取PVRTC文件。)

I haven't seen any information on the net regarding how to construct PVRTC images manually and to the best of my knowledge there is no support for this built into the iPhone (and it wouldn't be needed to read the PVRTC files).

对于大多数应用程序,包含或构建两个版本的文件几乎没有意义。在***条件下,PVRTC版本几乎与PNG版本无法区分,实际上只是为了直接流入视频内存而优化的文件的预处理版本。

For most applications, there is little sense to include or construct both versions of the files. Under optimal conditions, the PVRTC versions should be virtually indistinguishable from the PNG versions and are really just "pre-processed" versions of the files optimized for direct streaming into the video memory.

通常***通过所有图像并决定如何***地打包图像以平衡所有用户的内存保护和质量,而不仅仅是在特定的受限内存情况下。

It is generally best to go through all of your images and make decisions regarding how to best package the image to balance memory conservation and quality for all users, not just under specific restricted memory situations.

需要考虑的一些事项(如果这是多余的知识,请道歉):

A few things to consider (apologies if this is redundant knowledge):


  1. PVRTC文件可能存在复杂alpha问题混合图像作为预处理可能会导致混合边缘产生难看的伪影。

  2. 不透明的PNG文件应该在原始图像中删除其alpha通道(节省内存和混合开销)。

  3. 对于颜色范围有限的图像,将图像从PNG32缩小为PNG16或PNG8以节省磁盘上的内存。

  4. 如果是对于基于OpenGL的程序,请考虑使用增强版的Texture2D(例如来自Cocos2D),它支持565和4444等替代像素格式。通过仔细选择,可以大大减少图形卡的开销,对图像质量的影响最小。像素格式,对应于原始图像中的颜色平衡。

  5. 此外,对于基于OpenGL的程序,请避免使用背景的单个图像(320x480),因为这将导致内存中的512x512纹理每一个。将图像分成更小的部分或使图像为512x512,并用其他图像填充额外的空间,以便只需要加载一个纹理。

  6. 与所有内容一样,首先关注最大的图像获得最大的收益。

  1. PVRTC files can have problems with complex alpha blended images as the pre-processing can cause unsightly artifacts along the blended edges.
  2. Opaque PNG files should have their alpha channel removed in the original image (saving memory and blending overhead).
  3. For images with a limited range of colors, reduce the image from PNG32 to PNG16 or PNG8 to save memory on disk.
  4. If this is for OpenGL based programs, consider using an enhanced version of Texture2D (such as from Cocos2D) which supports alternate pixel formats such as 565 and 4444. This can greatly reduce the overhead in the graphics card with minimal impact on image quality, by carefully choosing a pixel format which corresponds to the balance of colors in the original image.
  5. Additionally for OpenGL based programs, avoid individual images (320x480) for backgrounds as this will result in a 512x512 texture in memory for each one. Break the image into smaller pieces or make the image 512x512 and fill the extra space with other images so that only one texture needs to load.
  6. As with everything, focus on the largest images first to get the biggest bang for the buck.

值得注意的是,因为您的应用程序将是唯一运行的(除了系统应用程序) ),唯一真正的内存开销将是有限数量的磁盘空间。制作所有图像文件的第二份副本实际上会对你起作用而不是帮助。

It's also worth noting that since your application will be the only thing running (other than system applications), the only real memory overhead is going to be a limited amount of "disk" space. Making a second copy of all the image files will actually be working against you instead of helping.

Barney