Open iTA9178 opened 9 years ago
@iTA9178 Hi there! News on this issue? Did you resolve the memory warning / crash?
Remove the fullimage normalize worked. Code on the FastttCapturedImage+Process line63
Hi, thanks for letting us know! This seems to be working fine for us on iPhone 6 Plus, but if the normalize is problematic, you can always set normalizesImageOrientations = NO
on your FastttCamera instance to disable this feature.
I'll also go through and see if we can optimize the memory usage of the code a bit more and see if we can improve performance here. Is it in the demo where you're seeing the problem, or in your own app?
The example project memory of take photo
Here is the code to resolve the memory warning / crash in my project. Hope it will help other people has the same problem.
(UIImage )imageByScalingAndCroppingForSourceImage:(UIImage )sourceImage targetSize:(CGSize)targetSize { UIImage *newImage = nil; CGSize imageSize = sourceImage.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; CGFloat targetWidth = targetSize.width; CGFloat targetHeight = targetSize.height; CGFloat scaleFactor = 0.0; CGFloat scaledWidth = targetWidth; CGFloat scaledHeight = targetHeight; CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
if (CGSizeEqualToSize(imageSize, targetSize) == NO) { CGFloat widthFactor = targetWidth / width; CGFloat heightFactor = targetHeight / height;
if (widthFactor > heightFactor)
scaleFactor = widthFactor; // scale to fit height
else
scaleFactor = heightFactor; // scale to fit width
scaledWidth = width * scaleFactor;
scaledHeight = height * scaleFactor;
// center the image
if (widthFactor > heightFactor)
{
thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
}
else
if (widthFactor < heightFactor)
{
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
}
}
UIGraphicsBeginImageContext(targetSize); // this will crop CGRect thumbnailRect = CGRectZero; thumbnailRect.origin = thumbnailPoint; thumbnailRect.size.width = scaledWidth; thumbnailRect.size.height = scaledHeight;
[sourceImage drawInRect:thumbnailRect];
newImage = UIGraphicsGetImageFromCurrentImageContext(); if(newImage == nil) NSLog(@"could not scale image");
//pop the context to get back to the default UIGraphicsEndImageContext(); return newImage; }
I'm also having this issue. Using this in my own app and it works on every device except the 6+.
This is a known issue- the 6+ is tricky because the size of the images the camera returns really push the device to its memory limits. I'll try to find some time to look into resolving this and minimizing the memory footprint as much as we can here.
Any update on this?
the delegate method return a capturedImage,and it's size 2448 * 2448 on iPhone6 plus device,cause memory waring then crash.Colud you help me or something advice?