├── CoreImageTest.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── misupeng.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── misupeng.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── CoreImageTest\.xcscheme │ └── xcschememanagement.plist ├── CoreImageTest\ ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-120.png │ │ ├── Icon-121.png │ │ ├── Icon-152.png │ │ ├── Icon-167.png │ │ ├── Icon-180.png │ │ ├── Icon-29.png │ │ ├── Icon-40.png │ │ ├── Icon-58.png │ │ ├── Icon-59.png │ │ ├── Icon-76.png │ │ ├── Icon-80.png │ │ ├── Icon-81.png │ │ └── Icon-87.png │ ├── Contents.json │ ├── jobs.imageset │ │ ├── 18009692.jpg │ │ └── Contents.json │ ├── qrc.imageset │ │ ├── 1471418949.png │ │ └── Contents.json │ ├── rect.imageset │ │ ├── Contents.json │ │ └── Q048101955PY.jpg │ ├── shit.imageset │ │ ├── 1470722773722.png │ │ └── Contents.json │ └── text.imageset │ │ ├── Contents.json │ │ └── QQ20160817-0.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── BlurSelectVC.swift ├── BlurVC.swift ├── DetectorVC.swift ├── Info.plist ├── MainTVC.swift └── ScrollBarPanel.xib ├── LICENSE ├── README.md └── ScreenShot ├── face.png ├── filter.png ├── filter_list.png └── main.png /CoreImageTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C4A6FD701D615A1800554097 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A6FD6F1D615A1800554097 /* AppDelegate.swift */; }; 11 | C4A6FD751D615A1800554097 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4A6FD731D615A1800554097 /* Main.storyboard */; }; 12 | C4A6FD771D615A1900554097 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4A6FD761D615A1900554097 /* Assets.xcassets */; }; 13 | C4A6FD7A1D615A1900554097 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4A6FD781D615A1900554097 /* LaunchScreen.storyboard */; }; 14 | C4A6FD821D615A4F00554097 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4A6FD811D615A4F00554097 /* CoreImage.framework */; }; 15 | C4A6FD871D61626900554097 /* MainTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A6FD861D61626900554097 /* MainTVC.swift */; }; 16 | C4A6FD891D62B9B300554097 /* ScrollBarPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4A6FD881D62B9B300554097 /* ScrollBarPanel.xib */; }; 17 | C4A6FD8B1D62BB1400554097 /* BlurVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A6FD8A1D62BB1400554097 /* BlurVC.swift */; }; 18 | C4A6FD8D1D62CF7700554097 /* BlurSelectVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A6FD8C1D62CF7700554097 /* BlurSelectVC.swift */; }; 19 | C4A6FD8F1D63FCD000554097 /* DetectorVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A6FD8E1D63FCD000554097 /* DetectorVC.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | C4A6FD6C1D615A1800554097 /* CoreImageTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreImageTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | C4A6FD6F1D615A1800554097 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 25 | C4A6FD741D615A1800554097 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | C4A6FD761D615A1900554097 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | C4A6FD791D615A1900554097 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | C4A6FD7B1D615A1900554097 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | C4A6FD811D615A4F00554097 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; }; 30 | C4A6FD861D61626900554097 /* MainTVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTVC.swift; sourceTree = ""; }; 31 | C4A6FD881D62B9B300554097 /* ScrollBarPanel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ScrollBarPanel.xib; sourceTree = ""; }; 32 | C4A6FD8A1D62BB1400554097 /* BlurVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurVC.swift; sourceTree = ""; }; 33 | C4A6FD8C1D62CF7700554097 /* BlurSelectVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurSelectVC.swift; sourceTree = ""; }; 34 | C4A6FD8E1D63FCD000554097 /* DetectorVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetectorVC.swift; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | C4A6FD691D615A1800554097 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | C4A6FD821D615A4F00554097 /* CoreImage.framework in Frameworks */, 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXFrameworksBuildPhase section */ 47 | 48 | /* Begin PBXGroup section */ 49 | C4A6FD631D615A1800554097 = { 50 | isa = PBXGroup; 51 | children = ( 52 | C4A6FD811D615A4F00554097 /* CoreImage.framework */, 53 | C4A6FD6E1D615A1800554097 /* CoreImageTest */, 54 | C4A6FD6D1D615A1800554097 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | C4A6FD6D1D615A1800554097 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | C4A6FD6C1D615A1800554097 /* CoreImageTest.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | C4A6FD6E1D615A1800554097 /* CoreImageTest */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | C4A6FD6F1D615A1800554097 /* AppDelegate.swift */, 70 | C4A6FD861D61626900554097 /* MainTVC.swift */, 71 | C4A6FD8A1D62BB1400554097 /* BlurVC.swift */, 72 | C4A6FD8C1D62CF7700554097 /* BlurSelectVC.swift */, 73 | C4A6FD8E1D63FCD000554097 /* DetectorVC.swift */, 74 | C4A6FD831D615BB500554097 /* Resources */, 75 | ); 76 | name = CoreImageTest; 77 | path = "CoreImageTest\\"; 78 | sourceTree = ""; 79 | }; 80 | C4A6FD831D615BB500554097 /* Resources */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | C4A6FD731D615A1800554097 /* Main.storyboard */, 84 | C4A6FD781D615A1900554097 /* LaunchScreen.storyboard */, 85 | C4A6FD881D62B9B300554097 /* ScrollBarPanel.xib */, 86 | C4A6FD7B1D615A1900554097 /* Info.plist */, 87 | C4A6FD761D615A1900554097 /* Assets.xcassets */, 88 | ); 89 | name = Resources; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | C4A6FD6B1D615A1800554097 /* CoreImageTest */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = C4A6FD7E1D615A1900554097 /* Build configuration list for PBXNativeTarget "CoreImageTest" */; 98 | buildPhases = ( 99 | C4A6FD681D615A1800554097 /* Sources */, 100 | C4A6FD691D615A1800554097 /* Frameworks */, 101 | C4A6FD6A1D615A1800554097 /* Resources */, 102 | ); 103 | buildRules = ( 104 | ); 105 | dependencies = ( 106 | ); 107 | name = CoreImageTest; 108 | productName = "CoreImageTest\\"; 109 | productReference = C4A6FD6C1D615A1800554097 /* CoreImageTest.app */; 110 | productType = "com.apple.product-type.application"; 111 | }; 112 | /* End PBXNativeTarget section */ 113 | 114 | /* Begin PBXProject section */ 115 | C4A6FD641D615A1800554097 /* Project object */ = { 116 | isa = PBXProject; 117 | attributes = { 118 | LastSwiftUpdateCheck = 0730; 119 | LastUpgradeCheck = 0730; 120 | ORGANIZATIONNAME = misuqian; 121 | TargetAttributes = { 122 | C4A6FD6B1D615A1800554097 = { 123 | CreatedOnToolsVersion = 7.3.1; 124 | }; 125 | }; 126 | }; 127 | buildConfigurationList = C4A6FD671D615A1800554097 /* Build configuration list for PBXProject "CoreImageTest" */; 128 | compatibilityVersion = "Xcode 3.2"; 129 | developmentRegion = English; 130 | hasScannedForEncodings = 0; 131 | knownRegions = ( 132 | en, 133 | Base, 134 | ); 135 | mainGroup = C4A6FD631D615A1800554097; 136 | productRefGroup = C4A6FD6D1D615A1800554097 /* Products */; 137 | projectDirPath = ""; 138 | projectRoot = ""; 139 | targets = ( 140 | C4A6FD6B1D615A1800554097 /* CoreImageTest */, 141 | ); 142 | }; 143 | /* End PBXProject section */ 144 | 145 | /* Begin PBXResourcesBuildPhase section */ 146 | C4A6FD6A1D615A1800554097 /* Resources */ = { 147 | isa = PBXResourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | C4A6FD7A1D615A1900554097 /* LaunchScreen.storyboard in Resources */, 151 | C4A6FD771D615A1900554097 /* Assets.xcassets in Resources */, 152 | C4A6FD751D615A1800554097 /* Main.storyboard in Resources */, 153 | C4A6FD891D62B9B300554097 /* ScrollBarPanel.xib in Resources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXResourcesBuildPhase section */ 158 | 159 | /* Begin PBXSourcesBuildPhase section */ 160 | C4A6FD681D615A1800554097 /* Sources */ = { 161 | isa = PBXSourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | C4A6FD871D61626900554097 /* MainTVC.swift in Sources */, 165 | C4A6FD8B1D62BB1400554097 /* BlurVC.swift in Sources */, 166 | C4A6FD8F1D63FCD000554097 /* DetectorVC.swift in Sources */, 167 | C4A6FD701D615A1800554097 /* AppDelegate.swift in Sources */, 168 | C4A6FD8D1D62CF7700554097 /* BlurSelectVC.swift in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | C4A6FD731D615A1800554097 /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | C4A6FD741D615A1800554097 /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | C4A6FD781D615A1900554097 /* LaunchScreen.storyboard */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | C4A6FD791D615A1900554097 /* Base */, 187 | ); 188 | name = LaunchScreen.storyboard; 189 | sourceTree = ""; 190 | }; 191 | /* End PBXVariantGroup section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | C4A6FD7C1D615A1900554097 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_ANALYZER_NONNULL = YES; 199 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 200 | CLANG_CXX_LIBRARY = "libc++"; 201 | CLANG_ENABLE_MODULES = YES; 202 | CLANG_ENABLE_OBJC_ARC = YES; 203 | CLANG_WARN_BOOL_CONVERSION = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 206 | CLANG_WARN_EMPTY_BODY = YES; 207 | CLANG_WARN_ENUM_CONVERSION = YES; 208 | CLANG_WARN_INT_CONVERSION = YES; 209 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 210 | CLANG_WARN_UNREACHABLE_CODE = YES; 211 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 212 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 213 | COPY_PHASE_STRIP = NO; 214 | DEBUG_INFORMATION_FORMAT = dwarf; 215 | ENABLE_STRICT_OBJC_MSGSEND = YES; 216 | ENABLE_TESTABILITY = YES; 217 | GCC_C_LANGUAGE_STANDARD = gnu99; 218 | GCC_DYNAMIC_NO_PIC = NO; 219 | GCC_NO_COMMON_BLOCKS = YES; 220 | GCC_OPTIMIZATION_LEVEL = 0; 221 | GCC_PREPROCESSOR_DEFINITIONS = ( 222 | "DEBUG=1", 223 | "$(inherited)", 224 | ); 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 227 | GCC_WARN_UNDECLARED_SELECTOR = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 229 | GCC_WARN_UNUSED_FUNCTION = YES; 230 | GCC_WARN_UNUSED_VARIABLE = YES; 231 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 232 | MTL_ENABLE_DEBUG_INFO = YES; 233 | ONLY_ACTIVE_ARCH = YES; 234 | SDKROOT = iphoneos; 235 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 236 | TARGETED_DEVICE_FAMILY = "1,2"; 237 | }; 238 | name = Debug; 239 | }; 240 | C4A6FD7D1D615A1900554097 /* Release */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_ANALYZER_NONNULL = YES; 245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 246 | CLANG_CXX_LIBRARY = "libc++"; 247 | CLANG_ENABLE_MODULES = YES; 248 | CLANG_ENABLE_OBJC_ARC = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_CONSTANT_CONVERSION = YES; 251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 272 | MTL_ENABLE_DEBUG_INFO = NO; 273 | SDKROOT = iphoneos; 274 | TARGETED_DEVICE_FAMILY = "1,2"; 275 | VALIDATE_PRODUCT = YES; 276 | }; 277 | name = Release; 278 | }; 279 | C4A6FD7F1D615A1900554097 /* Debug */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 283 | INFOPLIST_FILE = "CoreImageTest\\/Info.plist"; 284 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = sustc.micoder.CoreImageTest; 287 | PRODUCT_NAME = CoreImageTest; 288 | }; 289 | name = Debug; 290 | }; 291 | C4A6FD801D615A1900554097 /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | INFOPLIST_FILE = "CoreImageTest\\/Info.plist"; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | PRODUCT_BUNDLE_IDENTIFIER = sustc.micoder.CoreImageTest; 299 | PRODUCT_NAME = CoreImageTest; 300 | }; 301 | name = Release; 302 | }; 303 | /* End XCBuildConfiguration section */ 304 | 305 | /* Begin XCConfigurationList section */ 306 | C4A6FD671D615A1800554097 /* Build configuration list for PBXProject "CoreImageTest" */ = { 307 | isa = XCConfigurationList; 308 | buildConfigurations = ( 309 | C4A6FD7C1D615A1900554097 /* Debug */, 310 | C4A6FD7D1D615A1900554097 /* Release */, 311 | ); 312 | defaultConfigurationIsVisible = 0; 313 | defaultConfigurationName = Release; 314 | }; 315 | C4A6FD7E1D615A1900554097 /* Build configuration list for PBXNativeTarget "CoreImageTest" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | C4A6FD7F1D615A1900554097 /* Debug */, 319 | C4A6FD801D615A1900554097 /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | defaultConfigurationName = Release; 323 | }; 324 | /* End XCConfigurationList section */ 325 | }; 326 | rootObject = C4A6FD641D615A1800554097 /* Project object */; 327 | } 328 | -------------------------------------------------------------------------------- /CoreImageTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CoreImageTest.xcodeproj/project.xcworkspace/xcuserdata/misupeng.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest.xcodeproj/project.xcworkspace/xcuserdata/misupeng.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CoreImageTest.xcodeproj/xcuserdata/misupeng.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CoreImageTest.xcodeproj/xcuserdata/misupeng.xcuserdatad/xcschemes/CoreImageTest\.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CoreImageTest.xcodeproj/xcuserdata/misupeng.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CoreImageTest\.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C4A6FD6B1D615A1800554097 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreImageTest\/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CoreImageTest\ 4 | // 5 | // Created by misupeng on 16/8/15. 6 | // Copyright © 2016年 misuqian. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-121.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "Icon-29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "Icon-59.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "Icon-40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-81.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-120.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-121.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-152.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-167.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-180.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-29.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-58.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-59.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-80.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-81.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-81.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/AppIcon.appiconset/Icon-87.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/jobs.imageset/18009692.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/jobs.imageset/18009692.jpg -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/jobs.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "18009692.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/qrc.imageset/1471418949.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/qrc.imageset/1471418949.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/qrc.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1471418949.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/rect.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Q048101955PY.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/rect.imageset/Q048101955PY.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/rect.imageset/Q048101955PY.jpg -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/shit.imageset/1470722773722.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/shit.imageset/1470722773722.png -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/shit.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1470722773722.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/text.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "QQ20160817-0.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CoreImageTest\/Assets.xcassets/text.imageset/QQ20160817-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/CoreImageTest\/Assets.xcassets/text.imageset/QQ20160817-0.png -------------------------------------------------------------------------------- /CoreImageTest\/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CoreImageTest\/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | -------------------------------------------------------------------------------- /CoreImageTest\/BlurSelectVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlurSelectVC.swift 3 | // CoreImageTest 4 | // 5 | // Created by misupeng on 16/8/16. 6 | // Copyright © 2016年 misuqian. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //滤镜选择界面 12 | class BlurSelectVC: UIViewController,UITableViewDataSource,UITableViewDelegate{ 13 | @IBOutlet weak var tableView: UITableView! 14 | private var blurDatas = [String]() 15 | var delegate : BlurDelegate! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | tableView.delegate = self 20 | tableView.dataSource = self 21 | 22 | let filterNames = CIFilter.filterNamesInCategory(kCICategoryBuiltIn) as [String] //获取支持的所有滤镜 23 | self.blurDatas = filterNames 24 | } 25 | 26 | override func didReceiveMemoryWarning() { 27 | super.didReceiveMemoryWarning() 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 32 | return blurDatas.count 33 | } 34 | 35 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 36 | var cell = tableView.dequeueReusableCellWithIdentifier("cell") 37 | if cell == nil{ 38 | cell = UITableViewCell(style: .Default, reuseIdentifier: "cell") 39 | } 40 | cell?.textLabel?.text = blurDatas[indexPath.row] 41 | return cell! 42 | } 43 | 44 | func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 45 | delegate.didSelectBlurName(blurDatas[indexPath.row]) 46 | self.dismissViewControllerAnimated(true, completion: nil) 47 | } 48 | 49 | @IBAction func cancel(sender: UIBarButtonItem) { 50 | self.dismissViewControllerAnimated(true, completion: nil) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /CoreImageTest\/BlurVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlurVC.swift 3 | // CoreImageTest 4 | // 5 | // Created by misupeng on 16/8/16. 6 | // Copyright © 2016年 misuqian. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GLKit 11 | import OpenGLES 12 | 13 | protocol BlurDelegate { 14 | func didSelectBlurName(name : String) 15 | } 16 | 17 | //滤镜处理界面 18 | class BlurVC: UIViewController,BlurDelegate{ 19 | 20 | @IBOutlet weak var imageView: FilterImageView! 21 | @IBOutlet weak var scrollView: UIScrollView! 22 | private var inputKeys : [String] = [String]() 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | didSelectBlurName("CIDotScreen") 27 | } 28 | 29 | override func viewDidDisappear(animated: Bool) { 30 | super.viewDidDisappear(animated) 31 | EAGLContext.setCurrentContext(nil) 32 | } 33 | 34 | override func didReceiveMemoryWarning() { 35 | super.didReceiveMemoryWarning() 36 | 37 | } 38 | 39 | //选择滤镜后初始化 40 | func didSelectBlurName(name: String) { 41 | if let filter = CIFilter(name: name){ 42 | self.navigationItem.title = name 43 | self.inputKeys = filter.inputKeys 44 | let attri = filter.attributes 45 | let scrollWidth = self.scrollView.frame.width 46 | let cellHeight : CGFloat = 60.0 47 | for view in self.scrollView.subviews{ 48 | if view is ScrollBarView{ 49 | view.removeFromSuperview() //清空原先的滑动条 50 | } 51 | } 52 | var count = 0 53 | for i in 0..{ 58 | //根据attribute属性动态添加属性设置滚动条 59 | let panel = NSBundle.mainBundle().loadNibNamed("ScrollBarPanel", owner: nil, options: nil).first as! ScrollBarView 60 | panel.frame = CGRect(x: 0.0, y: CGFloat(count) * cellHeight, width: scrollWidth, height: cellHeight) 61 | panel.title.text = dic[kCIAttributeDisplayName] as? String ?? key 62 | panel.number.text = "\(dic[kCIAttributeDefault]!)" 63 | let max : Float = dic[kCIAttributeSliderMax] as? Float ?? 1.0 64 | let min : Float = dic[kCIAttributeSliderMin] as? Float ?? 0.0 65 | if dic[kCIAttributeClass] as! String != "NSNumber"{ 66 | panel.scrollBar.enabled = false //不是NSNumber的属性不能滚动设置.此可扩展,一般还有Vector,Transform等属性参数 67 | } 68 | panel.scrollBar.maximumValue = max 69 | panel.scrollBar.minimumValue = min 70 | panel.scrollBar.value = dic[kCIAttributeDefault] as? Float ?? 0.0 71 | panel.scrollBar.tag = i 72 | panel.scrollBar.addTarget(self, action: #selector(BlurVC.scrollBarChanged(_:)), forControlEvents: UIControlEvents.ValueChanged) 73 | 74 | self.scrollView.addSubview(panel) 75 | count += 1 76 | } 77 | } 78 | imageView.inputImage = UIImage(named: "shit")! 79 | imageView.filter = filter 80 | self.scrollView.contentSize = CGSize(width: scrollWidth, height: CGFloat(count) * cellHeight) 81 | }else{ 82 | print("filter init fail,GG") 83 | } 84 | } 85 | 86 | //显示滤镜选择界面 87 | private func showBlurSelect(){ 88 | let storyboard = UIStoryboard(name: "Main", bundle: nil) 89 | let vc = storyboard.instantiateViewControllerWithIdentifier("blurSelect") as! BlurSelectVC 90 | vc.delegate = self 91 | self.presentViewController(vc, animated: true, completion: nil) 92 | } 93 | 94 | @IBAction func selectBlur(sender: UIBarButtonItem) { 95 | self.showBlurSelect() 96 | } 97 | 98 | //滑动条滑动响应 99 | func scrollBarChanged(slider : UISlider){ 100 | let label = slider.superview?.viewWithTag(3) as? UILabel 101 | label?.text = String(format: "%.2f", slider.value) 102 | if let _filter = self.imageView.filter{ 103 | //设置滤镜属性重新绘制imageView 104 | _filter.setValue(slider.value, forKey: inputKeys[slider.tag]) 105 | imageView.setNeedsDisplay() 106 | } 107 | } 108 | } 109 | 110 | class ScrollBarView : UIView{ 111 | @IBOutlet weak var title: UILabel! 112 | @IBOutlet weak var number: UILabel! 113 | @IBOutlet weak var scrollBar: UISlider! 114 | } 115 | 116 | //OpenGL重绘滤镜图片 117 | class FilterImageView : GLKView{ 118 | private var ciContext: CIContext! 119 | 120 | var filter: CIFilter! { 121 | didSet { 122 | setNeedsDisplay() 123 | } 124 | } 125 | 126 | var inputImage: UIImage! { 127 | didSet { 128 | setNeedsDisplay() 129 | } 130 | } 131 | 132 | override func awakeFromNib() { 133 | super.awakeFromNib() 134 | clipsToBounds = true 135 | self.context = EAGLContext(API: .OpenGLES2) //必须使用2.0 136 | ciContext = CIContext(EAGLContext: context) 137 | EAGLContext.setCurrentContext(self.context) 138 | } 139 | 140 | required init?(coder aDecoder: NSCoder) { 141 | super.init(coder: aDecoder) 142 | clipsToBounds = true 143 | self.context = EAGLContext(API: .OpenGLES2) 144 | ciContext = CIContext(EAGLContext: context) 145 | EAGLContext.setCurrentContext(self.context) 146 | } 147 | 148 | override func drawRect(rect: CGRect) { 149 | super.drawRect(rect) 150 | guard ciContext != nil && inputImage != nil else{ 151 | return 152 | } 153 | if let _filter = self.filter{ 154 | let inputCIImage = CIImage(image: inputImage) 155 | _filter.setValue(inputCIImage!, forKey: kCIInputImageKey) 156 | if let outputImage = _filter.outputImage { 157 | clearBackground() 158 | let inputBounds = inputCIImage!.extent 159 | let drawableBounds = CGRect(x: 0, y: 0, width: self.drawableWidth, height: self.drawableHeight) 160 | let targetBounds = aspectFill(inputBounds, toRect: drawableBounds) 161 | ciContext.drawImage(outputImage, inRect: targetBounds, fromRect: inputBounds) 162 | } 163 | } 164 | } 165 | 166 | override func layoutSubviews() { 167 | super.layoutSubviews() 168 | self.setNeedsDisplay() 169 | } 170 | 171 | //对aspectFill进行适配 172 | func aspectFill(fromRect: CGRect, toRect: CGRect) -> CGRect { 173 | let fromAspectRatio = fromRect.size.width / fromRect.size.height; 174 | let toAspectRatio = toRect.size.width / toRect.size.height; 175 | 176 | var fitRect = toRect 177 | 178 | if (fromAspectRatio > toAspectRatio) { 179 | fitRect.size.width = toRect.size.height * fromAspectRatio; 180 | fitRect.origin.x += (toRect.size.width - fitRect.size.width) * 0.5; 181 | } else { 182 | fitRect.size.height = toRect.size.width / fromAspectRatio; 183 | fitRect.origin.y += (toRect.size.height - fitRect.size.height) * 0.5; 184 | } 185 | 186 | return CGRectIntegral(fitRect) 187 | } 188 | 189 | func clearBackground() { 190 | var r: CGFloat = 0 191 | var g: CGFloat = 0 192 | var b: CGFloat = 0 193 | var a: CGFloat = 0 194 | backgroundColor?.getRed(&r, green: &g, blue: &b, alpha: &a) 195 | glClearColor(GLfloat(r), GLfloat(g), GLfloat(b), GLfloat(a)) 196 | glClear(GLbitfield(GL_COLOR_BUFFER_BIT)) 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /CoreImageTest\/DetectorVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetectorVC.swift 3 | // CoreImageTest 4 | // 5 | // Created by misupeng on 16/8/17. 6 | // Copyright © 2016年 misuqian. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreImage 11 | 12 | //检测类型enum 13 | enum DetectType : Int{ 14 | case Face = 0 15 | case Rect 16 | case Text 17 | case QRC //QR code 18 | } 19 | 20 | //图像检测界面 21 | class DetectorVC: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate{ 22 | @IBOutlet weak var imageView: UIImageView! 23 | @IBOutlet weak var textView: UITextView! 24 | var type = DetectType.Face 25 | var isFirst = true 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | switch type { 30 | case .Face: 31 | self.imageView.image = UIImage(named: "jobs") 32 | case .QRC: 33 | self.imageView.image = UIImage(named: "qrc") 34 | case .Rect: 35 | self.imageView.image = UIImage(named: "rect") 36 | case .Text: 37 | self.imageView.image = UIImage(named: "text") 38 | } 39 | } 40 | 41 | override func viewDidAppear(animated: Bool) { 42 | super.viewDidAppear(animated) 43 | if isFirst{ 44 | detect() 45 | isFirst = false 46 | } 47 | } 48 | 49 | override func didReceiveMemoryWarning() { 50 | super.didReceiveMemoryWarning() 51 | } 52 | 53 | //选择照片响应 54 | @IBAction func chooseImage(sender: UIBarButtonItem) { 55 | let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet) 56 | let camera = UIAlertAction(title: "拍照", style: .Default, handler: { _ in 57 | let imageChooser = UIImagePickerController() 58 | imageChooser.delegate = self 59 | imageChooser.allowsEditing = false 60 | imageChooser.sourceType = .Camera 61 | MainThreadRun({ 62 | self.presentViewController(imageChooser, animated: true, completion: nil) 63 | }) 64 | }) 65 | sheet.addAction(camera) 66 | 67 | let photo = UIAlertAction(title: "相册选取", style: .Default, handler: { _ in 68 | let imageChooser = UIImagePickerController() 69 | imageChooser.delegate = self 70 | imageChooser.allowsEditing = false 71 | imageChooser.sourceType = .PhotoLibrary 72 | MainThreadRun({ 73 | self.presentViewController(imageChooser, animated: true, completion: nil) 74 | }) 75 | }) 76 | sheet.addAction(photo) 77 | 78 | let cancel = UIAlertAction(title: "取消", style: .Cancel, handler: { _ in 79 | 80 | }) 81 | sheet.addAction(cancel) 82 | 83 | self.presentViewController(sheet, animated: true, completion: nil) 84 | } 85 | 86 | func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { 87 | self.clearDetect() 88 | self.imageView.image = image 89 | self.detect() 90 | picker.dismissViewControllerAnimated(true, completion: nil) 91 | } 92 | 93 | private func detect(){ 94 | switch type { 95 | case .QRC: 96 | self.navigationItem.title = "二维码检测" 97 | detect_qrc() 98 | case .Rect: 99 | self.navigationItem.title = "矩形检测" 100 | detect_rect() 101 | case .Text: 102 | self.navigationItem.title = "文字检测" 103 | detect_text() 104 | default: 105 | self.navigationItem.title = "人脸检测" 106 | detect_face() 107 | } 108 | } 109 | 110 | private func detect_face(){ 111 | AsyncThreadRun({ 112 | let option = [CIDetectorAccuracy:CIDetectorAccuracyHigh] //高准确度 113 | let dector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: option) 114 | if let cgImage : CGImage = self.imageView.image?.CGImage{ 115 | let ciImage = CIImage(CGImage: cgImage) 116 | let results = dector.featuresInImage(ciImage) 117 | var text = "" 118 | for i in 0.. CGRect { 243 | var transform = resizeTransform(self.imageView.image!) //对拍摄的照片或者特殊的图片进行处理 244 | transform = CGAffineTransformScale(transform, 1, -1) 245 | transform = CGAffineTransformTranslate(transform, 0, -inputImageSize.height) 246 | 247 | var faceViewBounds = CGRectApplyAffineTransform(rect, transform) 248 | 249 | // let transScale = 1.0 / UIScreen.mainScreen().scale 250 | // let scaleTransform = CGAffineTransformMakeScale(transScale, transScale) 251 | // faceViewBounds = CGRectApplyAffineTransform(faceViewBounds, scaleTransform) 252 | 253 | // let scaleWidth = self.imageView.bounds.size.width / inputImageSize.width 254 | // let scaleHeight = self.imageView.bounds.size.height / inputImageSize.height 255 | // faceViewBounds.size = CGSize(width: faceViewBounds.size.width * scaleWidth, height: faceViewBounds.size.height * scaleHeight) 256 | // if scaleWidth < scaleHeight{ 257 | // faceViewBounds.origin.y += (self.imageView.bounds.size.height - inputImageSize.height * scaleWidth) / 2 258 | // faceViewBounds.origin.x = faceViewBounds.origin.x * scaleWidth 259 | // }else{ 260 | // faceViewBounds.origin.x += (self.imageView.bounds.size.width - inputImageSize.width * scaleHeight) / 2 261 | // faceViewBounds.origin.y = faceViewBounds.origin.y * scaleHeight 262 | // } 263 | 264 | let scale = min(imageView.bounds.size.width / inputImageSize.width, 265 | imageView.bounds.size.height / inputImageSize.height) 266 | let offsetX = (imageView.bounds.size.width - inputImageSize.width * scale) / 2 267 | let offsetY = (imageView.bounds.size.height - inputImageSize.height * scale) / 2 268 | 269 | faceViewBounds = CGRectApplyAffineTransform(faceViewBounds, CGAffineTransformMakeScale(scale, scale)) 270 | faceViewBounds.origin.x += offsetX 271 | faceViewBounds.origin.y += offsetY 272 | 273 | return faceViewBounds 274 | } 275 | 276 | func resizeTransform(image : UIImage)-> CGAffineTransform{ 277 | var rectTransform :CGAffineTransform = CGAffineTransformIdentity 278 | switch image.imageOrientation{ 279 | case .Left,.LeftMirrored: 280 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(90.0 / 180.0 * CGFloat(M_PI)),0,-image.size.height) 281 | case .Right,.RightMirrored: 282 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(-90.0 / 180.0 * CGFloat(M_PI)),-image.size.width,0) 283 | case .Down,.DownMirrored: 284 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(-180.0 / 180.0 * CGFloat(M_PI)),-image.size.width,-image.size.height) 285 | default: 286 | break 287 | } 288 | return rectTransform 289 | } 290 | } 291 | 292 | extension UIColor{ 293 | static func randomColor() -> UIColor{ 294 | let arc = arc4random() % 6 295 | switch arc { 296 | case 0: 297 | return UIColor.yellowColor() 298 | case 1: 299 | return UIColor.blueColor() 300 | case 2: 301 | return UIColor.orangeColor() 302 | case 3: 303 | return UIColor.whiteColor() 304 | case 4: 305 | return UIColor.greenColor() 306 | case 5: 307 | return UIColor.redColor() 308 | default: 309 | return UIColor.blueColor() 310 | } 311 | } 312 | } 313 | 314 | private let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) 315 | private let group = dispatch_group_create() 316 | func MainThreadRun(action : (Void -> Void)){ 317 | dispatch_async(dispatch_get_main_queue(), { 318 | action() 319 | }) 320 | } 321 | 322 | func AsyncThreadRun(action : (Void -> Void)){ 323 | dispatch_group_async(group, queue, { () -> Void in 324 | action() 325 | }) 326 | } 327 | -------------------------------------------------------------------------------- /CoreImageTest\/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | UISupportedInterfaceOrientations~ipad 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationPortraitUpsideDown 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CoreImageTest\/MainTVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainTVC.swift 3 | // CoreImageTest 4 | // 5 | // Created by misupeng on 16/8/15. 6 | // Copyright © 2016年 misuqian. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //首页界面 12 | class MainTVC: UITableViewController { 13 | let headers : [String] = ["图像检测","图片处理"] 14 | var datas : [[(String,String)]] = [[("人脸","face"),("矩形","rect"),("文字","text"),("二维码","qrc")],[("滤镜","filter")]] 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | let label = UILabel(frame: CGRect(origin: CGPointZero, size: CGSize(width: self.view.frame.width, height: 20.0))) 19 | label.textAlignment = .Center 20 | label.text = "By misupeng" 21 | self.tableView.tableFooterView = label 22 | 23 | let os = NSProcessInfo().operatingSystemVersion 24 | if os.majorVersion < 9{ 25 | datas = [[("人脸","face"),("矩形","rect"),("二维码","qrc")],[("滤镜","filter")]] 26 | } 27 | } 28 | 29 | override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 30 | return headers.count 31 | } 32 | 33 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 34 | return datas[section].count 35 | } 36 | 37 | override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 38 | return headers[section] 39 | } 40 | 41 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 42 | var cell = tableView.dequeueReusableCellWithIdentifier("cell") 43 | if cell == nil{ 44 | cell = UITableViewCell(style: .Default, reuseIdentifier: "cell") 45 | } 46 | cell?.textLabel?.text = datas[indexPath.section][indexPath.row].0 47 | cell?.accessoryType = .DisclosureIndicator 48 | return cell! 49 | } 50 | 51 | //点击响应 52 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 53 | if let identity : String = datas[indexPath.section][indexPath.row].1 where identity != ""{ 54 | if identity == "filter"{ 55 | self.performSegueWithIdentifier(identity, sender: self) 56 | }else{ 57 | var type = DetectType.Face 58 | if identity == "rect"{ 59 | type = DetectType.Rect 60 | }else if identity == "text"{ 61 | type = DetectType.Text 62 | }else if identity == "qrc"{ 63 | type = DetectType.QRC 64 | } 65 | let storyboard = UIStoryboard(name: "Main", bundle: nil) 66 | let vc = storyboard.instantiateViewControllerWithIdentifier("detect") as! DetectorVC 67 | vc.type = type 68 | self.navigationController?.pushViewController(vc, animated: true) 69 | } 70 | } 71 | self.tableView.deselectRowAtIndexPath(indexPath, animated: false) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /CoreImageTest\/ScrollBarPanel.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 pengqian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreImage-Swift 2 | CoreImage in Swift.preview 100+ filter.face,text,QRcode detect demo 3 | 4 | ![Main](https://github.com/misuqian/CoreImage-Swift/blob/master/ScreenShot/main.png) 5 | 6 | #CIDetector 7 | Face,Text,QRcode,Rectangle detect by CIDetector 8 | 9 | ![face](https://github.com/misuqian/CoreImage-Swift/blob/master/ScreenShot/face.png) 10 | 11 | #CIFilter 12 | 100+ filter to preview.using opengl2.0 to draw image 13 | 14 | ![filter](https://github.com/misuqian/CoreImage-Swift/blob/master/ScreenShot/filter.png) 15 | ![filter_list](https://github.com/misuqian/CoreImage-Swift/blob/master/ScreenShot/filter_list.png) 16 | 17 | #License 18 | [MIT](https://github.com/misuqian/CoreImage-Swift/blob/master/LICENSE) 19 | -------------------------------------------------------------------------------- /ScreenShot/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/ScreenShot/face.png -------------------------------------------------------------------------------- /ScreenShot/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/ScreenShot/filter.png -------------------------------------------------------------------------------- /ScreenShot/filter_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/ScreenShot/filter_list.png -------------------------------------------------------------------------------- /ScreenShot/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misuqian/CoreImage-Swift/0fb1c1f605a9c7919d9dbbf648cbd1d1432b43fe/ScreenShot/main.png --------------------------------------------------------------------------------