iOS學習 --- UIImage方法(imageWithCGImage: scale: orientation:)

 

UIImage *imaged = [UIImage imageWithCGImage:image.CGImage scale:1.0 orientation:UIImageOrientationUp];

 


/*

cgImage:cgImage = image.CGImage  image爲原始圖片

scale:原始圖片放大倍數

orientation:即UIImage的imageOrientation屬性   控制image的繪製方向

*/


+ (UIImage *)imageWithCGImage:(CGImageRef)cgImage scale:(CGFloat)scale orientation:(UIImageOrientation)orientation API_AVAILABLE(ios(4.0));

/*
typedef NS_ENUM(NSInteger, UIImageOrientation) {
    UIImageOrientationUp,            // default orientation
    UIImageOrientationDown,          // 180 deg rotation
    UIImageOrientationLeft,          // 90 deg CCW
    UIImageOrientationRight,         // 90 deg CW
    UIImageOrientationUpMirrored,    // as above but image mirrored along other axis. horizontal flip
    UIImageOrientationDownMirrored,  // horizontal flip
    UIImageOrientationLeftMirrored,  // vertical flip
    UIImageOrientationRightMirrored, // vertical flip
};
*/

UIImageOrientationUp:表示圖片的正常狀態

UIImageOrientationDown:表示圖片被翻轉180°

UIImageOrientationLeft:表示圖片被逆時針翻轉90°

UIImageOrientationRight:表示圖片被順時針翻轉90°

UIImageOrientationUpMirrored:表示圖片的正常狀態的鏡面圖像

UIImageOrientationDownMirrored:表示圖片被翻轉180°後的鏡面圖像

UIImageOrientationLeftMirrored:表示圖片被逆時針翻轉90°後的鏡面圖像

UIImageOrientationRightMirrored:表示圖片被順時針翻轉90°後的鏡面圖像
 

 

相關文章

image圖片大小調整和方向調整(UIImageOrientation)

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