标签:图片 gety enum class inline mda unsigned rom amp
1 typedef NS_ENUM(NSInteger, NSPUIImageType) 2 { NSPUIImageType_JPEG, 3 NSPUIImageType_PNG, 4 NSPUIImageType_Unknown 5 }; 6 static inline NSPUIImageType NSPUIImageTypeFromData(NSData *imageData) 7 { 8 if (imageData.length > 4) { 9 const unsigned char * bytes = [imageData bytes]; 10 11 if (bytes[0] == 0xff && 12 bytes[1] == 0xd8 && 13 bytes[2] == 0xff) 14 { 15 return NSPUIImageType_JPEG; 16 } 17 18 if (bytes[0] == 0x89 && 19 bytes[1] == 0x50 && 20 bytes[2] == 0x4e && 21 bytes[3] == 0x47) 22 { 23 return NSPUIImageType_PNG; 24 } 25 } 26 27 return NSPUIImageType_Unknown; 28 }
标签:图片 gety enum class inline mda unsigned rom amp
原文地址:http://www.cnblogs.com/jinglecode/p/6133554.html