- 什么是大端和小端?
- 大端模式:高位字節(jié)排放在內(nèi)存的低地址端,低位字節(jié)排放在內(nèi)存的高地址段。
- 小端模式:低位字節(jié)排放在內(nèi)存的低地址端,高位字節(jié)排放在內(nèi)存的高地址端。
- 一個NSObject對象占用多少內(nèi)存
- 系統(tǒng)分配了16個字節(jié)給NSObject對象(通過
malloc_size函數(shù)獲得)
- 但NSObject對象內(nèi)部只使用了8個字節(jié)的空間(64bit環(huán)境下)
NSObject *obj = [[NSObject alloc] init];
NSLog(@"%zd", class_getInstanceSize([NSObject class]));
NSLog(@"%zd", malloc_size((__bridge void *)obj));
- ImageIO學習
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(60, 120, [UIScreen mainScreen].bounds.size.width - 120, 160)];
[self.view addSubview:iv];
//
// UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"11.jpeg" ofType:nil]];
// NSData *data = UIImageJPEGRepresentation(image, 1.0);
// SDImageFormat type = [NSData sd_imageFormatForImageData:data];
// NSLog(@"%zd", type);
//
// NSString *typeStr = (NSString *)[NSData sd_UTTypeFromImageFormat:type];
// NSLog(@"%@", typeStr);
// CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
NSString *path = [[NSBundle mainBundle] pathForResource:@"show.gif" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
long count = CGImageSourceGetCount(source);
NSLog(@"圖片個數(shù)%ld", count);
//獲取第幾張圖片
CGImageRef firstImage = CGImageSourceCreateImageAtIndex(source, 23, NULL);
NSArray *arr = CFBridgingRelease(CGImageSourceCopyTypeIdentifiers());
NSLog(@"支持的類型\n%@", arr);
NSString *type = CFBridgingRelease(CGImageSourceGetType(source));
NSLog(@"所加載圖片的類型為:%@", type);
// 獲取某一幀圖片的縮略圖
CGImageRef thumbnailImage = CGImageSourceCreateThumbnailAtIndex(source, 0, NULL);
NSLog(@"%@", thumbnailImage);
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSInteger orientationValue = 1;
CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
// 圖片的高度
if (val) CFNumberGetValue(val, kCFNumberLongType, &_height);
val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
// 圖片的寬度
if (val) CFNumberGetValue(val, kCFNumberLongType, &_width);
val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
// 圖片的方向
if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue);
CFRelease(source);
_orientation = (CGImagePropertyOrientation)orientationValue;
iv.image = [UIImage imageWithCGImage:thumbnailImage];
}
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。