[Coco2d-x] memory usage of PVR and PNG

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_6fbe210701015j7z.html

 

 The spritesheet generated by zwoptex can export images in PNG format but also in PVR format. The PVR format can be directly read by the IOS display chip and can be directly displayed without parsing. Therefore, the rendering speed is faster and the memory is saved.

I specifically tested cocos2d 2.0 RC1:

The memory occupied by an empty cocos2d template project is about 4 MB.

After a 2048*1024 PNG Image in the format of rgba565 is displayed with ccsprite, the memory usage reaches 20 mb. In the same case, the memory usage is 16 MB after the format is changed to PVR. That is to say, images in PNG format occupy 20-4 = 16 MB, while those in PVR format occupy 16-4 = 12 Mb. Reduced by 25%. Zwoptex also has an option called "CCZ compression". After selection, the image size can be reduced by almost half. The file format is XXX. PVR. CCZ, which can be recognized by cocos2d.    Pvrtc2 And Pvrtc4 They are two PVR compression image formats, both of which are PVR files. These two image formats provide faster loading speed and smaller memory usage than normal images. Pvrtc4:
Compressed Format, 4 bits per pixel, OK Image Quality Pvrtc2:
Compressed Format, 2 bits per pixel, poor image quality Generally, the image formats of PVR files include: Rgba8888:
32-bit texture with alpha channel, best image quality Rgba4444:
16-bit texture with alpha channel, good image quality Rgb565:
16-bit texture without alpha channel, good image quality but no alpha (transparency) The formula for memory usage of images is: Numbytes
= Width * height * bitsperpixel/8
That is to say, 2048*2048 of rgba8888 occupies 16 MB of memory, while pvrtc4 only occupies 2 MB.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.