我遇到了UIImage内存大小问题。(iphone)UIImage占用多少内存?
当你有320个* 320分辨率的图像数据(PNG),当将图像加载到存储器,
使用[UIImage的imageWithData:],将所得的UIImage将占用320 * 320 * 4?屏幕大小(分辨率)会影响图像的内存使用情况吗?
下面的代码会占用myImage的两倍内存大小还是单个图像内存大小? (320 * 320 * 4)* 2 vs(320 * 320 * 4)?或者是其他东西?
UIImage* myImage = [UIImage imageWithData:]; myImage = [myImage scaleToSize:];
当scaleToSize作为
- (UIImage*)scaleToSize:(CGSize)size { // Create a bitmap graphics context // This will also set it as the current context UIGraphicsBeginImageContext(size); // Draw the scaled image in the current context [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; // Create a new image from current context UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); // Pop the current context from the stack UIGraphicsEndImageContext(); // Return our new scaled image return scaledImage; }