CGBitmapContextCreate的一個error

error: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaPremultipliedLast; 186 bytes/row.

正文:

CGBitmapContextCreate是一個繪製位圖的函數

其中一個參數(第5個)bytesPerRow,代表bitmap的每一行在內存所佔的比特數

其值必須的是4的倍數(一般用法是*4)

有時可能你所用的參數是一個float類型,這時就算*4後,其結果依舊不能被4整除

這時就會出現上面的error信息

解決辦法是:

在使用你的參數之前

const int width_int = width_float;

然後使用這個int類型的參數,問題就解決啦

這個問題是在iOS7之後纔出現的


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章