를 반환 여러 개의 이미지로 이미지를 분할하는 기능을 만들었지 만이있는 UIImage의의 CGImage을 취할 때의 CGImage NULL을 반환있는 UIImage의의 CGImage이 NULL
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는, 그것은 C 구조체 목적은 아니다 널 (null) 여부를 마지막 – Hector
의 CGImage에, 그래서 당신은 %의 @와 NSLog를 사용하지 않아야합니다. – lnafziger
문제는 IOSurface로 UIImage를 만들었다는 것입니다 : D – Otium