मैं कई छवियों में एक छवि विभाजित करने के लिए एक समारोह बनाई गई, लेकिन जब मैं UIImage की CGImage ले लेते हैं, CGImage NULL भेजता हैUIImage की CGImage वापसी शून्य
NSArray* splitImage(UIImage* image,NSUInteger pieces) {
NSLog(@"width: %f, %zu",image.size.width,CGImageGetWidth(image.CGImage));
NSLog(@"%@",image.CGImage);
returns NULL
NSMutableArray* tempArray = [[NSMutableArray alloc]initWithCapacity:pieces];
CGFloat piecesSize = image.size.height/pieces;
for (NSUInteger i = 0; i < pieces; i++) {
// take in account retina displays
CGRect subFrame = CGRectMake(0,i * piecesSize * image.scale ,image.size.width * image.scale,piecesSize * image.scale);
CGImageRef newImage = CGImageCreateWithImageInRect(image.CGImage,subFrame);
UIImage* finalImage =[UIImage imageWithCGImage:newImage];
CGImageRelease(newImage);
[tempArray addObject:finalImage];
}
NSArray* finalArray = [NSArray arrayWithArray:tempArray];
[tempArray release];
return finalArray;
}
जांच tempArray अशक्त या नहीं पिछले – Hector
CGImage में है नहीं एक वस्तु है, यह एक सी struct है है, तो आप% @ के साथ एक NSLog नहीं का उपयोग करना चाहिए। – lnafziger
समस्या यह थी कि मैंने IOSurface के साथ UIImage बनाया: D – Otium