我遇到了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; }