CGImageSource對圖像數據讀取任務的抽象

來自:http://www.tanhao.me/pieces/1019.html/html

其中獲取到的kCGImagePropertyPixelHeight和kCGImagePropertyPixelHeight的數值是原始的值,也就是旋轉以前的數值,因此要獲取到顯示圖像的寬和高,須要對應kCGImagePropertyOrientation的值,而經過查看kCGImagePropertyOrientation的文檔介紹,值分別從1-8,但其解釋卻讓人看不懂,通過測試,得出與UIImageOrientation有如下的映射關係:測試

UIImageOrientationUp: 1 正常方向(默認值) 如圖:翻譯

UIImageOrientationDown: 3 旋轉180度(朝左朝右固然是同樣的) 如圖:htm

UIImageOrientationLeft: 8 向左逆時針旋轉90度 如圖:文檔

UIImageOrientationRight: 6 向右順時針旋轉90度 如圖:get

UIImageOrientationUpMirrored: 2 將原圖水平的翻轉到背面 如圖:io

UIImageOrientationDownMirrored: 4 在水平翻轉以後再旋轉180度 如圖:im

UIImageOrientationLeftMirrored: 5 在水平翻轉以後向左逆時針旋轉90度 如圖:img

UIImageOrientationRightMirrored: 7 在水平翻譯以後向右順時針旋轉90度 如圖:tar

相關的Demo:頭像裁剪選擇器McAvatarView

相關文章
相關標籤/搜索