0
Herer가 내 크기 조정 루틴입니다 ... CGContextDrawImage 줄에 2 또는 3 번의 루틴 호출 후에 응용 프로그램이 충돌합니다.UIImage + Resize가 메모리 경고없이 충돌 함
메모리 경고 등이 없습니다. 그냥
- (UIImage *)resizedImage:(CGSize)newSize
transform:(CGAffineTransform)transform
drawTransposed:(BOOL)transpose
interpolationQuality:(CGInterpolationQuality)quality {
CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height));
CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width);
CGImageRef imageRef = self.CGImage;
// Build a context that's the same dimensions as the new size
CGContextRef bitmap = CGBitmapContextCreate(NULL,
newRect.size.width,
newRect.size.height,
CGImageGetBitsPerComponent(imageRef),
0,
CGImageGetColorSpace(imageRef),
CGImageGetBitmapInfo(imageRef));
// Rotate and/or flip the image if required by its orientation
CGContextConcatCTM(bitmap, transform);
// Set the quality level to use when rescaling
CGContextSetInterpolationQuality(bitmap, quality);
// Draw into the context; this scales the image
////////////AFTER THAT IT CRASHS!!!
CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef);
// Get the resized image from the context and a UIImage
CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
UIImage *newImage = [UIImage imageWithCGImage:newImageRef];
// Clean up
CGContextRelease(bitmap);
CGImageRelease(newImageRef);
return newImage;
}
사람 힌트를 chrashes?
관련, 필 어쩌면
탱크, 나는 ARC와 협력하고 있습니다 -> ARC에서 @autorelease {} 문법은 정확히 어떻게됩니까? – Phil
@autorelease {// some block code}는 블록에 대한 자동 autorelease 풀을 생성합니다. –