큰 PNG 이미지를 한 픽셀 씩 파싱해야하는 메소드가 있습니다 (PNG는 각각 600x600 픽셀입니다). 그것은 시뮬레이터에서 잘 작동하는 것 같지만, 장치 (iPad)에서는 EXC_BAD_ACCESS를 내부 메모리 복사 기능으로 사용합니다. 작은 크기의 이미지로 시도하면 모든 것이 제대로 작동하기 때문에 크기가 문제인 것 같습니다. 아래의 방법과 관련된 기억의 고기가 있습니다. iPhone/iPad에서 CGBitmapContextCreate
+ (CGRect) getAlphaBoundsForUImage: (UIImage*) image
{
CGImageRef imageRef = [image CGImage];
NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
unsigned char *rawData = malloc(height * width * 4);
memset(rawData,0,height * width * 4);
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * width;
NSUInteger bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
CGContextRelease(context);
/* non-memory related stuff */
free(rawData);
나는 이미지의 무리에이 실행
, 그것은 12 회를 실행 한 후 시뮬레이터에 아무 문제를 실행하지 않습니다 동안 밖으로 배변. 너희들은 어떤 생각을 가지고 있니?