UIGraphicsBeginImageContext使用此收到的内存问题和应用程序崩溃

时间:2014-03-26 06:50:12

标签: objective-c

 @try
        {
            UIImage* newImage;
            float width=imgSelected.size.width;
            float height=imgSelected.size.height;

            float wfirst =width/4;
            float hSecond = height/4;


            float wfirsts =width/2;
            float hSeconds = height/2;

            if (width > 550 || height >700)
            {
                UIGraphicsBeginImageContext(CGSizeMake(wfirst, hSecond));
                [imgSelected drawInRect:CGRectMake(0,0,wfirst, hSecond)];
            }
            else if (width < 180 || height <250)
            {
                UIGraphicsBeginImageContext(CGSizeMake(width, height));
                [imgSelected drawInRect:CGRectMake(0,0,width, height)];
            }
            else
            {
                UIGraphicsBeginImageContext(CGSizeMake(wfirsts, hSeconds));
                [imgSelected drawInRect:CGRectMake(0,0,wfirsts, hSeconds)];
            }

            newImage = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();

            [imgSelected release];
            NSData *imageData = UIImagePNGRepresentation(newImage);
        [imageData writeToFile:savedImagePath atomically:NO];
        return savedImagePath;

        }

当我使用上面的代码应用程序接收内存警告

0 个答案:

没有答案