Преобразуйте .png в PVRTC *на* iPhone

Хм. Вероятно, поскольку вы не можете установить фоновое изображение на рабочем столе (кроме заблокированного просмотра) на реальном iPhone до iOS 4, вы не можете сделать это в симуляторе.

6
задан bradhouse 20 June 2009 в 04:32
поделиться

2 ответа

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).

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 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

2
ответ дан 17 December 2019 в 20:34
поделиться

Я был бы осторожен, предполагая, что это поможет вам. Как только вы сделаете ссылку на изображения один раз, то есть загрузите их в UIImage, iPhone начнет кэшировать ваши png независимо от того, нравятся они вам или нет. На мой взгляд, их сжатие не поможет вам достичь того, что вы ищете.

0
ответ дан 17 December 2019 в 20:34
поделиться