Cocos2dx-screenshot and set the image size

Source: Internet
Author: User

 

When adding images for sharing a few days ago, we found that the full screen size exceeds the packet size. Therefore, we can reduce the size of screenshots to 0.5 times.
The following screenshot code:

 

Void LHUtil: screenShoot () {Size visibleSize = Director: getInstance ()-> getVisibleSize (); // defines the rendering texture RenderTexture * renderTexture = RenderTexture :: create (visibleSize. width *. 5, visibleSize. height *. 5, Texture2D: PixelFormat: RGBA8888); Scene * curScene = ctor: getInstance ()-> getRunningScene (); Point ancPos = pCurScene-> getAnchorPoint (); // render the texture and start capturing renderTexture-> begin (); // zoom out the screen capture area curScene-> setScale (. 5); curScene-> setAnchorPoint (cocos2d: Point (0, 0); // draw the current scene curScene-> visit (); // end renderTexture-> end (); // save png renderTexture-> saveToFile(screenshoot.png, Image: Format: PNG ); // restore the screen size curScene-> setScale (1); curScene-> setAnchorPoint (ancPos); CC_SAFE_DELETE (curScene );}


 

Related Article

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.