Search code examples
iosxcodeuiimageccsprite

How can i keep the resolution of UIimage in coco2d in xcode?


Hi i am working on image editing application using cocos2d. when i used to performs some action in cocos2d in on ccsprite i use to take screenshot of ccsprite and save it to preform the next effect. But after each and every action performed the image of screenshot becomes more blur. i want to keep the same resolution of image throughout so please if u have any idea to maintain resolution after each and every screen shot. how to solve resolution problem?

u can email me on stackram1988@gmail.com.


Solution

  • hi i am using this code to take screenshot

    +(CCRenderTexture*) screenshotWithStartNode:(CCSprite )startNode filename:(NSString)filename { [CCDirector sharedDirector].nextDeltaTimeZero = YES;

    CGSize winSize = CGSizeMake(startNode.contentSizeInPixels.width, startNode.contentSizeInPixels.height);
    
    CGSize   photoSize =CGSizeMake(startNode.contentSize.width, winSize.height * startNode.scaleX);
    CCRenderTexture* rtx =[CCRenderTexture renderTextureWithWidth:startNode.contentSizeInPixels.width height:startNode.contentSizeInPixels.height];
    [rtx begin];
    

    [startNode visit]; [rtx end];

    // save as file as PNG
    [rtx saveBuffer:[self screenshotPathForFile:filename]
             format:kCCImageFormatPNG];
    
    return rtx;
    

    }