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

轉載地址:http://www.tanhao.me/pieces/1019.htmlhtml

CGImageSource是對圖像數據讀取任務的抽象,經過它能夠得到圖像對象、縮略圖、圖像的屬性(包括Exif信息)。ide

1.建立CGImageSourceRef測試

2.獲取圖像spa

3.建立圖像的縮略圖翻譯

4.獲取圖像的屬性信息3d

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

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

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

UIImageOrientationLeft:           8      向左逆時針旋轉90度    如圖:UIImageOrientationLeft對象

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

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

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

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

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

 

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

相關文章
相關標籤/搜索