Cocos2d-x 2.0.4 in iPad IOS 4.3 jpgimage Alpha Display Error Solution

Source: Internet
Author: User

Today, when I installed an iOS 4.3 iPad, I suddenly found that all the JPG images in the game were very dark. In fact, JPG became translucent. It was previously run on more than 5.1 systems, so this problem was not found.


After reading the code, we found that it was an error when ccimage set alpha for JPG images.


Solution:

Find the/libs/cocos2dx/platform/IOS/ccimage. MM file.


After opening, find the code:

pImageinfo->hasAlpha = (info == kCGImageAlphaPremultipliedLast)                            || (info == kCGImageAlphaPremultipliedFirst)                             || (info == kCGImageAlphaLast)                             || (info == kCGImageAlphaFirst);

Replace it with the following:

pImageinfo->hasAlpha = ((info == kCGImageAlphaNoneSkipLast) ||                             (info == kCGImageAlphaPremultipliedLast) ||                             (info == kCGImageAlphaPremultipliedFirst) ||                             (info == kCGImageAlphaLast) ||                             (info == kCGImageAlphaFirst) ? YES : NO);

Run the command to check if it is okay.


JPG is generally used to reduce the capacity, so large background images are all in JPG format.


However, one thing you need to know is that the speed of JPG loading is slower than that of PNG loading. Therefore, you must weigh the trade-off between using JPG and other parts.

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.