//Now it is thread safe.
CGSize scaledSize = CGSizeMake(ceil(self.size.width * scaleRatio), ceil(self.size.height * scaleRatio));
CGImageRef imageRef = self.CGImage;
//The output context.
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
(int)scaledSize.width,
(int)scaledSize.height,
8,
(int)(4 * scaledSize.width),
colorSpace,
kCGImageAlphaPremultipliedLast);
//Percent (101%)
#define SCALE_OVER_A_BIT 1.01
//Scale.
CGContextScaleCTM(context, scaleRatio * SCALE_OVER_A_BIT, scaleRatio * SCALE_OVER_A_BIT);
CGContextDrawImage(context, CGRectMake(0.0, 0.0, scaledSize.width, scaledSize.height), imageRef);
CGImageRef scaledImageRef = CGBitmapContextCreateImage(context);
UIImage *scaledImage = [UIImage imageWithCGImage:scaledImageRef];
CGColorSpaceRelease(colorSpace);
CGImageRelease(imageRef);
CGImageRelease(scaledImageRef);
CGContextRelease(context);
return scaledImage;
CGBitmapContextCreate:不支持的參數的組合:8個整數位/分量; 32位/像素; 3分量色彩空間; kCGImageAlphaPremultipliedFirst; 450字節/行。
我應該改變什麼?我看不出問題在哪裏。 我是否必須創建一個4分量色彩空間?這是什麼工廠?
似乎沒什麼'。如何克服這一點? – Geri 2012-04-27 11:24:58