0

我有一个UIImage我知道它在缩放之前没问题的。我需要对其进行缩放,以便将其设置为 ccsprite 。我缩放它,但后来我得到了一个白色的图像..

UIImage *scaled=[newImage copy];
//scale the image
CGRect screenRect = CGRectMake(0, 0, 640.0, 960.0);
UIGraphicsBeginImageContext(screenRect.size);
scaled = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CCSprite * image = [CCSprite spriteWithCGImage:scaled.CGImage 
                                           key:[NSString stringWithFormat:@"%d",[localImagesSpritesArray count]]];

会是什么呢 ?

4

1 回答 1

1
UIGraphicsBeginImageContext(screenRect.size);
[newImage drawInRect:screenRect]; //you have to add this line 
scaled = UIGraphicsGetImageFromCurrentImageContext();
于 2013-03-16T20:56:32.687 回答