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 );}