Reputation: 105
I have been trying to get high quality screenshots of my Cocos2d
game programmatically to post on social networks. The quality has been quiet poor, most often blurry. I decided to take a manual screenshot and post it to facebook, the quality was also blurry. Most of the images rendered on the screen are .png
format and in spritesheets (using RGBA444
image format, .pvr.ccz
texture format, FloydSteinbergAlpha
dithering), also the resolution of most sprites are 380 ppi
. Could any of these settings be causing the blur? Also, is there anyway I can share the images rendered on the screen other than by taking a screenshot? Please see the code below:
-(UIImage*) screenshotWithStartNode:(CCNode*)startNode
{
[CCDirector sharedDirector].nextDeltaTimeZero = YES;
CGSize winSize = [CCDirector sharedDirector].winSize;
CCRenderTexture* rtx =
[CCRenderTexture renderTextureWithWidth:winSize.width
height:winSize.height];
[rtx begin];
[startNode visit];
[rtx end];
return [rtx getUIImage];
}
Upvotes: 0
Views: 651
Reputation: 64477
You're creating the screenshots in points instead of pixels. On Retina devices this means a 960x640 screenshot will actually be 480x320. That may explain why you regard the screenshots as "blurry", simply because they have been scaled down.
Assuming you're using cocos2d v2.x you should use the screen size in pixels to capture the screenshot at the full pixel resolution:
CGSize winSize = [CCDirector sharedDirector].winSizeInPixels;
I haven't checked but assume v3 has a similar way to get the size of the view/window in pixels instead of points.
PS: Facebook applies its own scaling (and reformatting to JPG I believe) to images under certain conditions. If you want to know if the results are good on your end, save the screenshot on the photo library, or display it as a sprite or send it to yourself by email to verify that the image looks okay if there is any remaining image quality degradation after publishing to Facebook.
Upvotes: 1