├── .gitignore ├── ImageFun ├── ImageFun.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── ImageFun │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── UIImageExtension.swift │ ├── ViewController.swift │ └── images.jpeg └── ImageFunTests │ ├── ImageFunTests.swift │ └── Info.plist ├── LICENSE ├── README.md └── Screenshots └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /ImageFun/ImageFun.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EAB41AD41A11E09F008DFF79 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB41AD31A11E09F008DFF79 /* AppDelegate.swift */; }; 11 | EAB41AD61A11E09F008DFF79 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB41AD51A11E09F008DFF79 /* ViewController.swift */; }; 12 | EAB41AD91A11E09F008DFF79 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EAB41AD71A11E09F008DFF79 /* Main.storyboard */; }; 13 | EAB41ADB1A11E09F008DFF79 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAB41ADA1A11E09F008DFF79 /* Images.xcassets */; }; 14 | EAB41ADE1A11E09F008DFF79 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = EAB41ADC1A11E09F008DFF79 /* LaunchScreen.xib */; }; 15 | EAB41AEA1A11E09F008DFF79 /* ImageFunTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB41AE91A11E09F008DFF79 /* ImageFunTests.swift */; }; 16 | EAB41AF41A11E0D5008DFF79 /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB41AF31A11E0D5008DFF79 /* UIImageExtension.swift */; }; 17 | EAB41AF61A11E12C008DFF79 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAB41AF51A11E12C008DFF79 /* CoreGraphics.framework */; }; 18 | EAB41AF81A11E8B8008DFF79 /* images.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = EAB41AF71A11E8B8008DFF79 /* images.jpeg */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | EAB41AE41A11E09F008DFF79 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = EAB41AC61A11E09E008DFF79 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = EAB41ACD1A11E09F008DFF79; 27 | remoteInfo = ImageFun; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | EAB41ACE1A11E09F008DFF79 /* ImageFun.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageFun.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | EAB41AD21A11E09F008DFF79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | EAB41AD31A11E09F008DFF79 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 35 | EAB41AD51A11E09F008DFF79 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 36 | EAB41AD81A11E09F008DFF79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | EAB41ADA1A11E09F008DFF79 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | EAB41ADD1A11E09F008DFF79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 39 | EAB41AE31A11E09F008DFF79 /* ImageFunTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageFunTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | EAB41AE81A11E09F008DFF79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | EAB41AE91A11E09F008DFF79 /* ImageFunTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageFunTests.swift; sourceTree = ""; }; 42 | EAB41AF31A11E0D5008DFF79 /* UIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = ""; }; 43 | EAB41AF51A11E12C008DFF79 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 44 | EAB41AF71A11E8B8008DFF79 /* images.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = images.jpeg; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | EAB41ACB1A11E09F008DFF79 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | EAB41AF61A11E12C008DFF79 /* CoreGraphics.framework in Frameworks */, 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | EAB41AE01A11E09F008DFF79 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | EAB41AC51A11E09E008DFF79 = { 67 | isa = PBXGroup; 68 | children = ( 69 | EAB41AF51A11E12C008DFF79 /* CoreGraphics.framework */, 70 | EAB41AD01A11E09F008DFF79 /* ImageFun */, 71 | EAB41AE61A11E09F008DFF79 /* ImageFunTests */, 72 | EAB41ACF1A11E09F008DFF79 /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | EAB41ACF1A11E09F008DFF79 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | EAB41ACE1A11E09F008DFF79 /* ImageFun.app */, 80 | EAB41AE31A11E09F008DFF79 /* ImageFunTests.xctest */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | EAB41AD01A11E09F008DFF79 /* ImageFun */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | EAB41AF71A11E8B8008DFF79 /* images.jpeg */, 89 | EAB41AD31A11E09F008DFF79 /* AppDelegate.swift */, 90 | EAB41AD51A11E09F008DFF79 /* ViewController.swift */, 91 | EAB41AD71A11E09F008DFF79 /* Main.storyboard */, 92 | EAB41ADA1A11E09F008DFF79 /* Images.xcassets */, 93 | EAB41ADC1A11E09F008DFF79 /* LaunchScreen.xib */, 94 | EAB41AD11A11E09F008DFF79 /* Supporting Files */, 95 | EAB41AF31A11E0D5008DFF79 /* UIImageExtension.swift */, 96 | ); 97 | path = ImageFun; 98 | sourceTree = ""; 99 | }; 100 | EAB41AD11A11E09F008DFF79 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | EAB41AD21A11E09F008DFF79 /* Info.plist */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | EAB41AE61A11E09F008DFF79 /* ImageFunTests */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | EAB41AE91A11E09F008DFF79 /* ImageFunTests.swift */, 112 | EAB41AE71A11E09F008DFF79 /* Supporting Files */, 113 | ); 114 | path = ImageFunTests; 115 | sourceTree = ""; 116 | }; 117 | EAB41AE71A11E09F008DFF79 /* Supporting Files */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | EAB41AE81A11E09F008DFF79 /* Info.plist */, 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | /* End PBXGroup section */ 126 | 127 | /* Begin PBXNativeTarget section */ 128 | EAB41ACD1A11E09F008DFF79 /* ImageFun */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = EAB41AED1A11E09F008DFF79 /* Build configuration list for PBXNativeTarget "ImageFun" */; 131 | buildPhases = ( 132 | EAB41ACA1A11E09F008DFF79 /* Sources */, 133 | EAB41ACB1A11E09F008DFF79 /* Frameworks */, 134 | EAB41ACC1A11E09F008DFF79 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | ); 140 | name = ImageFun; 141 | productName = ImageFun; 142 | productReference = EAB41ACE1A11E09F008DFF79 /* ImageFun.app */; 143 | productType = "com.apple.product-type.application"; 144 | }; 145 | EAB41AE21A11E09F008DFF79 /* ImageFunTests */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = EAB41AF01A11E09F008DFF79 /* Build configuration list for PBXNativeTarget "ImageFunTests" */; 148 | buildPhases = ( 149 | EAB41ADF1A11E09F008DFF79 /* Sources */, 150 | EAB41AE01A11E09F008DFF79 /* Frameworks */, 151 | EAB41AE11A11E09F008DFF79 /* Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | EAB41AE51A11E09F008DFF79 /* PBXTargetDependency */, 157 | ); 158 | name = ImageFunTests; 159 | productName = ImageFunTests; 160 | productReference = EAB41AE31A11E09F008DFF79 /* ImageFunTests.xctest */; 161 | productType = "com.apple.product-type.bundle.unit-test"; 162 | }; 163 | /* End PBXNativeTarget section */ 164 | 165 | /* Begin PBXProject section */ 166 | EAB41AC61A11E09E008DFF79 /* Project object */ = { 167 | isa = PBXProject; 168 | attributes = { 169 | LastUpgradeCheck = 0600; 170 | ORGANIZATIONNAME = "Neeraj Kumar"; 171 | TargetAttributes = { 172 | EAB41ACD1A11E09F008DFF79 = { 173 | CreatedOnToolsVersion = 6.0.1; 174 | }; 175 | EAB41AE21A11E09F008DFF79 = { 176 | CreatedOnToolsVersion = 6.0.1; 177 | TestTargetID = EAB41ACD1A11E09F008DFF79; 178 | }; 179 | }; 180 | }; 181 | buildConfigurationList = EAB41AC91A11E09E008DFF79 /* Build configuration list for PBXProject "ImageFun" */; 182 | compatibilityVersion = "Xcode 3.2"; 183 | developmentRegion = English; 184 | hasScannedForEncodings = 0; 185 | knownRegions = ( 186 | en, 187 | Base, 188 | ); 189 | mainGroup = EAB41AC51A11E09E008DFF79; 190 | productRefGroup = EAB41ACF1A11E09F008DFF79 /* Products */; 191 | projectDirPath = ""; 192 | projectRoot = ""; 193 | targets = ( 194 | EAB41ACD1A11E09F008DFF79 /* ImageFun */, 195 | EAB41AE21A11E09F008DFF79 /* ImageFunTests */, 196 | ); 197 | }; 198 | /* End PBXProject section */ 199 | 200 | /* Begin PBXResourcesBuildPhase section */ 201 | EAB41ACC1A11E09F008DFF79 /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | EAB41AD91A11E09F008DFF79 /* Main.storyboard in Resources */, 206 | EAB41AF81A11E8B8008DFF79 /* images.jpeg in Resources */, 207 | EAB41ADE1A11E09F008DFF79 /* LaunchScreen.xib in Resources */, 208 | EAB41ADB1A11E09F008DFF79 /* Images.xcassets in Resources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | EAB41AE11A11E09F008DFF79 /* Resources */ = { 213 | isa = PBXResourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | EAB41ACA1A11E09F008DFF79 /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | EAB41AD61A11E09F008DFF79 /* ViewController.swift in Sources */, 227 | EAB41AD41A11E09F008DFF79 /* AppDelegate.swift in Sources */, 228 | EAB41AF41A11E0D5008DFF79 /* UIImageExtension.swift in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | EAB41ADF1A11E09F008DFF79 /* Sources */ = { 233 | isa = PBXSourcesBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | EAB41AEA1A11E09F008DFF79 /* ImageFunTests.swift in Sources */, 237 | ); 238 | runOnlyForDeploymentPostprocessing = 0; 239 | }; 240 | /* End PBXSourcesBuildPhase section */ 241 | 242 | /* Begin PBXTargetDependency section */ 243 | EAB41AE51A11E09F008DFF79 /* PBXTargetDependency */ = { 244 | isa = PBXTargetDependency; 245 | target = EAB41ACD1A11E09F008DFF79 /* ImageFun */; 246 | targetProxy = EAB41AE41A11E09F008DFF79 /* PBXContainerItemProxy */; 247 | }; 248 | /* End PBXTargetDependency section */ 249 | 250 | /* Begin PBXVariantGroup section */ 251 | EAB41AD71A11E09F008DFF79 /* Main.storyboard */ = { 252 | isa = PBXVariantGroup; 253 | children = ( 254 | EAB41AD81A11E09F008DFF79 /* Base */, 255 | ); 256 | name = Main.storyboard; 257 | sourceTree = ""; 258 | }; 259 | EAB41ADC1A11E09F008DFF79 /* LaunchScreen.xib */ = { 260 | isa = PBXVariantGroup; 261 | children = ( 262 | EAB41ADD1A11E09F008DFF79 /* Base */, 263 | ); 264 | name = LaunchScreen.xib; 265 | sourceTree = ""; 266 | }; 267 | /* End PBXVariantGroup section */ 268 | 269 | /* Begin XCBuildConfiguration section */ 270 | EAB41AEB1A11E09F008DFF79 /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ALWAYS_SEARCH_USER_PATHS = NO; 274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 275 | CLANG_CXX_LIBRARY = "libc++"; 276 | CLANG_ENABLE_MODULES = YES; 277 | CLANG_ENABLE_OBJC_ARC = YES; 278 | CLANG_WARN_BOOL_CONVERSION = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | ENABLE_STRICT_OBJC_MSGSEND = YES; 290 | GCC_C_LANGUAGE_STANDARD = gnu99; 291 | GCC_DYNAMIC_NO_PIC = NO; 292 | GCC_OPTIMIZATION_LEVEL = 0; 293 | GCC_PREPROCESSOR_DEFINITIONS = ( 294 | "DEBUG=1", 295 | "$(inherited)", 296 | ); 297 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 298 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 299 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 300 | GCC_WARN_UNDECLARED_SELECTOR = YES; 301 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 302 | GCC_WARN_UNUSED_FUNCTION = YES; 303 | GCC_WARN_UNUSED_VARIABLE = YES; 304 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 305 | MTL_ENABLE_DEBUG_INFO = YES; 306 | ONLY_ACTIVE_ARCH = YES; 307 | SDKROOT = iphoneos; 308 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 309 | }; 310 | name = Debug; 311 | }; 312 | EAB41AEC1A11E09F008DFF79 /* Release */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ALWAYS_SEARCH_USER_PATHS = NO; 316 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 317 | CLANG_CXX_LIBRARY = "libc++"; 318 | CLANG_ENABLE_MODULES = YES; 319 | CLANG_ENABLE_OBJC_ARC = YES; 320 | CLANG_WARN_BOOL_CONVERSION = YES; 321 | CLANG_WARN_CONSTANT_CONVERSION = YES; 322 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 323 | CLANG_WARN_EMPTY_BODY = YES; 324 | CLANG_WARN_ENUM_CONVERSION = YES; 325 | CLANG_WARN_INT_CONVERSION = YES; 326 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 327 | CLANG_WARN_UNREACHABLE_CODE = YES; 328 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 329 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 330 | COPY_PHASE_STRIP = YES; 331 | ENABLE_NS_ASSERTIONS = NO; 332 | ENABLE_STRICT_OBJC_MSGSEND = YES; 333 | GCC_C_LANGUAGE_STANDARD = gnu99; 334 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 335 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 336 | GCC_WARN_UNDECLARED_SELECTOR = YES; 337 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 338 | GCC_WARN_UNUSED_FUNCTION = YES; 339 | GCC_WARN_UNUSED_VARIABLE = YES; 340 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 341 | MTL_ENABLE_DEBUG_INFO = NO; 342 | SDKROOT = iphoneos; 343 | VALIDATE_PRODUCT = YES; 344 | }; 345 | name = Release; 346 | }; 347 | EAB41AEE1A11E09F008DFF79 /* Debug */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 351 | INFOPLIST_FILE = ImageFun/Info.plist; 352 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | }; 355 | name = Debug; 356 | }; 357 | EAB41AEF1A11E09F008DFF79 /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 361 | INFOPLIST_FILE = ImageFun/Info.plist; 362 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 363 | PRODUCT_NAME = "$(TARGET_NAME)"; 364 | }; 365 | name = Release; 366 | }; 367 | EAB41AF11A11E09F008DFF79 /* Debug */ = { 368 | isa = XCBuildConfiguration; 369 | buildSettings = { 370 | BUNDLE_LOADER = "$(TEST_HOST)"; 371 | FRAMEWORK_SEARCH_PATHS = ( 372 | "$(SDKROOT)/Developer/Library/Frameworks", 373 | "$(inherited)", 374 | ); 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | INFOPLIST_FILE = ImageFunTests/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 381 | PRODUCT_NAME = "$(TARGET_NAME)"; 382 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageFun.app/ImageFun"; 383 | }; 384 | name = Debug; 385 | }; 386 | EAB41AF21A11E09F008DFF79 /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | BUNDLE_LOADER = "$(TEST_HOST)"; 390 | FRAMEWORK_SEARCH_PATHS = ( 391 | "$(SDKROOT)/Developer/Library/Frameworks", 392 | "$(inherited)", 393 | ); 394 | INFOPLIST_FILE = ImageFunTests/Info.plist; 395 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageFun.app/ImageFun"; 398 | }; 399 | name = Release; 400 | }; 401 | /* End XCBuildConfiguration section */ 402 | 403 | /* Begin XCConfigurationList section */ 404 | EAB41AC91A11E09E008DFF79 /* Build configuration list for PBXProject "ImageFun" */ = { 405 | isa = XCConfigurationList; 406 | buildConfigurations = ( 407 | EAB41AEB1A11E09F008DFF79 /* Debug */, 408 | EAB41AEC1A11E09F008DFF79 /* Release */, 409 | ); 410 | defaultConfigurationIsVisible = 0; 411 | defaultConfigurationName = Release; 412 | }; 413 | EAB41AED1A11E09F008DFF79 /* Build configuration list for PBXNativeTarget "ImageFun" */ = { 414 | isa = XCConfigurationList; 415 | buildConfigurations = ( 416 | EAB41AEE1A11E09F008DFF79 /* Debug */, 417 | EAB41AEF1A11E09F008DFF79 /* Release */, 418 | ); 419 | defaultConfigurationIsVisible = 0; 420 | }; 421 | EAB41AF01A11E09F008DFF79 /* Build configuration list for PBXNativeTarget "ImageFunTests" */ = { 422 | isa = XCConfigurationList; 423 | buildConfigurations = ( 424 | EAB41AF11A11E09F008DFF79 /* Debug */, 425 | EAB41AF21A11E09F008DFF79 /* Release */, 426 | ); 427 | defaultConfigurationIsVisible = 0; 428 | }; 429 | /* End XCConfigurationList section */ 430 | }; 431 | rootObject = EAB41AC61A11E09E008DFF79 /* Project object */; 432 | } 433 | -------------------------------------------------------------------------------- /ImageFun/ImageFun.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ImageFun 4 | // 5 | // Created by Neeraj Kumar on 11/11/14. 6 | // Copyright (c) 2014 Neeraj Kumar. 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 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/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 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ImageFun/ImageFun/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | NK.$(PRODUCT_NAME:rfc1034identifier) 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 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/UIImageExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageExtension.swift 3 | // ImageFun 4 | // 5 | // Created by Neeraj Kumar on 11/11/14. 6 | // Copyright (c) 2014 Neeraj Kumar. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | private extension UIImage { 13 | private func createARGBBitmapContext(inImage: CGImageRef) -> CGContext { 14 | 15 | //Get image width, height 16 | let pixelsWide = CGImageGetWidth(inImage) 17 | let pixelsHigh = CGImageGetHeight(inImage) 18 | 19 | // Declare the number of bytes per row. Each pixel in the bitmap in this 20 | // example is represented by 4 bytes; 8 bits each of red, green, blue, and 21 | // alpha. 22 | let bitmapBytesPerRow = Int(pixelsWide) * 4 23 | let bitmapByteCount = bitmapBytesPerRow * Int(pixelsHigh) 24 | 25 | // Use the generic RGB color space. 26 | let colorSpace = CGColorSpaceCreateDeviceRGB() 27 | 28 | // Allocate memory for image data. This is the destination in memory 29 | // where any drawing to the bitmap context will be rendered. 30 | var bitmapData = UnsafeMutablePointer() 31 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue) 32 | 33 | // Create the bitmap context. We want pre-multiplied ARGB, 8-bits 34 | // per component. Regardless of what the source image format is 35 | // (CMYK, Grayscale, and so on) it will be converted over to the format 36 | // specified here by CGBitmapContextCreate. 37 | let context = CGBitmapContextCreate(bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, bitmapInfo) 38 | 39 | return context 40 | } 41 | 42 | func sanitizePoint(point:CGPoint) { 43 | let inImage:CGImageRef = self.CGImage 44 | let pixelsWide = CGImageGetWidth(inImage) 45 | let pixelsHigh = CGImageGetHeight(inImage) 46 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 47 | 48 | precondition(CGRectContainsPoint(rect, point), "CGPoint passed is not inside the rect of image.It will give wrong pixel and may crash.") 49 | } 50 | } 51 | 52 | 53 | // Internal functions exposed.Can be public. 54 | 55 | extension UIImage { 56 | typealias RawColorType = (newRedColor:UInt8, newgreenColor:UInt8, newblueColor:UInt8, newalphaValue:UInt8) 57 | 58 | 59 | /* 60 | Change the color of pixel at a certain point.If you want more control try block based method to modify pixels. 61 | */ 62 | func setPixelColorAtPoint(point:CGPoint, color: RawColorType) -> UIImage? { 63 | self.sanitizePoint(point) 64 | let inImage:CGImageRef = self.CGImage 65 | let context = self.createARGBBitmapContext(inImage) 66 | 67 | let pixelsWide = CGImageGetWidth(inImage) 68 | let pixelsHigh = CGImageGetHeight(inImage) 69 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 70 | 71 | //Clear the context 72 | CGContextClearRect(context, rect) 73 | 74 | // Draw the image to the bitmap context. Once we draw, the memory 75 | // allocated for the context for rendering will then contain the 76 | // raw image data in the specified color space. 77 | CGContextDrawImage(context, rect, inImage) 78 | 79 | // Now we can get a pointer to the image data associated with the bitmap 80 | // context. 81 | var data = CGBitmapContextGetData(context) 82 | var dataType = UnsafeMutablePointer(data) 83 | 84 | let offset = 4*((Int(pixelsWide) * Int(point.y)) + Int(point.x)) 85 | dataType[offset] = color.newalphaValue 86 | dataType[offset+1] = color.newRedColor 87 | dataType[offset+2] = color.newgreenColor 88 | dataType[offset+3] = color.newblueColor 89 | 90 | let colorSpace = CGColorSpaceCreateDeviceRGB() 91 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue) 92 | 93 | let bitmapBytesPerRow = Int(pixelsWide) * 4 94 | let bitmapByteCount = bitmapBytesPerRow * Int(pixelsHigh) 95 | 96 | let finalcontext = CGBitmapContextCreate(data, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, bitmapInfo) 97 | 98 | let imageRef = CGBitmapContextCreateImage(finalcontext) 99 | return UIImage(CGImage: imageRef, scale: self.scale,orientation: self.imageOrientation) 100 | 101 | } 102 | 103 | 104 | /* 105 | Get pixel color for a pixel in the image. 106 | */ 107 | func getPixelColorAtLocation(point:CGPoint)->UIColor? { 108 | self.sanitizePoint(point) 109 | // Create off screen bitmap context to draw the image into. Format ARGB is 4 bytes for each pixel: Alpa, Red, Green, Blue 110 | let inImage:CGImageRef = self.CGImage 111 | let context = self.createARGBBitmapContext(inImage) 112 | 113 | let pixelsWide = CGImageGetWidth(inImage) 114 | let pixelsHigh = CGImageGetHeight(inImage) 115 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 116 | 117 | //Clear the context 118 | CGContextClearRect(context, rect) 119 | 120 | // Draw the image to the bitmap context. Once we draw, the memory 121 | // allocated for the context for rendering will then contain the 122 | // raw image data in the specified color space. 123 | CGContextDrawImage(context, rect, inImage) 124 | 125 | // Now we can get a pointer to the image data associated with the bitmap 126 | // context. 127 | let data = CGBitmapContextGetData(context) 128 | let dataType = UnsafePointer(data) 129 | 130 | let offset = 4*((Int(pixelsWide) * Int(point.y)) + Int(point.x)) 131 | let alphaValue = dataType[offset] 132 | let redColor = dataType[offset+1] 133 | let greenColor = dataType[offset+2] 134 | let blueColor = dataType[offset+3] 135 | 136 | let redFloat = CGFloat(redColor)/255.0 137 | let greenFloat = CGFloat(greenColor)/255.0 138 | let blueFloat = CGFloat(blueColor)/255.0 139 | let alphaFloat = CGFloat(alphaValue)/255.0 140 | 141 | return UIColor(red: redFloat, green: greenFloat, blue: blueFloat, alpha: alphaFloat) 142 | 143 | // When finished, release the context 144 | // Free image data memory for the context 145 | } 146 | 147 | 148 | // Get grayscale image from normal image. 149 | 150 | func getGrayScale() -> UIImage? { 151 | let inImage:CGImageRef = self.CGImage 152 | let context = self.createARGBBitmapContext(inImage) 153 | let pixelsWide = CGImageGetWidth(inImage) 154 | let pixelsHigh = CGImageGetHeight(inImage) 155 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 156 | 157 | let bitmapBytesPerRow = Int(pixelsWide) * 4 158 | let bitmapByteCount = bitmapBytesPerRow * Int(pixelsHigh) 159 | 160 | //Clear the context 161 | CGContextClearRect(context, rect) 162 | 163 | // Draw the image to the bitmap context. Once we draw, the memory 164 | // allocated for the context for rendering will then contain the 165 | // raw image data in the specified color space. 166 | CGContextDrawImage(context, rect, inImage) 167 | 168 | // Now we can get a pointer to the image data associated with the bitmap 169 | // context. 170 | 171 | 172 | var data = CGBitmapContextGetData(context) 173 | var dataType = UnsafeMutablePointer(data) 174 | let point: CGPoint = CGPointMake(0, 0) 175 | 176 | for var x = 0; x < Int(pixelsWide) ; x++ { 177 | for var y = 0; y < Int(pixelsHigh) ; y++ { 178 | let offset = 4*((Int(pixelsWide) * Int(y)) + Int(x)) 179 | let alpha = dataType[offset] 180 | let red = dataType[offset+1] 181 | let green = dataType[offset+2] 182 | let blue = dataType[offset+3] 183 | 184 | let avg = (UInt32(red) + UInt32(green) + UInt32(blue))/3 185 | 186 | dataType[offset + 1] = UInt8(avg) 187 | dataType[offset + 2] = UInt8(avg) 188 | dataType[offset + 3] = UInt8(avg) 189 | } 190 | } 191 | 192 | let colorSpace = CGColorSpaceCreateDeviceRGB() 193 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue) 194 | 195 | let finalcontext = CGBitmapContextCreate(data, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, bitmapInfo) 196 | 197 | let imageRef = CGBitmapContextCreateImage(finalcontext) 198 | return UIImage(CGImage: imageRef, scale: self.scale,orientation: self.imageOrientation) 199 | } 200 | 201 | 202 | 203 | // Defining the closure. 204 | typealias ModifyPixelsClosure = (point:CGPoint, redColor:UInt8, greenColor:UInt8, blueColor:UInt8, alphaValue:UInt8)->(newRedColor:UInt8, newgreenColor:UInt8, newblueColor:UInt8, newalphaValue:UInt8) 205 | 206 | 207 | // Provide closure which will return new color value for pixel using any condition you want inside the closure. 208 | 209 | func applyOnPixels(closure:ModifyPixelsClosure) -> UIImage? { 210 | let inImage:CGImageRef = self.CGImage 211 | let context = self.createARGBBitmapContext(inImage) 212 | let pixelsWide = CGImageGetWidth(inImage) 213 | let pixelsHigh = CGImageGetHeight(inImage) 214 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 215 | 216 | let bitmapBytesPerRow = Int(pixelsWide) * 4 217 | let bitmapByteCount = bitmapBytesPerRow * Int(pixelsHigh) 218 | 219 | //Clear the context 220 | CGContextClearRect(context, rect) 221 | 222 | // Draw the image to the bitmap context. Once we draw, the memory 223 | // allocated for the context for rendering will then contain the 224 | // raw image data in the specified color space. 225 | CGContextDrawImage(context, rect, inImage) 226 | 227 | // Now we can get a pointer to the image data associated with the bitmap 228 | // context. 229 | 230 | 231 | var data = CGBitmapContextGetData(context) 232 | var dataType = UnsafeMutablePointer(data) 233 | let point: CGPoint = CGPointMake(0, 0) 234 | 235 | for var x = 0; x < Int(pixelsWide) ; x++ { 236 | for var y = 0; y < Int(pixelsHigh) ; y++ { 237 | let offset = 4*((Int(pixelsWide) * Int(y)) + Int(x)) 238 | let alpha = dataType[offset] 239 | let red = dataType[offset+1] 240 | let green = dataType[offset+2] 241 | let blue = dataType[offset+3] 242 | let (newRedColor:UInt8, newGreenColor:UInt8, newBlueColor:UInt8, newAlphaValue:UInt8) = closure(point: CGPointMake(CGFloat(x), CGFloat(y)), redColor: red, greenColor: green, blueColor: blue, alphaValue: alpha) 243 | dataType[offset] = newAlphaValue 244 | dataType[offset + 1] = newRedColor 245 | dataType[offset + 2] = newGreenColor 246 | dataType[offset + 3] = newBlueColor 247 | } 248 | } 249 | 250 | let colorSpace = CGColorSpaceCreateDeviceRGB() 251 | let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue) 252 | 253 | let finalcontext = CGBitmapContextCreate(data, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, bitmapInfo) 254 | 255 | let imageRef = CGBitmapContextCreateImage(finalcontext) 256 | return UIImage(CGImage: imageRef, scale: self.scale,orientation: self.imageOrientation) 257 | } 258 | 259 | } -------------------------------------------------------------------------------- /ImageFun/ImageFun/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ImageFun 4 | // 5 | // Created by Neeraj Kumar on 11/11/14. 6 | // Copyright (c) 2014 Neeraj Kumar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | let image:UIImage = UIImage(named: "images.jpeg")! 17 | 18 | // Displaying original image. 19 | var originalImageView:UIImageView = UIImageView(frame: CGRectMake(20, 20, image.size.width, image.size.height)) 20 | originalImageView.image = image 21 | self.view.addSubview(originalImageView) 22 | 23 | // GrayScaled image. 24 | var imageView:UIImageView = UIImageView(frame: CGRectMake(20, CGRectGetMaxY(originalImageView.frame) + 10, image.size.width, image.size.height)) 25 | 26 | imageView.image = image.getGrayScale() 27 | self.view.addSubview(imageView) 28 | 29 | // Modify image colors. 30 | var modifiedImageView:UIImageView = UIImageView(frame: CGRectMake(20, CGRectGetMaxY(imageView.frame) + 10, image.size.width, image.size.height)) 31 | modifiedImageView.image = image.applyOnPixels({ (point, redColor, greenColor, blueColor, alphaValue) -> (newRedColor: UInt8, newgreenColor: UInt8, newblueColor: UInt8, newalphaValue: UInt8) in 32 | 33 | let avg = (UInt32(redColor) + UInt32(greenColor) + UInt32(blueColor))/3 34 | if (Double(UInt32(redColor)) > (Double(avg) * 1.8)) { 35 | return (0,0,200,255) 36 | } 37 | else { 38 | return (redColor,greenColor,blueColor,alphaValue) 39 | } 40 | 41 | }) 42 | self.view.addSubview(modifiedImageView) 43 | } 44 | 45 | override func didReceiveMemoryWarning() { 46 | super.didReceiveMemoryWarning() 47 | // Dispose of any resources that can be recreated. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /ImageFun/ImageFun/images.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kn-neeraj/ImagePixelFun/a640422fade11ba90719471a5db89ae9a1f4b285/ImageFun/ImageFun/images.jpeg -------------------------------------------------------------------------------- /ImageFun/ImageFunTests/ImageFunTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFunTests.swift 3 | // ImageFunTests 4 | // 5 | // Created by Neeraj Kumar on 11/11/14. 6 | // Copyright (c) 2014 Neeraj Kumar. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ImageFunTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ImageFun/ImageFunTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | NK.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ImagePixelFun 2 | ============= 3 | A small UIImage extension to play with pixels of an image. 4 | Helper methods to - 5 | Set/Get colors of a pixel. 6 | Create a grayscale image. 7 | Change color of an array of pixels conditionally by providing closure. 8 | 9 | Here is the accompanying blog - https://medium.com/hacking-ios/uiimage-pixel-play-extension-in-swift-7c6fe90396b6 10 | 11 | Screenshot - 12 | https://github.com/kNeerajPro/ImagePixelFun/blob/master/Screenshots/screenshot.png 13 | -------------------------------------------------------------------------------- /Screenshots/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kn-neeraj/ImagePixelFun/a640422fade11ba90719471a5db89ae9a1f4b285/Screenshots/screenshot.png --------------------------------------------------------------------------------