Ai
3 Star 0 Fork 0

Gitee 极速下载/fastimagecache

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/path/FastImageCache
克隆/下载
FICDAppDelegate.m 5.04 KB
一键复制 编辑 原始数据 按行查看 历史
//
// FICDAppDelegate.m
// FastImageCacheDemo
//
// Copyright (c) 2013 Path, Inc.
// See LICENSE for full license agreement.
//
#import "FICDAppDelegate.h"
#import "FICImageCache.h"
#import "FICDViewController.h"
#import "FICDPhoto.h"
#pragma mark Class Extension
@interface FICDAppDelegate () <FICImageCacheDelegate>
@end
#pragma mark
@implementation FICDAppDelegate
#pragma mark - Application Lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSMutableArray *mutableImageFormats = [NSMutableArray array];
// Square image formats...
NSInteger squareImageFormatMaximumCount = 400;
FICImageFormatDevices squareImageFormatDevices = FICImageFormatDevicePhone | FICImageFormatDevicePad;
// ...32-bit BGR
FICImageFormat *squareImageFormat32BitBGRA = [FICImageFormat formatWithName:FICDPhotoSquareImage32BitBGRAFormatName family:FICDPhotoImageFormatFamily imageSize:FICDPhotoSquareImageSize style:FICImageFormatStyle32BitBGRA
maximumCount:squareImageFormatMaximumCount devices:squareImageFormatDevices protectionMode:FICImageFormatProtectionModeNone];
[mutableImageFormats addObject:squareImageFormat32BitBGRA];
// ...32-bit BGR
FICImageFormat *squareImageFormat32BitBGR = [FICImageFormat formatWithName:FICDPhotoSquareImage32BitBGRFormatName family:FICDPhotoImageFormatFamily imageSize:FICDPhotoSquareImageSize style:FICImageFormatStyle32BitBGR
maximumCount:squareImageFormatMaximumCount devices:squareImageFormatDevices protectionMode:FICImageFormatProtectionModeNone];
[mutableImageFormats addObject:squareImageFormat32BitBGR];
// ...16-bit BGR
FICImageFormat *squareImageFormat16BitBGR = [FICImageFormat formatWithName:FICDPhotoSquareImage16BitBGRFormatName family:FICDPhotoImageFormatFamily imageSize:FICDPhotoSquareImageSize style:FICImageFormatStyle16BitBGR
maximumCount:squareImageFormatMaximumCount devices:squareImageFormatDevices protectionMode:FICImageFormatProtectionModeNone];
[mutableImageFormats addObject:squareImageFormat16BitBGR];
// ...8-bit Grayscale
FICImageFormat *squareImageFormat8BitGrayscale = [FICImageFormat formatWithName:FICDPhotoSquareImage8BitGrayscaleFormatName family:FICDPhotoImageFormatFamily imageSize:FICDPhotoSquareImageSize style:FICImageFormatStyle8BitGrayscale
maximumCount:squareImageFormatMaximumCount devices:squareImageFormatDevices protectionMode:FICImageFormatProtectionModeNone];
[mutableImageFormats addObject:squareImageFormat8BitGrayscale];
if ([UIViewController instancesRespondToSelector:@selector(preferredStatusBarStyle)]) {
// Pixel image format
NSInteger pixelImageFormatMaximumCount = 1000;
FICImageFormatDevices pixelImageFormatDevices = FICImageFormatDevicePhone | FICImageFormatDevicePad;
FICImageFormat *pixelImageFormat = [FICImageFormat formatWithName:FICDPhotoPixelImageFormatName family:FICDPhotoImageFormatFamily imageSize:FICDPhotoPixelImageSize style:FICImageFormatStyle32BitBGR
maximumCount:pixelImageFormatMaximumCount devices:pixelImageFormatDevices protectionMode:FICImageFormatProtectionModeNone];
[mutableImageFormats addObject:pixelImageFormat];
}
// Configure the image cache
FICImageCache *sharedImageCache = [FICImageCache sharedImageCache];
[sharedImageCache setDelegate:self];
[sharedImageCache setFormats:mutableImageFormats];
// Configure the window
CGRect windowFrame = [[UIScreen mainScreen] bounds];
UIWindow *window = [[UIWindow alloc] initWithFrame:windowFrame];
[self setWindow:window];
UIViewController *rootViewController = [[FICDViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[[self window] setRootViewController:navigationController];
[[self window] makeKeyAndVisible];
return YES;
}
#pragma mark - Protocol Implementations
#pragma mark - FICImageCacheDelegate
- (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id<FICEntity>)entity withFormatName:(NSString *)formatName completionBlock:(FICImageRequestCompletionBlock)completionBlock {
// Images typically come from the Internet rather than from the app bundle directly, so this would be the place to fire off a network request to download the image.
// For the purposes of this demo app, we'll just access images stored locally on disk.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *sourceImage = [(FICDPhoto *)entity sourceImage];
dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(sourceImage);
});
});
}
- (BOOL)imageCache:(FICImageCache *)imageCache shouldProcessAllFormatsInFamily:(NSString *)formatFamily forEntity:(id<FICEntity>)entity {
return NO;
}
- (void)imageCache:(FICImageCache *)imageCache errorDidOccurWithMessage:(NSString *)errorMessage {
NSLog(@"%@", errorMessage);
}
@end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/fastimagecache.git
git@gitee.com:mirrors/fastimagecache.git
mirrors
fastimagecache
fastimagecache
master

搜索帮助