├── UIImageAverageColor ├── en.lproj │ ├── InfoPlist.strings │ └── NRViewController.xib ├── Lena.tiff ├── UIImageAverageColorAddition.h ├── UIImageAverageColor-Prefix.pch ├── main.m ├── NRAppDelegate.h ├── NRViewController.h ├── UIImageAverageColor-Info.plist ├── NRViewController.m ├── UIImageAverageColorAddition.m └── NRAppDelegate.m ├── UIImageAverageColor.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj └── README.md /UIImageAverageColor/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /UIImageAverageColor/Lena.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NikolaiRuhe/UIImageAverageColor/HEAD/UIImageAverageColor/Lena.tiff -------------------------------------------------------------------------------- /UIImageAverageColor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIImageAverageColor 2 | ============== 3 | 4 | See description on stackoverflow [in this answer](http://stackoverflow.com/questions/12147779/how-do-i-release-a-cgimageref-in-ios/12148136#12148136). 5 | 6 | The code in this project is in the public domain. Use it at your will. 7 | -------------------------------------------------------------------------------- /UIImageAverageColor/UIImageAverageColorAddition.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+UIImageAverageColorAddition.h 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (UIImageAverageColorAddition) 12 | 13 | - (UIColor *)averageColor; 14 | - (UIColor *)mergedColor; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /UIImageAverageColor/UIImageAverageColor-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'AvgColor' target in the 'AvgColor' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /UIImageAverageColor/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "NRAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([NRAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /UIImageAverageColor/NRAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // NRAppDelegate.h 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class NRViewController; 12 | 13 | @interface NRAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) NRViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /UIImageAverageColor/NRViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NRViewController.h 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NRViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *averageColorLabel; 14 | @property (weak, nonatomic) IBOutlet UILabel *mergedColorLabel; 15 | @property (weak, nonatomic) IBOutlet UILabel *resultLabel; 16 | @property (weak, nonatomic) IBOutlet UIImageView *imageView; 17 | 18 | - (IBAction)testAverage:(UIBarButtonItem *)sender; 19 | - (IBAction)testMerge:(UIBarButtonItem *)sender; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /UIImageAverageColor/UIImageAverageColor-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.savoysoftware.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /UIImageAverageColor/NRViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NRViewController.m 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import "NRViewController.h" 10 | #import "UIImageAverageColorAddition.h" 11 | 12 | 13 | @implementation NRViewController 14 | 15 | - (void)viewDidLoad 16 | { 17 | [super viewDidLoad]; 18 | 19 | CGFloat red, green, blue; 20 | 21 | self.averageColorLabel.backgroundColor = [self.imageView.image averageColor]; 22 | [self.averageColorLabel.backgroundColor getRed:&red green:&green blue:&blue alpha:NULL]; 23 | self.averageColorLabel.text = [NSString stringWithFormat:@"average color: %.2f %.2f %.2f", red, green, blue]; 24 | 25 | self.mergedColorLabel.backgroundColor = [self.imageView.image mergedColor]; 26 | [self.mergedColorLabel.backgroundColor getRed:&red green:&green blue:&blue alpha:NULL]; 27 | self.mergedColorLabel.text = [NSString stringWithFormat:@"merged color: %.2f %.2f %.2f", red, green, blue]; 28 | 29 | self.resultLabel.text = @""; 30 | } 31 | 32 | - (IBAction)testAverage:(UIBarButtonItem *)sender 33 | { 34 | UIImage * image = self.imageView.image; 35 | NSDate *start = [NSDate date]; 36 | NSUInteger iterations = 0; 37 | while ([start timeIntervalSinceNow] > -2) { 38 | [image averageColor]; 39 | iterations += 1; 40 | } 41 | NSDate *end = [NSDate date]; 42 | self.resultLabel.text = [NSString stringWithFormat:@"average: %.2f ms", 1000.0 * [end timeIntervalSinceDate:start] / iterations]; 43 | } 44 | 45 | - (IBAction)testMerge:(UIBarButtonItem *)sender 46 | { 47 | UIImage * image = self.imageView.image; 48 | NSDate *start = [NSDate date]; 49 | NSUInteger iterations = 0; 50 | while ([start timeIntervalSinceNow] > -2) { 51 | [image mergedColor]; 52 | iterations += 1; 53 | } 54 | NSDate *end = [NSDate date]; 55 | self.resultLabel.text = [NSString stringWithFormat:@"merge: %.2f ms", 1000.0 * [end timeIntervalSinceDate:start] / iterations]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /UIImageAverageColor/UIImageAverageColorAddition.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+UIImageAverageColorAddition.m 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import "UIImageAverageColorAddition.h" 10 | 11 | @implementation UIImage (UIImageAverageColorAddition) 12 | 13 | - (UIColor *)averageColor 14 | { 15 | CGImageRef rawImageRef = [self CGImage]; 16 | 17 | // This function returns the raw pixel values 18 | CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(rawImageRef)); 19 | const UInt8 *rawPixelData = CFDataGetBytePtr(data); 20 | 21 | NSUInteger imageHeight = CGImageGetHeight(rawImageRef); 22 | NSUInteger imageWidth = CGImageGetWidth(rawImageRef); 23 | NSUInteger bytesPerRow = CGImageGetBytesPerRow(rawImageRef); 24 | NSUInteger stride = CGImageGetBitsPerPixel(rawImageRef) / 8; 25 | 26 | // Here I sort the R,G,B, values and get the average over the whole image 27 | unsigned int red = 0; 28 | unsigned int green = 0; 29 | unsigned int blue = 0; 30 | 31 | for (int row = 0; row < imageHeight; row++) { 32 | const UInt8 *rowPtr = rawPixelData + bytesPerRow * row; 33 | for (int column = 0; column < imageWidth; column++) { 34 | red += rowPtr[0]; 35 | green += rowPtr[1]; 36 | blue += rowPtr[2]; 37 | rowPtr += stride; 38 | 39 | } 40 | } 41 | CFRelease(data); 42 | 43 | CGFloat f = 1.0f / (255.0f * imageWidth * imageHeight); 44 | return [UIColor colorWithRed:f * red green:f * green blue:f * blue alpha:1]; 45 | } 46 | 47 | - (UIColor *)mergedColor 48 | { 49 | CGSize size = {1, 1}; 50 | UIGraphicsBeginImageContext(size); 51 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 52 | CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium); 53 | [self drawInRect:(CGRect){.size = size} blendMode:kCGBlendModeCopy alpha:1]; 54 | uint8_t *data = CGBitmapContextGetData(ctx); 55 | UIColor *color = [UIColor colorWithRed:data[2] / 255.0f 56 | green:data[1] / 255.0f 57 | blue:data[0] / 255.0f 58 | alpha:1]; 59 | UIGraphicsEndImageContext(); 60 | return color; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /UIImageAverageColor/NRAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // NRAppDelegate.m 3 | // AvgColor 4 | // 5 | // Created by nikolai on 28.08.12. 6 | // Copyright (c) 2012 Savoy Software. All rights reserved. 7 | // 8 | 9 | #import "NRAppDelegate.h" 10 | 11 | #import "NRViewController.h" 12 | 13 | @implementation NRAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[NRViewController alloc] initWithNibName:@"NRViewController" bundle:nil]; 20 | self.window.rootViewController = self.viewController; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /UIImageAverageColor.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 91B36BAE15ECB9E100BA1F30 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91B36BAD15ECB9E100BA1F30 /* UIKit.framework */; }; 11 | 91B36BB015ECB9E100BA1F30 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91B36BAF15ECB9E100BA1F30 /* Foundation.framework */; }; 12 | 91B36BB215ECB9E100BA1F30 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91B36BB115ECB9E100BA1F30 /* CoreGraphics.framework */; }; 13 | 91B36BB815ECB9E100BA1F30 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 91B36BB615ECB9E100BA1F30 /* InfoPlist.strings */; }; 14 | 91B36BBA15ECB9E100BA1F30 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 91B36BB915ECB9E100BA1F30 /* main.m */; }; 15 | 91B36BBE15ECB9E100BA1F30 /* NRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 91B36BBD15ECB9E100BA1F30 /* NRAppDelegate.m */; }; 16 | 91B36BC115ECB9E100BA1F30 /* NRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 91B36BC015ECB9E100BA1F30 /* NRViewController.m */; }; 17 | 91B36BC415ECB9E100BA1F30 /* NRViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 91B36BC215ECB9E100BA1F30 /* NRViewController.xib */; }; 18 | 91B36BCD15ECBA8B00BA1F30 /* UIImageAverageColorAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = 91B36BCC15ECBA8B00BA1F30 /* UIImageAverageColorAddition.m */; settings = {COMPILER_FLAGS = "-Os"; }; }; 19 | 91B36BCF15ECC09000BA1F30 /* Lena.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 91B36BCE15ECC09000BA1F30 /* Lena.tiff */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 91B36BA915ECB9E100BA1F30 /* UIImageAverageColor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIImageAverageColor.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 91B36BAD15ECB9E100BA1F30 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 25 | 91B36BAF15ECB9E100BA1F30 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 91B36BB115ECB9E100BA1F30 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 91B36BB515ECB9E100BA1F30 /* UIImageAverageColor-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UIImageAverageColor-Info.plist"; sourceTree = ""; }; 28 | 91B36BB715ECB9E100BA1F30 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 91B36BB915ECB9E100BA1F30 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 91B36BBB15ECB9E100BA1F30 /* UIImageAverageColor-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageAverageColor-Prefix.pch"; sourceTree = ""; }; 31 | 91B36BBC15ECB9E100BA1F30 /* NRAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NRAppDelegate.h; sourceTree = ""; }; 32 | 91B36BBD15ECB9E100BA1F30 /* NRAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NRAppDelegate.m; sourceTree = ""; }; 33 | 91B36BBF15ECB9E100BA1F30 /* NRViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NRViewController.h; sourceTree = ""; }; 34 | 91B36BC015ECB9E100BA1F30 /* NRViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NRViewController.m; sourceTree = ""; }; 35 | 91B36BC315ECB9E100BA1F30 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/NRViewController.xib; sourceTree = ""; }; 36 | 91B36BCB15ECBA8B00BA1F30 /* UIImageAverageColorAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIImageAverageColorAddition.h; sourceTree = ""; }; 37 | 91B36BCC15ECBA8B00BA1F30 /* UIImageAverageColorAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIImageAverageColorAddition.m; sourceTree = ""; }; 38 | 91B36BCE15ECC09000BA1F30 /* Lena.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Lena.tiff; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 91B36BA615ECB9E100BA1F30 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | 91B36BAE15ECB9E100BA1F30 /* UIKit.framework in Frameworks */, 47 | 91B36BB015ECB9E100BA1F30 /* Foundation.framework in Frameworks */, 48 | 91B36BB215ECB9E100BA1F30 /* CoreGraphics.framework in Frameworks */, 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | 91B36B9E15ECB9E100BA1F30 = { 56 | isa = PBXGroup; 57 | children = ( 58 | 91B36BB315ECB9E100BA1F30 /* UIImageAverageColor */, 59 | 91B36BAC15ECB9E100BA1F30 /* Frameworks */, 60 | 91B36BAA15ECB9E100BA1F30 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 91B36BAA15ECB9E100BA1F30 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 91B36BA915ECB9E100BA1F30 /* UIImageAverageColor.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 91B36BAC15ECB9E100BA1F30 /* Frameworks */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 91B36BAD15ECB9E100BA1F30 /* UIKit.framework */, 76 | 91B36BAF15ECB9E100BA1F30 /* Foundation.framework */, 77 | 91B36BB115ECB9E100BA1F30 /* CoreGraphics.framework */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | 91B36BB315ECB9E100BA1F30 /* UIImageAverageColor */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 91B36BBC15ECB9E100BA1F30 /* NRAppDelegate.h */, 86 | 91B36BBD15ECB9E100BA1F30 /* NRAppDelegate.m */, 87 | 91B36BBF15ECB9E100BA1F30 /* NRViewController.h */, 88 | 91B36BC015ECB9E100BA1F30 /* NRViewController.m */, 89 | 91B36BC215ECB9E100BA1F30 /* NRViewController.xib */, 90 | 91B36BB415ECB9E100BA1F30 /* Supporting Files */, 91 | 91B36BCB15ECBA8B00BA1F30 /* UIImageAverageColorAddition.h */, 92 | 91B36BCC15ECBA8B00BA1F30 /* UIImageAverageColorAddition.m */, 93 | ); 94 | path = UIImageAverageColor; 95 | sourceTree = ""; 96 | }; 97 | 91B36BB415ECB9E100BA1F30 /* Supporting Files */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 91B36BB515ECB9E100BA1F30 /* UIImageAverageColor-Info.plist */, 101 | 91B36BB615ECB9E100BA1F30 /* InfoPlist.strings */, 102 | 91B36BB915ECB9E100BA1F30 /* main.m */, 103 | 91B36BBB15ECB9E100BA1F30 /* UIImageAverageColor-Prefix.pch */, 104 | 91B36BCE15ECC09000BA1F30 /* Lena.tiff */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | /* End PBXGroup section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | 91B36BA815ECB9E100BA1F30 /* UIImageAverageColor */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = 91B36BC715ECB9E100BA1F30 /* Build configuration list for PBXNativeTarget "UIImageAverageColor" */; 115 | buildPhases = ( 116 | 91B36BA515ECB9E100BA1F30 /* Sources */, 117 | 91B36BA615ECB9E100BA1F30 /* Frameworks */, 118 | 91B36BA715ECB9E100BA1F30 /* Resources */, 119 | ); 120 | buildRules = ( 121 | ); 122 | dependencies = ( 123 | ); 124 | name = UIImageAverageColor; 125 | productName = AvgColor; 126 | productReference = 91B36BA915ECB9E100BA1F30 /* UIImageAverageColor.app */; 127 | productType = "com.apple.product-type.application"; 128 | }; 129 | /* End PBXNativeTarget section */ 130 | 131 | /* Begin PBXProject section */ 132 | 91B36BA015ECB9E100BA1F30 /* Project object */ = { 133 | isa = PBXProject; 134 | attributes = { 135 | CLASSPREFIX = NR; 136 | LastUpgradeCheck = 0450; 137 | ORGANIZATIONNAME = "Savoy Software"; 138 | }; 139 | buildConfigurationList = 91B36BA315ECB9E100BA1F30 /* Build configuration list for PBXProject "UIImageAverageColor" */; 140 | compatibilityVersion = "Xcode 3.2"; 141 | developmentRegion = English; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | ); 146 | mainGroup = 91B36B9E15ECB9E100BA1F30; 147 | productRefGroup = 91B36BAA15ECB9E100BA1F30 /* Products */; 148 | projectDirPath = ""; 149 | projectRoot = ""; 150 | targets = ( 151 | 91B36BA815ECB9E100BA1F30 /* UIImageAverageColor */, 152 | ); 153 | }; 154 | /* End PBXProject section */ 155 | 156 | /* Begin PBXResourcesBuildPhase section */ 157 | 91B36BA715ECB9E100BA1F30 /* Resources */ = { 158 | isa = PBXResourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | 91B36BB815ECB9E100BA1F30 /* InfoPlist.strings in Resources */, 162 | 91B36BC415ECB9E100BA1F30 /* NRViewController.xib in Resources */, 163 | 91B36BCF15ECC09000BA1F30 /* Lena.tiff in Resources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXResourcesBuildPhase section */ 168 | 169 | /* Begin PBXSourcesBuildPhase section */ 170 | 91B36BA515ECB9E100BA1F30 /* Sources */ = { 171 | isa = PBXSourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | 91B36BBA15ECB9E100BA1F30 /* main.m in Sources */, 175 | 91B36BBE15ECB9E100BA1F30 /* NRAppDelegate.m in Sources */, 176 | 91B36BC115ECB9E100BA1F30 /* NRViewController.m in Sources */, 177 | 91B36BCD15ECBA8B00BA1F30 /* UIImageAverageColorAddition.m in Sources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXSourcesBuildPhase section */ 182 | 183 | /* Begin PBXVariantGroup section */ 184 | 91B36BB615ECB9E100BA1F30 /* InfoPlist.strings */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | 91B36BB715ECB9E100BA1F30 /* en */, 188 | ); 189 | name = InfoPlist.strings; 190 | sourceTree = ""; 191 | }; 192 | 91B36BC215ECB9E100BA1F30 /* NRViewController.xib */ = { 193 | isa = PBXVariantGroup; 194 | children = ( 195 | 91B36BC315ECB9E100BA1F30 /* en */, 196 | ); 197 | name = NRViewController.xib; 198 | sourceTree = ""; 199 | }; 200 | /* End PBXVariantGroup section */ 201 | 202 | /* Begin XCBuildConfiguration section */ 203 | 91B36BC515ECB9E100BA1F30 /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_OBJC_ARC = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 221 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 225 | SDKROOT = iphoneos; 226 | }; 227 | name = Debug; 228 | }; 229 | 91B36BC615ECB9E100BA1F30 /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | COPY_PHASE_STRIP = YES; 239 | GCC_C_LANGUAGE_STANDARD = gnu99; 240 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 244 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 245 | SDKROOT = iphoneos; 246 | VALIDATE_PRODUCT = YES; 247 | }; 248 | name = Release; 249 | }; 250 | 91B36BC815ECB9E100BA1F30 /* Debug */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 254 | GCC_PREFIX_HEADER = "UIImageAverageColor/UIImageAverageColor-Prefix.pch"; 255 | INFOPLIST_FILE = "UIImageAverageColor/UIImageAverageColor-Info.plist"; 256 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 257 | PRODUCT_NAME = UIImageAverageColor; 258 | WRAPPER_EXTENSION = app; 259 | }; 260 | name = Debug; 261 | }; 262 | 91B36BC915ECB9E100BA1F30 /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 266 | GCC_PREFIX_HEADER = "UIImageAverageColor/UIImageAverageColor-Prefix.pch"; 267 | INFOPLIST_FILE = "UIImageAverageColor/UIImageAverageColor-Info.plist"; 268 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 269 | PRODUCT_NAME = UIImageAverageColor; 270 | WRAPPER_EXTENSION = app; 271 | }; 272 | name = Release; 273 | }; 274 | /* End XCBuildConfiguration section */ 275 | 276 | /* Begin XCConfigurationList section */ 277 | 91B36BA315ECB9E100BA1F30 /* Build configuration list for PBXProject "UIImageAverageColor" */ = { 278 | isa = XCConfigurationList; 279 | buildConfigurations = ( 280 | 91B36BC515ECB9E100BA1F30 /* Debug */, 281 | 91B36BC615ECB9E100BA1F30 /* Release */, 282 | ); 283 | defaultConfigurationIsVisible = 0; 284 | defaultConfigurationName = Release; 285 | }; 286 | 91B36BC715ECB9E100BA1F30 /* Build configuration list for PBXNativeTarget "UIImageAverageColor" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | 91B36BC815ECB9E100BA1F30 /* Debug */, 290 | 91B36BC915ECB9E100BA1F30 /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | defaultConfigurationName = Release; 294 | }; 295 | /* End XCConfigurationList section */ 296 | }; 297 | rootObject = 91B36BA015ECB9E100BA1F30 /* Project object */; 298 | } 299 | -------------------------------------------------------------------------------- /UIImageAverageColor/en.lproj/NRViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1536 5 | 12B19 6 | 2829 7 | 1187 8 | 624.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 1914 12 | 13 | 14 | IBProxyObject 15 | IBUIBarButtonItem 16 | IBUIImageView 17 | IBUILabel 18 | IBUIToolbar 19 | IBUIView 20 | 21 | 22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 23 | 24 | 25 | PluginDependencyRecalculationVersion 26 | 27 | 28 | 29 | 30 | IBFilesOwner 31 | IBCocoaTouchFramework 32 | 33 | 34 | IBFirstResponder 35 | IBCocoaTouchFramework 36 | 37 | 38 | 39 | 274 40 | 41 | 42 | 43 | 274 44 | {320, 320} 45 | 46 | 47 | _NS:9 48 | NO 49 | IBCocoaTouchFramework 50 | 51 | NSImage 52 | Lena.tiff 53 | 54 | 55 | 56 | 57 | 292 58 | {{20, 330}, {280, 21}} 59 | 60 | 61 | _NS:9 62 | NO 63 | YES 64 | 7 65 | NO 66 | IBCocoaTouchFramework 67 | 68 | 0 69 | Average Color 70 | 71 | 1 72 | MCAwIDAAA 73 | darkTextColor 74 | 75 | 1 76 | 77 | 1 78 | 17 79 | 80 | 81 | Helvetica 82 | 17 83 | 16 84 | 85 | NO 86 | 0 87 | 88 | 89 | 90 | 292 91 | {{20, 359}, {280, 21}} 92 | 93 | 94 | _NS:9 95 | NO 96 | YES 97 | 7 98 | NO 99 | IBCocoaTouchFramework 100 | 101 | 0 102 | Merged Color 103 | 104 | 1 105 | 106 | 107 | NO 108 | 0 109 | 110 | 111 | 112 | 292 113 | {{20, 388}, {280, 21}} 114 | 115 | 116 | _NS:9 117 | NO 118 | YES 119 | 7 120 | NO 121 | IBCocoaTouchFramework 122 | 123 | 0 124 | Result 125 | 126 | 1 127 | 128 | 129 | NO 130 | 0 131 | 132 | 133 | 134 | 266 135 | {{0, 416}, {320, 44}} 136 | 137 | 138 | _NS:9 139 | NO 140 | NO 141 | IBCocoaTouchFramework 142 | 143 | 144 | Test Average 145 | IBCocoaTouchFramework 146 | 1 147 | 148 | 149 | 150 | Test Merge 151 | IBCocoaTouchFramework 152 | 1 153 | 154 | 155 | 156 | 157 | 158 | {{0, 20}, {320, 460}} 159 | 160 | 161 | 162 | 3 163 | MC43NQA 164 | 165 | 2 166 | 167 | 168 | NO 169 | 170 | IBCocoaTouchFramework 171 | 172 | 173 | 174 | 175 | 176 | 177 | view 178 | 179 | 180 | 181 | 7 182 | 183 | 184 | 185 | averageColorLabel 186 | 187 | 188 | 189 | 29 190 | 191 | 192 | 193 | mergedColorLabel 194 | 195 | 196 | 197 | 30 198 | 199 | 200 | 201 | imageView 202 | 203 | 204 | 205 | 31 206 | 207 | 208 | 209 | resultLabel 210 | 211 | 212 | 213 | 61 214 | 215 | 216 | 217 | testAverage: 218 | 219 | 220 | 221 | 62 222 | 223 | 224 | 225 | testMerge: 226 | 227 | 228 | 229 | 63 230 | 231 | 232 | 233 | 234 | 235 | 0 236 | 237 | 238 | 239 | 240 | 241 | -1 242 | 243 | 244 | File's Owner 245 | 246 | 247 | -2 248 | 249 | 250 | 251 | 252 | 6 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 8 265 | 266 | 267 | 268 | 269 | 270 | 16 271 | 272 | 273 | 274 | 275 | 21 276 | 277 | 278 | 279 | 280 | 32 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 33 290 | 291 | 292 | 293 | 294 | 37 295 | 296 | 297 | 298 | 299 | 47 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | NRViewController 308 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 309 | UIResponder 310 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 311 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 312 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 313 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 314 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 315 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 316 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 317 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 318 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 319 | 320 | 321 | 322 | 323 | 324 | 63 325 | 326 | 327 | 328 | 329 | NRViewController 330 | UIViewController 331 | 332 | UIBarButtonItem 333 | UIBarButtonItem 334 | 335 | 336 | 337 | testAverage: 338 | UIBarButtonItem 339 | 340 | 341 | testMerge: 342 | UIBarButtonItem 343 | 344 | 345 | 346 | UILabel 347 | UIImageView 348 | UILabel 349 | UILabel 350 | 351 | 352 | 353 | averageColorLabel 354 | UILabel 355 | 356 | 357 | imageView 358 | UIImageView 359 | 360 | 361 | mergedColorLabel 362 | UILabel 363 | 364 | 365 | resultLabel 366 | UILabel 367 | 368 | 369 | 370 | IBProjectSource 371 | ./Classes/NRViewController.h 372 | 373 | 374 | 375 | 376 | 0 377 | IBCocoaTouchFramework 378 | YES 379 | 3 380 | 381 | Lena.tiff 382 | {512, 512} 383 | 384 | 1914 385 | 386 | 387 | --------------------------------------------------------------------------------