The console is showing following statements every time I run my application either on simulator or on iPhone. What does it actually want to say?
** *attempt to pop an unknown aut开发者_开发知识库orelease pool (0x6830200) < Error >: CGContextScaleCTM: invalid context 0x0 < Error >: CGContextTranslateCTM: invalid context 0x0 < Error >: CGContextConcatCTM: invalid context 0x0 < Error >: CGContextDrawImage: invalid context 0x0 < Error >: CGContextScaleCTM: invalid context 0x0 < Error >: CGContextTranslateCTM: invalid context 0x0 < Error >: CGContextConcatCTM: invalid context 0x0 < Error >: CGContextDrawImage: invalid context 0x0 < Error >: CGContextScaleCTM: invalid context 0x0 < Error >: CGContextTranslateCTM: invalid context 0x0 < Error >: CGContextConcatCTM: invalid context 0x0 < Error >: CGContextTranslateCTM: invalid context 0x0 < Error >: CGContextConcatCTM: invalid context 0x0 < Error >: CGContextDrawImage: invalid context 0x0
How to resolve it?
Following is the code for the reference where imgPic is an instance of UIImage...
int kMaxResolution = 640;
CGImageRef imgRef = imgPic.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGAffineTransform transform = CGAffineTransformIdentity;
CGRect bounds = CGRectMake(0, 0, width, height);
if (width > kMaxResolution || height > kMaxResolution)
{
CGFloat ratio = width/height;
if (ratio > 1)
{
bounds.size.width = kMaxResolution;
bounds.size.height = roundf(bounds.size.width / ratio);
}
else
{
bounds.size.height = kMaxResolution;
bounds.size.width = roundf(bounds.size.height * ratio);
}
}
CGFloat scaleRatio = bounds.size.width / width;
CGSize imageSize = CGSizeMake(CGImageGetWidth(imgRef), CGImageGetHeight(imgRef));
CGFloat boundHeight;
UIGraphicsBeginImageContext(bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scaleRatio, -scaleRatio);
CGContextTranslateCTM(context, 0, -height);
CGContextConcatCTM(context, transform);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), imgRef);
UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
I think that he tries to tell you that your context is not valid. :)
精彩评论