开发者

Error messages in Console

开发者 https://www.devze.com 2023-03-23 09:13 出处:网络
The console is showing following statements every time I run my application either on simulator or on iPhone.

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. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号