我收到iOS 8的iOS 7異常。異常情況是「無效句柄」,消息: :CGBitmapContextCreate:不受支持的參數組合:8整數位/分量; 32位/像素; 3分量色彩空間; kCGImageAlphaLast; 524字節/行。CGImageAlphaInfo.Last in iOS 8不受支持的參數組合
任何想法爲什麼這不再是一個支持的參數?我已經將它追蹤到下面的代碼中我的PNG圖像使用的alpha信息「CGImageAlphaInfo.Last」,其中我指定了CGImageAlphaInfo alphaInfo = image.AlphaInfo;我在這個函數中使用的一些其他圖像具有「CGImageAlphaInfo.PremultipliedFirst」alpha信息,它不會導致異常。所以我現在迫使Alpha信息成爲PremultipliedFirst。
CGImage image = uiimage.CGImage;
int width = image.Width;
int height = image.Height;
CGColorSpace colorSpace = image.ColorSpace;
int bytesPerRow = image.BytesPerRow;
int bitmapByteCount = bytesPerRow * height;
int bitsPerComponent = image.BitsPerComponent;
CGImageAlphaInfo alphaInfo = image.AlphaInfo;
// Allocate memory because the BitmapData is unmanaged
IntPtr BitmapData = Marshal.AllocHGlobal(bitmapByteCount);
CGBitmapContext context = new CGBitmapContext(BitmapData, width, height, bitsPerComponent, bytesPerRow, colorSpace, alphaInfo);
我使用:
的XCode版6.0.1(6A317)
Xamarin工作室5.4(建立240)
更多的代碼和圖像本身將有助於診斷爲什麼這停止工作。 – poupou 2014-09-19 00:17:41