├── ImageFilterByColorMatrix ├── ImageFilterByColorMatrix.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── YiNian.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── YiNian.xcuserdatad │ │ └── xcschemes │ │ ├── ImageFilterByColorMatrix.xcscheme │ │ └── xcschememanagement.plist ├── ImageFilterByColorMatrix │ ├── 1.jpeg │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── ZHImageFilterTool │ │ ├── ColorMatrix.h │ │ ├── UIImage-Extensions │ │ │ ├── UIImage+Alpha.h │ │ │ ├── UIImage+Alpha.m │ │ │ ├── UIImage+Cut.h │ │ │ ├── UIImage+Cut.m │ │ │ ├── UIImage+Resize.h │ │ │ ├── UIImage+Resize.m │ │ │ ├── UIImage+RoundedCorner.h │ │ │ ├── UIImage+RoundedCorner.m │ │ │ ├── UIImage+SplitImageIntoTwoParts.h │ │ │ ├── UIImage+SplitImageIntoTwoParts.m │ │ │ ├── UIImage+ZY.h │ │ │ └── UIImage+ZY.m │ │ ├── ZHMacroDefinition.h │ │ ├── ZYFilterImageView.h │ │ ├── ZYFilterImageView.m │ │ ├── ZYFilterTool.h │ │ └── ZYFilterTool.m │ └── main.m ├── ImageFilterByColorMatrixTests │ ├── ImageFilterByColorMatrixTests.m │ └── Info.plist └── ImageFilterByColorMatrixUITests │ ├── ImageFilterByColorMatrixUITests.m │ └── Info.plist └── README.md /ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 331310E91F1CA7C9008DE7D8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 331310E81F1CA7C9008DE7D8 /* main.m */; }; 11 | 331310EC1F1CA7C9008DE7D8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 331310EB1F1CA7C9008DE7D8 /* AppDelegate.m */; }; 12 | 331310EF1F1CA7C9008DE7D8 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 331310EE1F1CA7C9008DE7D8 /* ViewController.m */; }; 13 | 331310F21F1CA7C9008DE7D8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 331310F01F1CA7C9008DE7D8 /* Main.storyboard */; }; 14 | 331310F41F1CA7C9008DE7D8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 331310F31F1CA7C9008DE7D8 /* Assets.xcassets */; }; 15 | 331310F71F1CA7C9008DE7D8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 331310F51F1CA7C9008DE7D8 /* LaunchScreen.storyboard */; }; 16 | 331311021F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 331311011F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.m */; }; 17 | 3313110D1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3313110C1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.m */; }; 18 | 3337EF271F1EF14B00BCF431 /* 1.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 3337EF261F1EF14B00BCF431 /* 1.jpeg */; }; 19 | 3337EF371F1EF2BF00BCF431 /* UIImage+Alpha.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF2C1F1EF2BF00BCF431 /* UIImage+Alpha.m */; }; 20 | 3337EF381F1EF2BF00BCF431 /* UIImage+Cut.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF2E1F1EF2BF00BCF431 /* UIImage+Cut.m */; }; 21 | 3337EF391F1EF2BF00BCF431 /* UIImage+Resize.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF301F1EF2BF00BCF431 /* UIImage+Resize.m */; }; 22 | 3337EF3A1F1EF2BF00BCF431 /* UIImage+RoundedCorner.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF321F1EF2BF00BCF431 /* UIImage+RoundedCorner.m */; }; 23 | 3337EF3B1F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF341F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.m */; }; 24 | 3337EF3F1F1EF32400BCF431 /* ZYFilterTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF3E1F1EF32400BCF431 /* ZYFilterTool.m */; }; 25 | 3337EF441F1EF4A200BCF431 /* ZYFilterImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF431F1EF4A200BCF431 /* ZYFilterImageView.m */; }; 26 | 3337EF4B1F1EF76000BCF431 /* UIImage+ZY.m in Sources */ = {isa = PBXBuildFile; fileRef = 3337EF4A1F1EF76000BCF431 /* UIImage+ZY.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | 331310FE1F1CA7C9008DE7D8 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 331310DC1F1CA7C9008DE7D8 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 331310E31F1CA7C9008DE7D8; 35 | remoteInfo = ImageFilterByColorMatrix; 36 | }; 37 | 331311091F1CA7C9008DE7D8 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 331310DC1F1CA7C9008DE7D8 /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = 331310E31F1CA7C9008DE7D8; 42 | remoteInfo = ImageFilterByColorMatrix; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 331310E41F1CA7C9008DE7D8 /* ImageFilterByColorMatrix.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageFilterByColorMatrix.app; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 331310E81F1CA7C9008DE7D8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | 331310EA1F1CA7C9008DE7D8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 50 | 331310EB1F1CA7C9008DE7D8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 51 | 331310ED1F1CA7C9008DE7D8 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 52 | 331310EE1F1CA7C9008DE7D8 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 53 | 331310F11F1CA7C9008DE7D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 54 | 331310F31F1CA7C9008DE7D8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 55 | 331310F61F1CA7C9008DE7D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 56 | 331310F81F1CA7C9008DE7D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 331310FD1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageFilterByColorMatrixTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 331311011F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageFilterByColorMatrixTests.m; sourceTree = ""; }; 59 | 331311031F1CA7C9008DE7D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 331311081F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageFilterByColorMatrixUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 3313110C1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageFilterByColorMatrixUITests.m; sourceTree = ""; }; 62 | 3313110E1F1CA7C9008DE7D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | 3337EF261F1EF14B00BCF431 /* 1.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpeg; sourceTree = ""; }; 64 | 3337EF291F1EF2BF00BCF431 /* ColorMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMatrix.h; sourceTree = ""; }; 65 | 3337EF2B1F1EF2BF00BCF431 /* UIImage+Alpha.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Alpha.h"; sourceTree = ""; }; 66 | 3337EF2C1F1EF2BF00BCF431 /* UIImage+Alpha.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Alpha.m"; sourceTree = ""; }; 67 | 3337EF2D1F1EF2BF00BCF431 /* UIImage+Cut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Cut.h"; sourceTree = ""; }; 68 | 3337EF2E1F1EF2BF00BCF431 /* UIImage+Cut.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Cut.m"; sourceTree = ""; }; 69 | 3337EF2F1F1EF2BF00BCF431 /* UIImage+Resize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Resize.h"; sourceTree = ""; }; 70 | 3337EF301F1EF2BF00BCF431 /* UIImage+Resize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Resize.m"; sourceTree = ""; }; 71 | 3337EF311F1EF2BF00BCF431 /* UIImage+RoundedCorner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RoundedCorner.h"; sourceTree = ""; }; 72 | 3337EF321F1EF2BF00BCF431 /* UIImage+RoundedCorner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RoundedCorner.m"; sourceTree = ""; }; 73 | 3337EF331F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+SplitImageIntoTwoParts.h"; sourceTree = ""; }; 74 | 3337EF341F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+SplitImageIntoTwoParts.m"; sourceTree = ""; }; 75 | 3337EF3D1F1EF32400BCF431 /* ZYFilterTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZYFilterTool.h; sourceTree = ""; }; 76 | 3337EF3E1F1EF32400BCF431 /* ZYFilterTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZYFilterTool.m; sourceTree = ""; }; 77 | 3337EF411F1EF4A200BCF431 /* ZHMacroDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHMacroDefinition.h; sourceTree = ""; }; 78 | 3337EF421F1EF4A200BCF431 /* ZYFilterImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZYFilterImageView.h; sourceTree = ""; }; 79 | 3337EF431F1EF4A200BCF431 /* ZYFilterImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZYFilterImageView.m; sourceTree = ""; }; 80 | 3337EF471F1EF6FC00BCF431 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 81 | 3337EF491F1EF76000BCF431 /* UIImage+ZY.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ZY.h"; sourceTree = ""; }; 82 | 3337EF4A1F1EF76000BCF431 /* UIImage+ZY.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ZY.m"; sourceTree = ""; }; 83 | 3337EF4C1F1EF78200BCF431 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 84 | /* End PBXFileReference section */ 85 | 86 | /* Begin PBXFrameworksBuildPhase section */ 87 | 331310E11F1CA7C9008DE7D8 /* Frameworks */ = { 88 | isa = PBXFrameworksBuildPhase; 89 | buildActionMask = 2147483647; 90 | files = ( 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | 331310FA1F1CA7C9008DE7D8 /* Frameworks */ = { 95 | isa = PBXFrameworksBuildPhase; 96 | buildActionMask = 2147483647; 97 | files = ( 98 | ); 99 | runOnlyForDeploymentPostprocessing = 0; 100 | }; 101 | 331311051F1CA7C9008DE7D8 /* Frameworks */ = { 102 | isa = PBXFrameworksBuildPhase; 103 | buildActionMask = 2147483647; 104 | files = ( 105 | ); 106 | runOnlyForDeploymentPostprocessing = 0; 107 | }; 108 | /* End PBXFrameworksBuildPhase section */ 109 | 110 | /* Begin PBXGroup section */ 111 | 331310DB1F1CA7C9008DE7D8 = { 112 | isa = PBXGroup; 113 | children = ( 114 | 331310E61F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */, 115 | 331311001F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests */, 116 | 3313110B1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests */, 117 | 331310E51F1CA7C9008DE7D8 /* Products */, 118 | 3337EF461F1EF6FC00BCF431 /* Frameworks */, 119 | ); 120 | sourceTree = ""; 121 | }; 122 | 331310E51F1CA7C9008DE7D8 /* Products */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 331310E41F1CA7C9008DE7D8 /* ImageFilterByColorMatrix.app */, 126 | 331310FD1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.xctest */, 127 | 331311081F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.xctest */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | 331310E61F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 331310EA1F1CA7C9008DE7D8 /* AppDelegate.h */, 136 | 331310EB1F1CA7C9008DE7D8 /* AppDelegate.m */, 137 | 3337EF281F1EF2BF00BCF431 /* ZHImageFilterTool */, 138 | 331310ED1F1CA7C9008DE7D8 /* ViewController.h */, 139 | 331310EE1F1CA7C9008DE7D8 /* ViewController.m */, 140 | 331310F01F1CA7C9008DE7D8 /* Main.storyboard */, 141 | 331310F31F1CA7C9008DE7D8 /* Assets.xcassets */, 142 | 3337EF261F1EF14B00BCF431 /* 1.jpeg */, 143 | 331310F51F1CA7C9008DE7D8 /* LaunchScreen.storyboard */, 144 | 331310F81F1CA7C9008DE7D8 /* Info.plist */, 145 | 331310E71F1CA7C9008DE7D8 /* Supporting Files */, 146 | ); 147 | path = ImageFilterByColorMatrix; 148 | sourceTree = ""; 149 | }; 150 | 331310E71F1CA7C9008DE7D8 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 331310E81F1CA7C9008DE7D8 /* main.m */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | 331311001F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 331311011F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.m */, 162 | 331311031F1CA7C9008DE7D8 /* Info.plist */, 163 | ); 164 | path = ImageFilterByColorMatrixTests; 165 | sourceTree = ""; 166 | }; 167 | 3313110B1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 3313110C1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.m */, 171 | 3313110E1F1CA7C9008DE7D8 /* Info.plist */, 172 | ); 173 | path = ImageFilterByColorMatrixUITests; 174 | sourceTree = ""; 175 | }; 176 | 3337EF281F1EF2BF00BCF431 /* ZHImageFilterTool */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 3337EF411F1EF4A200BCF431 /* ZHMacroDefinition.h */, 180 | 3337EF421F1EF4A200BCF431 /* ZYFilterImageView.h */, 181 | 3337EF431F1EF4A200BCF431 /* ZYFilterImageView.m */, 182 | 3337EF3D1F1EF32400BCF431 /* ZYFilterTool.h */, 183 | 3337EF3E1F1EF32400BCF431 /* ZYFilterTool.m */, 184 | 3337EF291F1EF2BF00BCF431 /* ColorMatrix.h */, 185 | 3337EF2A1F1EF2BF00BCF431 /* UIImage-Extensions */, 186 | ); 187 | path = ZHImageFilterTool; 188 | sourceTree = ""; 189 | }; 190 | 3337EF2A1F1EF2BF00BCF431 /* UIImage-Extensions */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 3337EF491F1EF76000BCF431 /* UIImage+ZY.h */, 194 | 3337EF4A1F1EF76000BCF431 /* UIImage+ZY.m */, 195 | 3337EF2B1F1EF2BF00BCF431 /* UIImage+Alpha.h */, 196 | 3337EF2C1F1EF2BF00BCF431 /* UIImage+Alpha.m */, 197 | 3337EF2D1F1EF2BF00BCF431 /* UIImage+Cut.h */, 198 | 3337EF2E1F1EF2BF00BCF431 /* UIImage+Cut.m */, 199 | 3337EF2F1F1EF2BF00BCF431 /* UIImage+Resize.h */, 200 | 3337EF301F1EF2BF00BCF431 /* UIImage+Resize.m */, 201 | 3337EF311F1EF2BF00BCF431 /* UIImage+RoundedCorner.h */, 202 | 3337EF321F1EF2BF00BCF431 /* UIImage+RoundedCorner.m */, 203 | 3337EF331F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.h */, 204 | 3337EF341F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.m */, 205 | ); 206 | path = "UIImage-Extensions"; 207 | sourceTree = ""; 208 | }; 209 | 3337EF461F1EF6FC00BCF431 /* Frameworks */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | 3337EF4C1F1EF78200BCF431 /* OpenGLES.framework */, 213 | 3337EF471F1EF6FC00BCF431 /* QuartzCore.framework */, 214 | ); 215 | name = Frameworks; 216 | sourceTree = ""; 217 | }; 218 | /* End PBXGroup section */ 219 | 220 | /* Begin PBXNativeTarget section */ 221 | 331310E31F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 331311111F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrix" */; 224 | buildPhases = ( 225 | 331310E01F1CA7C9008DE7D8 /* Sources */, 226 | 331310E11F1CA7C9008DE7D8 /* Frameworks */, 227 | 331310E21F1CA7C9008DE7D8 /* Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | ); 233 | name = ImageFilterByColorMatrix; 234 | productName = ImageFilterByColorMatrix; 235 | productReference = 331310E41F1CA7C9008DE7D8 /* ImageFilterByColorMatrix.app */; 236 | productType = "com.apple.product-type.application"; 237 | }; 238 | 331310FC1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests */ = { 239 | isa = PBXNativeTarget; 240 | buildConfigurationList = 331311141F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrixTests" */; 241 | buildPhases = ( 242 | 331310F91F1CA7C9008DE7D8 /* Sources */, 243 | 331310FA1F1CA7C9008DE7D8 /* Frameworks */, 244 | 331310FB1F1CA7C9008DE7D8 /* Resources */, 245 | ); 246 | buildRules = ( 247 | ); 248 | dependencies = ( 249 | 331310FF1F1CA7C9008DE7D8 /* PBXTargetDependency */, 250 | ); 251 | name = ImageFilterByColorMatrixTests; 252 | productName = ImageFilterByColorMatrixTests; 253 | productReference = 331310FD1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.xctest */; 254 | productType = "com.apple.product-type.bundle.unit-test"; 255 | }; 256 | 331311071F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests */ = { 257 | isa = PBXNativeTarget; 258 | buildConfigurationList = 331311171F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrixUITests" */; 259 | buildPhases = ( 260 | 331311041F1CA7C9008DE7D8 /* Sources */, 261 | 331311051F1CA7C9008DE7D8 /* Frameworks */, 262 | 331311061F1CA7C9008DE7D8 /* Resources */, 263 | ); 264 | buildRules = ( 265 | ); 266 | dependencies = ( 267 | 3313110A1F1CA7C9008DE7D8 /* PBXTargetDependency */, 268 | ); 269 | name = ImageFilterByColorMatrixUITests; 270 | productName = ImageFilterByColorMatrixUITests; 271 | productReference = 331311081F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.xctest */; 272 | productType = "com.apple.product-type.bundle.ui-testing"; 273 | }; 274 | /* End PBXNativeTarget section */ 275 | 276 | /* Begin PBXProject section */ 277 | 331310DC1F1CA7C9008DE7D8 /* Project object */ = { 278 | isa = PBXProject; 279 | attributes = { 280 | LastUpgradeCheck = 0830; 281 | ORGANIZATIONNAME = "丁子恒"; 282 | TargetAttributes = { 283 | 331310E31F1CA7C9008DE7D8 = { 284 | CreatedOnToolsVersion = 8.3.3; 285 | DevelopmentTeam = 4KMKZN4473; 286 | ProvisioningStyle = Automatic; 287 | }; 288 | 331310FC1F1CA7C9008DE7D8 = { 289 | CreatedOnToolsVersion = 8.3.3; 290 | DevelopmentTeam = 4KMKZN4473; 291 | ProvisioningStyle = Automatic; 292 | TestTargetID = 331310E31F1CA7C9008DE7D8; 293 | }; 294 | 331311071F1CA7C9008DE7D8 = { 295 | CreatedOnToolsVersion = 8.3.3; 296 | DevelopmentTeam = 4KMKZN4473; 297 | ProvisioningStyle = Automatic; 298 | TestTargetID = 331310E31F1CA7C9008DE7D8; 299 | }; 300 | }; 301 | }; 302 | buildConfigurationList = 331310DF1F1CA7C9008DE7D8 /* Build configuration list for PBXProject "ImageFilterByColorMatrix" */; 303 | compatibilityVersion = "Xcode 3.2"; 304 | developmentRegion = English; 305 | hasScannedForEncodings = 0; 306 | knownRegions = ( 307 | en, 308 | Base, 309 | ); 310 | mainGroup = 331310DB1F1CA7C9008DE7D8; 311 | productRefGroup = 331310E51F1CA7C9008DE7D8 /* Products */; 312 | projectDirPath = ""; 313 | projectRoot = ""; 314 | targets = ( 315 | 331310E31F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */, 316 | 331310FC1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests */, 317 | 331311071F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests */, 318 | ); 319 | }; 320 | /* End PBXProject section */ 321 | 322 | /* Begin PBXResourcesBuildPhase section */ 323 | 331310E21F1CA7C9008DE7D8 /* Resources */ = { 324 | isa = PBXResourcesBuildPhase; 325 | buildActionMask = 2147483647; 326 | files = ( 327 | 331310F71F1CA7C9008DE7D8 /* LaunchScreen.storyboard in Resources */, 328 | 331310F41F1CA7C9008DE7D8 /* Assets.xcassets in Resources */, 329 | 331310F21F1CA7C9008DE7D8 /* Main.storyboard in Resources */, 330 | 3337EF271F1EF14B00BCF431 /* 1.jpeg in Resources */, 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | 331310FB1F1CA7C9008DE7D8 /* Resources */ = { 335 | isa = PBXResourcesBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | 331311061F1CA7C9008DE7D8 /* Resources */ = { 342 | isa = PBXResourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | }; 348 | /* End PBXResourcesBuildPhase section */ 349 | 350 | /* Begin PBXSourcesBuildPhase section */ 351 | 331310E01F1CA7C9008DE7D8 /* Sources */ = { 352 | isa = PBXSourcesBuildPhase; 353 | buildActionMask = 2147483647; 354 | files = ( 355 | 3337EF3A1F1EF2BF00BCF431 /* UIImage+RoundedCorner.m in Sources */, 356 | 3337EF441F1EF4A200BCF431 /* ZYFilterImageView.m in Sources */, 357 | 3337EF381F1EF2BF00BCF431 /* UIImage+Cut.m in Sources */, 358 | 3337EF4B1F1EF76000BCF431 /* UIImage+ZY.m in Sources */, 359 | 331310EF1F1CA7C9008DE7D8 /* ViewController.m in Sources */, 360 | 3337EF3F1F1EF32400BCF431 /* ZYFilterTool.m in Sources */, 361 | 331310EC1F1CA7C9008DE7D8 /* AppDelegate.m in Sources */, 362 | 3337EF371F1EF2BF00BCF431 /* UIImage+Alpha.m in Sources */, 363 | 331310E91F1CA7C9008DE7D8 /* main.m in Sources */, 364 | 3337EF391F1EF2BF00BCF431 /* UIImage+Resize.m in Sources */, 365 | 3337EF3B1F1EF2BF00BCF431 /* UIImage+SplitImageIntoTwoParts.m in Sources */, 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | 331310F91F1CA7C9008DE7D8 /* Sources */ = { 370 | isa = PBXSourcesBuildPhase; 371 | buildActionMask = 2147483647; 372 | files = ( 373 | 331311021F1CA7C9008DE7D8 /* ImageFilterByColorMatrixTests.m in Sources */, 374 | ); 375 | runOnlyForDeploymentPostprocessing = 0; 376 | }; 377 | 331311041F1CA7C9008DE7D8 /* Sources */ = { 378 | isa = PBXSourcesBuildPhase; 379 | buildActionMask = 2147483647; 380 | files = ( 381 | 3313110D1F1CA7C9008DE7D8 /* ImageFilterByColorMatrixUITests.m in Sources */, 382 | ); 383 | runOnlyForDeploymentPostprocessing = 0; 384 | }; 385 | /* End PBXSourcesBuildPhase section */ 386 | 387 | /* Begin PBXTargetDependency section */ 388 | 331310FF1F1CA7C9008DE7D8 /* PBXTargetDependency */ = { 389 | isa = PBXTargetDependency; 390 | target = 331310E31F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */; 391 | targetProxy = 331310FE1F1CA7C9008DE7D8 /* PBXContainerItemProxy */; 392 | }; 393 | 3313110A1F1CA7C9008DE7D8 /* PBXTargetDependency */ = { 394 | isa = PBXTargetDependency; 395 | target = 331310E31F1CA7C9008DE7D8 /* ImageFilterByColorMatrix */; 396 | targetProxy = 331311091F1CA7C9008DE7D8 /* PBXContainerItemProxy */; 397 | }; 398 | /* End PBXTargetDependency section */ 399 | 400 | /* Begin PBXVariantGroup section */ 401 | 331310F01F1CA7C9008DE7D8 /* Main.storyboard */ = { 402 | isa = PBXVariantGroup; 403 | children = ( 404 | 331310F11F1CA7C9008DE7D8 /* Base */, 405 | ); 406 | name = Main.storyboard; 407 | sourceTree = ""; 408 | }; 409 | 331310F51F1CA7C9008DE7D8 /* LaunchScreen.storyboard */ = { 410 | isa = PBXVariantGroup; 411 | children = ( 412 | 331310F61F1CA7C9008DE7D8 /* Base */, 413 | ); 414 | name = LaunchScreen.storyboard; 415 | sourceTree = ""; 416 | }; 417 | /* End PBXVariantGroup section */ 418 | 419 | /* Begin XCBuildConfiguration section */ 420 | 3313110F1F1CA7C9008DE7D8 /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ALWAYS_SEARCH_USER_PATHS = NO; 424 | CLANG_ANALYZER_NONNULL = YES; 425 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 426 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 427 | CLANG_CXX_LIBRARY = "libc++"; 428 | CLANG_ENABLE_MODULES = YES; 429 | CLANG_ENABLE_OBJC_ARC = YES; 430 | CLANG_WARN_BOOL_CONVERSION = YES; 431 | CLANG_WARN_CONSTANT_CONVERSION = YES; 432 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 433 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 434 | CLANG_WARN_EMPTY_BODY = YES; 435 | CLANG_WARN_ENUM_CONVERSION = YES; 436 | CLANG_WARN_INFINITE_RECURSION = YES; 437 | CLANG_WARN_INT_CONVERSION = YES; 438 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 439 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 440 | CLANG_WARN_UNREACHABLE_CODE = YES; 441 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 442 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 443 | COPY_PHASE_STRIP = NO; 444 | DEBUG_INFORMATION_FORMAT = dwarf; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | ENABLE_TESTABILITY = YES; 447 | GCC_C_LANGUAGE_STANDARD = gnu99; 448 | GCC_DYNAMIC_NO_PIC = NO; 449 | GCC_NO_COMMON_BLOCKS = YES; 450 | GCC_OPTIMIZATION_LEVEL = 0; 451 | GCC_PREPROCESSOR_DEFINITIONS = ( 452 | "DEBUG=1", 453 | "$(inherited)", 454 | ); 455 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 456 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 457 | GCC_WARN_UNDECLARED_SELECTOR = YES; 458 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 459 | GCC_WARN_UNUSED_FUNCTION = YES; 460 | GCC_WARN_UNUSED_VARIABLE = YES; 461 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 462 | MTL_ENABLE_DEBUG_INFO = YES; 463 | ONLY_ACTIVE_ARCH = YES; 464 | SDKROOT = iphoneos; 465 | TARGETED_DEVICE_FAMILY = "1,2"; 466 | }; 467 | name = Debug; 468 | }; 469 | 331311101F1CA7C9008DE7D8 /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ALWAYS_SEARCH_USER_PATHS = NO; 473 | CLANG_ANALYZER_NONNULL = YES; 474 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 475 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 476 | CLANG_CXX_LIBRARY = "libc++"; 477 | CLANG_ENABLE_MODULES = YES; 478 | CLANG_ENABLE_OBJC_ARC = YES; 479 | CLANG_WARN_BOOL_CONVERSION = YES; 480 | CLANG_WARN_CONSTANT_CONVERSION = YES; 481 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 482 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 483 | CLANG_WARN_EMPTY_BODY = YES; 484 | CLANG_WARN_ENUM_CONVERSION = YES; 485 | CLANG_WARN_INFINITE_RECURSION = YES; 486 | CLANG_WARN_INT_CONVERSION = YES; 487 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 488 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 489 | CLANG_WARN_UNREACHABLE_CODE = YES; 490 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 491 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 492 | COPY_PHASE_STRIP = NO; 493 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 494 | ENABLE_NS_ASSERTIONS = NO; 495 | ENABLE_STRICT_OBJC_MSGSEND = YES; 496 | GCC_C_LANGUAGE_STANDARD = gnu99; 497 | GCC_NO_COMMON_BLOCKS = YES; 498 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 499 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 500 | GCC_WARN_UNDECLARED_SELECTOR = YES; 501 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 502 | GCC_WARN_UNUSED_FUNCTION = YES; 503 | GCC_WARN_UNUSED_VARIABLE = YES; 504 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 505 | MTL_ENABLE_DEBUG_INFO = NO; 506 | SDKROOT = iphoneos; 507 | TARGETED_DEVICE_FAMILY = "1,2"; 508 | VALIDATE_PRODUCT = YES; 509 | }; 510 | name = Release; 511 | }; 512 | 331311121F1CA7C9008DE7D8 /* Debug */ = { 513 | isa = XCBuildConfiguration; 514 | buildSettings = { 515 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 516 | DEVELOPMENT_TEAM = 4KMKZN4473; 517 | INFOPLIST_FILE = ImageFilterByColorMatrix/Info.plist; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 519 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrix; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | }; 522 | name = Debug; 523 | }; 524 | 331311131F1CA7C9008DE7D8 /* Release */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 528 | DEVELOPMENT_TEAM = 4KMKZN4473; 529 | INFOPLIST_FILE = ImageFilterByColorMatrix/Info.plist; 530 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 531 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrix; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | }; 534 | name = Release; 535 | }; 536 | 331311151F1CA7C9008DE7D8 /* Debug */ = { 537 | isa = XCBuildConfiguration; 538 | buildSettings = { 539 | BUNDLE_LOADER = "$(TEST_HOST)"; 540 | DEVELOPMENT_TEAM = 4KMKZN4473; 541 | INFOPLIST_FILE = ImageFilterByColorMatrixTests/Info.plist; 542 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 543 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrixTests; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageFilterByColorMatrix.app/ImageFilterByColorMatrix"; 546 | }; 547 | name = Debug; 548 | }; 549 | 331311161F1CA7C9008DE7D8 /* Release */ = { 550 | isa = XCBuildConfiguration; 551 | buildSettings = { 552 | BUNDLE_LOADER = "$(TEST_HOST)"; 553 | DEVELOPMENT_TEAM = 4KMKZN4473; 554 | INFOPLIST_FILE = ImageFilterByColorMatrixTests/Info.plist; 555 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 556 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrixTests; 557 | PRODUCT_NAME = "$(TARGET_NAME)"; 558 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageFilterByColorMatrix.app/ImageFilterByColorMatrix"; 559 | }; 560 | name = Release; 561 | }; 562 | 331311181F1CA7C9008DE7D8 /* Debug */ = { 563 | isa = XCBuildConfiguration; 564 | buildSettings = { 565 | DEVELOPMENT_TEAM = 4KMKZN4473; 566 | INFOPLIST_FILE = ImageFilterByColorMatrixUITests/Info.plist; 567 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 568 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrixUITests; 569 | PRODUCT_NAME = "$(TARGET_NAME)"; 570 | TEST_TARGET_NAME = ImageFilterByColorMatrix; 571 | }; 572 | name = Debug; 573 | }; 574 | 331311191F1CA7C9008DE7D8 /* Release */ = { 575 | isa = XCBuildConfiguration; 576 | buildSettings = { 577 | DEVELOPMENT_TEAM = 4KMKZN4473; 578 | INFOPLIST_FILE = ImageFilterByColorMatrixUITests/Info.plist; 579 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 580 | PRODUCT_BUNDLE_IDENTIFIER = com.HenryVarro.ImageFilterByColorMatrixUITests; 581 | PRODUCT_NAME = "$(TARGET_NAME)"; 582 | TEST_TARGET_NAME = ImageFilterByColorMatrix; 583 | }; 584 | name = Release; 585 | }; 586 | /* End XCBuildConfiguration section */ 587 | 588 | /* Begin XCConfigurationList section */ 589 | 331310DF1F1CA7C9008DE7D8 /* Build configuration list for PBXProject "ImageFilterByColorMatrix" */ = { 590 | isa = XCConfigurationList; 591 | buildConfigurations = ( 592 | 3313110F1F1CA7C9008DE7D8 /* Debug */, 593 | 331311101F1CA7C9008DE7D8 /* Release */, 594 | ); 595 | defaultConfigurationIsVisible = 0; 596 | defaultConfigurationName = Release; 597 | }; 598 | 331311111F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrix" */ = { 599 | isa = XCConfigurationList; 600 | buildConfigurations = ( 601 | 331311121F1CA7C9008DE7D8 /* Debug */, 602 | 331311131F1CA7C9008DE7D8 /* Release */, 603 | ); 604 | defaultConfigurationIsVisible = 0; 605 | defaultConfigurationName = Release; 606 | }; 607 | 331311141F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrixTests" */ = { 608 | isa = XCConfigurationList; 609 | buildConfigurations = ( 610 | 331311151F1CA7C9008DE7D8 /* Debug */, 611 | 331311161F1CA7C9008DE7D8 /* Release */, 612 | ); 613 | defaultConfigurationIsVisible = 0; 614 | defaultConfigurationName = Release; 615 | }; 616 | 331311171F1CA7C9008DE7D8 /* Build configuration list for PBXNativeTarget "ImageFilterByColorMatrixUITests" */ = { 617 | isa = XCConfigurationList; 618 | buildConfigurations = ( 619 | 331311181F1CA7C9008DE7D8 /* Debug */, 620 | 331311191F1CA7C9008DE7D8 /* Release */, 621 | ); 622 | defaultConfigurationIsVisible = 0; 623 | defaultConfigurationName = Release; 624 | }; 625 | /* End XCConfigurationList section */ 626 | }; 627 | rootObject = 331310DC1F1CA7C9008DE7D8 /* Project object */; 628 | } 629 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/project.xcworkspace/xcuserdata/YiNian.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCoderDing/ImageFilterByColorMatrix/46510361910a87b21121ec6bdcc1298730f04f0a/ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/project.xcworkspace/xcuserdata/YiNian.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/xcuserdata/YiNian.xcuserdatad/xcschemes/ImageFilterByColorMatrix.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix.xcodeproj/xcuserdata/YiNian.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ImageFilterByColorMatrix.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 331310E31F1CA7C9008DE7D8 16 | 17 | primary 18 | 19 | 20 | 331310FC1F1CA7C9008DE7D8 21 | 22 | primary 23 | 24 | 25 | 331311071F1CA7C9008DE7D8 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCoderDing/ImageFilterByColorMatrix/46510361910a87b21121ec6bdcc1298730f04f0a/ImageFilterByColorMatrix/ImageFilterByColorMatrix/1.jpeg -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ImageFilterByColorMatrix 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ImageFilterByColorMatrix 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/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 | 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 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ImageFilterByColorMatrix 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ImageFilterByColorMatrix 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ZYFilterImageView.h" 11 | #import "ZHMacroDefinition.h" 12 | @interface ViewController () 13 | @property (weak, nonatomic) IBOutlet UIImageView *filterImageView; 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | ZYFilterImageView *filterSeleter =[ZYFilterImageView filterViewWithImage:[UIImage imageNamed:@"1.jpeg"] andFrame:CGRectMake(0, kScreenHeight - 96, kScreenWidth, 96)]; 23 | filterSeleter.delegate = self; 24 | [self.view addSubview:filterSeleter]; 25 | } 26 | //滤镜选择后 27 | - (void)imageFilterDidChangeWithAfterImage:(UIImage *)afterImage{ 28 | self.filterImageView.image = afterImage; 29 | } 30 | 31 | - (void)didReceiveMemoryWarning { 32 | [super didReceiveMemoryWarning]; 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/ColorMatrix.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.h 3 | // pictureProcess 4 | // 5 | // Created by Ibokan on 12-9-7. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | // 1、LOMO 10 | const float colormatrix_lomo[] = { 11 | // 1.7f, 0.1f, 0.1f, 0, -73.1f, 12 | // 0, 1.7f, 0.1f, 0, -73.1f, 13 | // 0, 0.1f, 1.6f, 0, -73.1f, 14 | // 0, 0, 0, 1.0f, 0 15 | 1.20, 0.10, 0.10, 0.00, -73.10, 16 | 0.00, 1.20, 0.10, 0.00, -73.10, 17 | 0.00, 0.10, 1.10, 0.00, -73.10, 18 | 0.00, 0.00, 0.00, 0.00, 0.00 19 | }; 20 | 21 | // 2、黑白 22 | const float colormatrix_heibai[] = { 23 | 24 | 25 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 26 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 27 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 28 | // 0, 0, 0, 1.0f, 0 29 | 0.00, 0.00, 1.00, 0.00, -1, 30 | 0.00, 0.00, 1.00, 0.00, -1, 31 | 0.00, 0.00, 1.00, 0.00, -1, 32 | 0.00, 0.00, 0.00, 1.00, 0.00 33 | }; 34 | // 3、复古 35 | const float colormatrix_huajiu[] = { 36 | 0.2f,0.5f, 0.1f, 0, 40.8f, 37 | 0.2f, 0.5f, 0.1f, 0, 40.8f, 38 | 0.2f,0.5f, 0.1f, 0, 40.8f, 39 | 0, 0, 0, 1, 0 }; 40 | 41 | // 4、哥特 42 | const float colormatrix_gete[] = { 43 | 1.9f,-0.3f, -0.2f, 0,-87.0f, 44 | -0.2f, 1.7f, -0.1f, 0, -87.0f, 45 | -0.1f,-0.6f, 2.0f, 0, -87.0f, 46 | 0, 0, 0, 1.0f, 0 }; 47 | 48 | // 5、锐化 49 | const float colormatrix_ruise[] = { 50 | 4.8f,-1.0f, -0.1f, 0,-388.4f, 51 | -0.5f,4.4f, -0.1f, 0,-388.4f, 52 | -0.5f,-1.0f, 5.2f, 0,-388.4f, 53 | 0, 0, 0, 1.0f, 0 }; 54 | 55 | 56 | // 6、淡雅 57 | const float colormatrix_danya[] = { 58 | 0.6f,0.3f, 0.1f, 0,73.3f, 59 | 0.2f,0.7f, 0.1f, 0,73.3f, 60 | 0.2f,0.3f, 0.4f, 0,73.3f, 61 | 0, 0, 0, 1.0f, 0 }; 62 | 63 | // 7、酒红 64 | const float colormatrix_jiuhong[] = { 65 | 1.2f,0.0f, 0.0f, 0.0f,0.0f, 66 | 0.0f,0.9f, 0.0f, 0.0f,0.0f, 67 | 0.0f,0.0f, 0.8f, 0.0f,0.0f, 68 | 0, 0, 0, 1.0f, 0 }; 69 | 70 | // 8、清宁 71 | const float colormatrix_qingning[] = { 72 | 0.9f, 0, 0, 0, 0, 73 | 0, 1.1f,0, 0, 0, 74 | 0, 0, 0.9f, 0, 0, 75 | 0, 0, 0, 1.0f, 0 }; 76 | 77 | // 9、浪漫 78 | const float colormatrix_langman[] = { 79 | 0.9f, 0, 0, 0, 63.0f, 80 | 0, 0.9f,0, 0, 63.0f, 81 | 0, 0, 0.9f, 0, 63.0f, 82 | 0, 0, 0, 1.0f, 0 }; 83 | 84 | // 10、光晕 85 | const float colormatrix_guangyun[] = { 86 | 0.9f, 0, 0, 0, 64.9f, 87 | 0, 0.9f,0, 0, 64.9f, 88 | 0, 0, 0.9f, 0, 64.9f, 89 | 0, 0, 0, 1.0f, 0 }; 90 | 91 | // 11、蓝调 92 | const float colormatrix_landiao[] = { 93 | 2.1f, -1.4f, 0.6f, 0.0f, -31.0f, 94 | -0.3f, 2.0f, -0.3f, 0.0f, -31.0f, 95 | -1.1f, -0.2f, 2.6f, 0.0f, -31.0f, 96 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 97 | }; 98 | 99 | // 12、梦幻 100 | const float colormatrix_menghuan[] = { 101 | 0.8f, 0.3f, 0.1f, 0.0f, 46.5f, 102 | 0.1f, 0.9f, 0.0f, 0.0f, 46.5f, 103 | 0.1f, 0.3f, 0.7f, 0.0f, 46.5f, 104 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 105 | }; 106 | 107 | // 13、夜色 108 | const float colormatrix_yese[] = { 109 | 1.0f, 0.0f, 0.0f, 0.0f, -66.6f, 110 | 0.0f, 1.1f, 0.0f, 0.0f, -66.6f, 111 | 0.0f, 0.0f, 1.0f, 0.0f, -66.6f, 112 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 113 | }; 114 | 115 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Alpha.h: -------------------------------------------------------------------------------- 1 | // UIImage+Alpha.h 2 | // Created by Trevor Harmon on 9/20/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | // Helper methods for adding an alpha layer to an image 7 | #import 8 | @interface UIImage (Alpha) 9 | - (BOOL)hasAlpha; 10 | - (UIImage *)imageWithAlpha; 11 | - (UIImage *)transparentBorderImage:(NSUInteger)borderSize; 12 | - (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size; 13 | @end 14 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Alpha.m: -------------------------------------------------------------------------------- 1 | // UIImage+Alpha.m 2 | // Created by Trevor Harmon on 9/20/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | #import "UIImage+Alpha.h" 7 | 8 | 9 | @implementation UIImage (Alpha) 10 | 11 | // Returns true if the image has an alpha layer 12 | - (BOOL)hasAlpha { 13 | CGImageAlphaInfo alpha = CGImageGetAlphaInfo(self.CGImage); 14 | return (alpha == kCGImageAlphaFirst || 15 | alpha == kCGImageAlphaLast || 16 | alpha == kCGImageAlphaPremultipliedFirst || 17 | alpha == kCGImageAlphaPremultipliedLast); 18 | } 19 | 20 | // Returns a copy of the given image, adding an alpha channel if it doesn't already have one 21 | - (UIImage *)imageWithAlpha { 22 | if ([self hasAlpha]) { 23 | return self; 24 | } 25 | 26 | CGImageRef imageRef = self.CGImage; 27 | size_t width = CGImageGetWidth(imageRef); 28 | size_t height = CGImageGetHeight(imageRef); 29 | 30 | // The bitsPerComponent and bitmapInfo values are hard-coded to prevent an "unsupported parameter combination" error 31 | CGContextRef offscreenContext = CGBitmapContextCreate(NULL, 32 | width, 33 | height, 34 | 8, 35 | 0, 36 | CGImageGetColorSpace(imageRef), 37 | kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); 38 | 39 | // Draw the image into the context and retrieve the new image, which will now have an alpha layer 40 | CGContextDrawImage(offscreenContext, CGRectMake(0, 0, width, height), imageRef); 41 | CGImageRef imageRefWithAlpha = CGBitmapContextCreateImage(offscreenContext); 42 | UIImage *imageWithAlpha = [UIImage imageWithCGImage:imageRefWithAlpha]; 43 | 44 | // Clean up 45 | CGContextRelease(offscreenContext); 46 | CGImageRelease(imageRefWithAlpha); 47 | 48 | return imageWithAlpha; 49 | } 50 | 51 | // Returns a copy of the image with a transparent border of the given size added around its edges. 52 | // If the image has no alpha layer, one will be added to it. 53 | - (UIImage *)transparentBorderImage:(NSUInteger)borderSize { 54 | // If the image does not have an alpha layer, add one 55 | UIImage *image = [self imageWithAlpha]; 56 | 57 | CGRect newRect = CGRectMake(0, 0, image.size.width + borderSize * 2, image.size.height + borderSize * 2); 58 | 59 | // Build a context that's the same dimensions as the new size 60 | CGContextRef bitmap = CGBitmapContextCreate(NULL, 61 | newRect.size.width, 62 | newRect.size.height, 63 | CGImageGetBitsPerComponent(self.CGImage), 64 | 0, 65 | CGImageGetColorSpace(self.CGImage), 66 | CGImageGetBitmapInfo(self.CGImage)); 67 | 68 | // Draw the image in the center of the context, leaving a gap around the edges 69 | CGRect imageLocation = CGRectMake(borderSize, borderSize, image.size.width, image.size.height); 70 | CGContextDrawImage(bitmap, imageLocation, self.CGImage); 71 | CGImageRef borderImageRef = CGBitmapContextCreateImage(bitmap); 72 | 73 | // Create a mask to make the border transparent, and combine it with the image 74 | CGImageRef maskImageRef = [self newBorderMask:borderSize size:newRect.size]; 75 | CGImageRef transparentBorderImageRef = CGImageCreateWithMask(borderImageRef, maskImageRef); 76 | UIImage *transparentBorderImage = [UIImage imageWithCGImage:transparentBorderImageRef]; 77 | 78 | // Clean up 79 | CGContextRelease(bitmap); 80 | CGImageRelease(borderImageRef); 81 | CGImageRelease(maskImageRef); 82 | CGImageRelease(transparentBorderImageRef); 83 | 84 | return transparentBorderImage; 85 | } 86 | 87 | #pragma mark - 88 | #pragma mark Private helper methods 89 | 90 | // Creates a mask that makes the outer edges transparent and everything else opaque 91 | // The size must include the entire mask (opaque part + transparent border) 92 | // The caller is responsible for releasing the returned reference by calling CGImageRelease 93 | - (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size { 94 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); 95 | 96 | // Build a context that's the same dimensions as the new size 97 | CGContextRef maskContext = CGBitmapContextCreate(NULL, 98 | size.width, 99 | size.height, 100 | 8, // 8-bit grayscale 101 | 0, 102 | colorSpace, 103 | kCGBitmapByteOrderDefault | kCGImageAlphaNone); 104 | 105 | // Start with a mask that's entirely transparent 106 | CGContextSetFillColorWithColor(maskContext, [UIColor blackColor].CGColor); 107 | CGContextFillRect(maskContext, CGRectMake(0, 0, size.width, size.height)); 108 | 109 | // Make the inner part (within the border) opaque 110 | CGContextSetFillColorWithColor(maskContext, [UIColor whiteColor].CGColor); 111 | CGContextFillRect(maskContext, CGRectMake(borderSize, borderSize, size.width - borderSize * 2, size.height - borderSize * 2)); 112 | 113 | // Get an image of the context 114 | CGImageRef maskImageRef = CGBitmapContextCreateImage(maskContext); 115 | 116 | // Clean up 117 | CGContextRelease(maskContext); 118 | CGColorSpaceRelease(colorSpace); 119 | 120 | return maskImageRef; 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Cut.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Cut.h 3 | // MeiJiaLove 4 | // 5 | // Created by Wu.weibin on 13-5-17. 6 | // Copyright (c) 2013年 Wu.weibin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface UIImage (Cut) 12 | 13 | - (UIImage *)clipImageWithScaleWithsize:(CGSize)asize; 14 | - (UIImage *)clipImageWithScaleWithsize:(CGSize)asize roundedCornerImage:(NSInteger)roundedCornerImage borderSize:(NSInteger)borderSize; 15 | @end 16 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Cut.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Cut.m 3 | // MeiJiaLove 4 | // 5 | // Created by Wu.weibin on 13-5-17. 6 | // Copyright (c) 2013年 Wu.weibin. All rights reserved. 7 | // 8 | 9 | #import "UIImage+Cut.h" 10 | #import "UIImage+RoundedCorner.h" 11 | @implementation UIImage (Cut) 12 | 13 | 14 | - (UIImage *)clipImageWithScaleWithsize:(CGSize)asize 15 | { 16 | UIImage *newimage; 17 | UIImage *image = self; 18 | if (nil == image) { 19 | newimage = nil; 20 | } 21 | else{ 22 | CGSize oldsize = image.size; 23 | CGRect rect; 24 | if (asize.width/asize.height > oldsize.width/oldsize.height) { 25 | rect.size.width = asize.width; 26 | rect.size.height = asize.width*oldsize.height/oldsize.width; 27 | rect.origin.x = 0; 28 | rect.origin.y = (asize.height - rect.size.height)/2; 29 | } 30 | else{ 31 | rect.size.width = asize.height*oldsize.width/oldsize.height; 32 | rect.size.height = asize.height; 33 | rect.origin.x = (asize.width - rect.size.width)/2; 34 | rect.origin.y = 0; 35 | } 36 | UIGraphicsBeginImageContext(asize); 37 | CGContextRef context = UIGraphicsGetCurrentContext(); 38 | CGContextClipToRect(context, CGRectMake(0, 0, asize.width, asize.height)); 39 | CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]); 40 | UIRectFill(CGRectMake(0, 0, asize.width, asize.height));//clear background 41 | [image drawInRect:rect]; 42 | newimage = UIGraphicsGetImageFromCurrentImageContext(); 43 | UIGraphicsEndImageContext(); 44 | } 45 | return newimage; 46 | } 47 | - (UIImage *)clipImageWithScaleWithsize:(CGSize)asize roundedCornerImage:(NSInteger)roundedCornerImage borderSize:(NSInteger)borderSize 48 | { 49 | UIImage *image = [self clipImageWithScaleWithsize:asize]; 50 | return [image roundedCornerImage:roundedCornerImage borderSize:borderSize]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Resize.h: -------------------------------------------------------------------------------- 1 | // UIImage+Resize.h 2 | // Created by Trevor Harmon on 8/5/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | // Extends the UIImage class to support resizing/cropping 7 | #import 8 | @interface UIImage (Resize) 9 | - (UIImage *)croppedImage:(CGRect)bounds; 10 | - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize 11 | transparentBorder:(NSUInteger)borderSize 12 | cornerRadius:(NSUInteger)cornerRadius 13 | interpolationQuality:(CGInterpolationQuality)quality; 14 | - (UIImage *)resizedImage:(CGSize)newSize 15 | interpolationQuality:(CGInterpolationQuality)quality; 16 | - (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode 17 | bounds:(CGSize)bounds 18 | interpolationQuality:(CGInterpolationQuality)quality; 19 | 20 | - (UIImage *)resizedImage:(CGSize)newSize 21 | transform:(CGAffineTransform)transform 22 | drawTransposed:(BOOL)transpose 23 | interpolationQuality:(CGInterpolationQuality)quality; 24 | - (CGAffineTransform)transformForOrientation:(CGSize)newSize; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+Resize.m: -------------------------------------------------------------------------------- 1 | // UIImage+Resize.m 2 | // Created by Trevor Harmon on 8/5/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | #import "UIImage+Resize.h" 7 | #import "UIImage+RoundedCorner.h" 8 | #import "UIImage+Alpha.h" 9 | 10 | 11 | @implementation UIImage (Resize) 12 | 13 | // Returns a copy of this image that is cropped to the given bounds. 14 | // The bounds will be adjusted using CGRectIntegral. 15 | // This method ignores the image's imageOrientation setting. 16 | - (UIImage *)croppedImage:(CGRect)bounds { 17 | CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds); 18 | UIImage *croppedImage = [UIImage imageWithCGImage:imageRef]; 19 | CGImageRelease(imageRef); 20 | return croppedImage; 21 | } 22 | 23 | // Returns a copy of this image that is squared to the thumbnail size. 24 | // If transparentBorder is non-zero, a transparent border of the given size will be added around the edges of the thumbnail. (Adding a transparent border of at least one pixel in size has the side-effect of antialiasing the edges of the image when rotating it using Core Animation.) 25 | - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize 26 | transparentBorder:(NSUInteger)borderSize 27 | cornerRadius:(NSUInteger)cornerRadius 28 | interpolationQuality:(CGInterpolationQuality)quality { 29 | UIImage *resizedImage = [self resizedImageWithContentMode:UIViewContentModeScaleAspectFill 30 | bounds:CGSizeMake(thumbnailSize, thumbnailSize) 31 | interpolationQuality:quality]; 32 | 33 | // Crop out any part of the image that's larger than the thumbnail size 34 | // The cropped rect must be centered on the resized image 35 | // Round the origin points so that the size isn't altered when CGRectIntegral is later invoked 36 | CGRect cropRect = CGRectMake(round((resizedImage.size.width - thumbnailSize) / 2), 37 | round((resizedImage.size.height - thumbnailSize) / 2), 38 | thumbnailSize, 39 | thumbnailSize); 40 | UIImage *croppedImage = [resizedImage croppedImage:cropRect]; 41 | 42 | UIImage *transparentBorderImage = borderSize ? [croppedImage transparentBorderImage:borderSize] : croppedImage; 43 | 44 | return [transparentBorderImage roundedCornerImage:cornerRadius borderSize:borderSize]; 45 | } 46 | 47 | // Returns a rescaled copy of the image, taking into account its orientation 48 | // The image will be scaled disproportionately if necessary to fit the bounds specified by the parameter 49 | - (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality { 50 | BOOL drawTransposed; 51 | 52 | switch (self.imageOrientation) { 53 | case UIImageOrientationLeft: 54 | case UIImageOrientationLeftMirrored: 55 | case UIImageOrientationRight: 56 | case UIImageOrientationRightMirrored: 57 | drawTransposed = YES; 58 | break; 59 | 60 | default: 61 | drawTransposed = NO; 62 | } 63 | 64 | return [self resizedImage:newSize 65 | transform:[self transformForOrientation:newSize] 66 | drawTransposed:drawTransposed 67 | interpolationQuality:quality]; 68 | } 69 | 70 | // Resizes the image according to the given content mode, taking into account the image's orientation 71 | - (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode 72 | bounds:(CGSize)bounds 73 | interpolationQuality:(CGInterpolationQuality)quality { 74 | CGFloat horizontalRatio = bounds.width / self.size.width; 75 | CGFloat verticalRatio = bounds.height / self.size.height; 76 | CGFloat ratio; 77 | 78 | switch (contentMode) { 79 | case UIViewContentModeScaleAspectFill: 80 | ratio = MAX(horizontalRatio, verticalRatio); 81 | break; 82 | 83 | case UIViewContentModeScaleAspectFit: 84 | ratio = MIN(horizontalRatio, verticalRatio); 85 | break; 86 | 87 | default: 88 | [NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %ld", (long)contentMode]; 89 | } 90 | 91 | CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio); 92 | 93 | return [self resizedImage:newSize interpolationQuality:quality]; 94 | } 95 | 96 | #pragma mark - 97 | #pragma mark Private helper methods 98 | 99 | // Returns a copy of the image that has been transformed using the given affine transform and scaled to the new size 100 | // The new image's orientation will be UIImageOrientationUp, regardless of the current image's orientation 101 | // If the new size is not integral, it will be rounded up 102 | - (UIImage *)resizedImage:(CGSize)newSize 103 | transform:(CGAffineTransform)transform 104 | drawTransposed:(BOOL)transpose 105 | interpolationQuality:(CGInterpolationQuality)quality { 106 | 107 | CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height)); 108 | CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width); 109 | CGImageRef imageRef = self.CGImage; 110 | 111 | // Build a context that's the same dimensions as the new size 112 | CGContextRef bitmap = CGBitmapContextCreate(NULL, 113 | newRect.size.width, 114 | newRect.size.height, 115 | CGImageGetBitsPerComponent(imageRef), 116 | 0, 117 | CGImageGetColorSpace(imageRef), 118 | CGImageGetBitmapInfo(imageRef)); 119 | 120 | // Rotate and/or flip the image if required by its orientation 121 | CGContextConcatCTM(bitmap, transform); 122 | 123 | // Set the quality level to use when rescaling 124 | CGContextSetInterpolationQuality(bitmap, quality); 125 | 126 | // Draw into the context; this scales the image 127 | CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef); 128 | 129 | // Get the resized image from the context and a UIImage 130 | CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap); 131 | UIImage *newImage = [UIImage imageWithCGImage:newImageRef]; 132 | 133 | // Clean up 134 | CGContextRelease(bitmap); 135 | CGImageRelease(newImageRef); 136 | 137 | return newImage; 138 | } 139 | 140 | // Returns an affine transform that takes into account the image orientation when drawing a scaled image 141 | - (CGAffineTransform)transformForOrientation:(CGSize)newSize { 142 | CGAffineTransform transform = CGAffineTransformIdentity; 143 | 144 | switch (self.imageOrientation) { 145 | case UIImageOrientationDown: // EXIF = 3 146 | case UIImageOrientationDownMirrored: // EXIF = 4 147 | transform = CGAffineTransformTranslate(transform, newSize.width, newSize.height); 148 | transform = CGAffineTransformRotate(transform, M_PI); 149 | break; 150 | 151 | case UIImageOrientationLeft: // EXIF = 6 152 | case UIImageOrientationLeftMirrored: // EXIF = 5 153 | transform = CGAffineTransformTranslate(transform, newSize.width, 0); 154 | transform = CGAffineTransformRotate(transform, M_PI_2); 155 | break; 156 | 157 | case UIImageOrientationRight: // EXIF = 8 158 | case UIImageOrientationRightMirrored: // EXIF = 7 159 | transform = CGAffineTransformTranslate(transform, 0, newSize.height); 160 | transform = CGAffineTransformRotate(transform, -M_PI_2); 161 | break; 162 | default: 163 | break; 164 | } 165 | 166 | switch (self.imageOrientation) { 167 | case UIImageOrientationUpMirrored: // EXIF = 2 168 | case UIImageOrientationDownMirrored: // EXIF = 4 169 | transform = CGAffineTransformTranslate(transform, newSize.width, 0); 170 | transform = CGAffineTransformScale(transform, -1, 1); 171 | break; 172 | 173 | case UIImageOrientationLeftMirrored: // EXIF = 5 174 | case UIImageOrientationRightMirrored: // EXIF = 7 175 | transform = CGAffineTransformTranslate(transform, newSize.height, 0); 176 | transform = CGAffineTransformScale(transform, -1, 1); 177 | break; 178 | default: 179 | break; 180 | } 181 | 182 | return transform; 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+RoundedCorner.h: -------------------------------------------------------------------------------- 1 | // UIImage+RoundedCorner.h 2 | // Created by Trevor Harmon on 9/20/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | // Extends the UIImage class to support making rounded corners 7 | #import 8 | @interface UIImage (RoundedCorner) 9 | - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize; 10 | - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+RoundedCorner.m: -------------------------------------------------------------------------------- 1 | // UIImage+RoundedCorner.m 2 | // Created by Trevor Harmon on 9/20/09. 3 | // Free for personal or commercial use, with or without modification. 4 | // No warranty is expressed or implied. 5 | 6 | #import "UIImage+RoundedCorner.h" 7 | #import "UIImage+Alpha.h" 8 | 9 | 10 | @implementation UIImage (RoundedCorner) 11 | 12 | // Creates a copy of this image with rounded corners 13 | // If borderSize is non-zero, a transparent border of the given size will also be added 14 | // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ 15 | - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize { 16 | // If the image does not have an alpha layer, add one 17 | UIImage *image = [self imageWithAlpha]; 18 | 19 | // Build a context that's the same dimensions as the new size 20 | CGContextRef context = CGBitmapContextCreate(NULL, 21 | image.size.width, 22 | image.size.height, 23 | CGImageGetBitsPerComponent(image.CGImage), 24 | 0, 25 | CGImageGetColorSpace(image.CGImage), 26 | CGImageGetBitmapInfo(image.CGImage)); 27 | 28 | // Create a clipping path with rounded corners 29 | CGContextBeginPath(context); 30 | [self addRoundedRectToPath:CGRectMake(borderSize, borderSize, image.size.width - borderSize * 2, image.size.height - borderSize * 2) 31 | context:context 32 | ovalWidth:cornerSize 33 | ovalHeight:cornerSize]; 34 | CGContextClosePath(context); 35 | CGContextClip(context); 36 | 37 | // Draw the image to the context; the clipping path will make anything outside the rounded rect transparent 38 | CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage); 39 | 40 | // Create a CGImage from the context 41 | CGImageRef clippedImage = CGBitmapContextCreateImage(context); 42 | CGContextRelease(context); 43 | 44 | // Create a UIImage from the CGImage 45 | UIImage *roundedImage = [UIImage imageWithCGImage:clippedImage]; 46 | CGImageRelease(clippedImage); 47 | 48 | return roundedImage; 49 | } 50 | 51 | #pragma mark - 52 | #pragma mark Private helper methods 53 | 54 | // Adds a rectangular path to the given context and rounds its corners by the given extents 55 | // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ 56 | - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight { 57 | if (ovalWidth == 0 || ovalHeight == 0) { 58 | CGContextAddRect(context, rect); 59 | return; 60 | } 61 | CGContextSaveGState(context); 62 | CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); 63 | CGContextScaleCTM(context, ovalWidth, ovalHeight); 64 | CGFloat fw = CGRectGetWidth(rect) / ovalWidth; 65 | CGFloat fh = CGRectGetHeight(rect) / ovalHeight; 66 | CGContextMoveToPoint(context, fw, fh/2); 67 | CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); 68 | CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); 69 | CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); 70 | CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); 71 | CGContextClosePath(context); 72 | CGContextRestoreGState(context); 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+SplitImageIntoTwoParts.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+SplitImageIntoTwoParts.h 3 | // TapRepublic 4 | // 5 | // Created by Terry Lin on 12-5-11. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (SplitImageIntoTwoParts) 12 | + (NSArray*)splitImageIntoTwoParts:(UIImage*)image; 13 | @end 14 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+SplitImageIntoTwoParts.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+SplitImageIntoTwoParts.m 3 | // TapRepublic 4 | // 5 | // Created by Terry Lin on 12-5-11. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | #define SAWTOOTH_COUNT 10 9 | #define SAWTOOTH_WIDTH_FACTOR 20 10 | #import "UIImage+SplitImageIntoTwoParts.h" 11 | 12 | @implementation UIImage (SplitImageIntoTwoParts) 13 | 14 | +(NSArray *)splitImageIntoTwoParts:(UIImage *)image 15 | { 16 | CGFloat scale = [[UIScreen mainScreen] scale]; 17 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; 18 | CGFloat width,height,widthgap,heightgap; 19 | int piceCount = SAWTOOTH_COUNT; 20 | width = image.size.width; 21 | height = image.size.height; 22 | widthgap = width/SAWTOOTH_WIDTH_FACTOR; 23 | heightgap = height/piceCount; 24 | // CGRect rect = CGRectMake(0, 0, width, height); 25 | CGContextRef context; 26 | CGImageRef imageMasked; 27 | UIImage *leftImage,*rightImage; 28 | 29 | //part one 30 | UIGraphicsBeginImageContext(CGSizeMake(width*scale, height*scale)); 31 | context = UIGraphicsGetCurrentContext(); 32 | CGContextScaleCTM(context, scale, scale); 33 | CGContextMoveToPoint(context, 0, 0); 34 | int a=-1; 35 | for (int i=0; i 10 | 11 | @interface UIImage (ZY) 12 | + (UIImage *)resizedImageWithName:(NSString *)name; 13 | + (UIImage *)resizedImageWithName:(NSString *)name left:(CGFloat)left top:(CGFloat)top; 14 | + (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur; 15 | 16 | /// 图片转换时自动旋转, 调正 17 | + (UIImage *)cropImage:(UIImage*)image toRect:(CGRect)rect; 18 | //图片旋转纠正 19 | + (UIImage *)fixOrientation:(UIImage* )aImage; 20 | 21 | /** 22 | 生成截图 23 | 24 | @param view 界面 25 | @return 截图 26 | */ 27 | + (UIImage *)makeImageWithView:(UIView *)view; 28 | @end 29 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/UIImage-Extensions/UIImage+ZY.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ZY.m 3 | // ZYNaNian 4 | // 5 | // Created by YiNian on 16/3/18. 6 | // Copyright © 2016年 ZYNaNian. All rights reserved. 7 | // 8 | 9 | #import "UIImage+ZY.h" 10 | #import 11 | @implementation UIImage (ZY) 12 | + (UIImage *)resizedImageWithName:(NSString *)name 13 | { 14 | return [self resizedImageWithName:name left:0.5 top:0.5]; 15 | } 16 | 17 | + (UIImage *)resizedImageWithName:(NSString *)name left:(CGFloat)left top:(CGFloat)top 18 | { 19 | UIImage *image = [self imageNamed:name]; 20 | return [image stretchableImageWithLeftCapWidth:image.size.width * left topCapHeight:image.size.height * top]; 21 | } 22 | + (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur 23 | { 24 | if (blur < 0.f || blur > 1.f) { 25 | blur = 0.5f; 26 | } 27 | int boxSize = (int)(blur * 100); 28 | boxSize = boxSize - (boxSize % 2) + 1; 29 | 30 | CGImageRef img = image.CGImage; 31 | 32 | vImage_Buffer inBuffer, outBuffer; 33 | vImage_Error error; 34 | 35 | void *pixelBuffer; 36 | 37 | CGDataProviderRef inProvider = CGImageGetDataProvider(img); 38 | CFDataRef inBitmapData = CGDataProviderCopyData(inProvider); 39 | 40 | inBuffer.width = CGImageGetWidth(img); 41 | inBuffer.height = CGImageGetHeight(img); 42 | inBuffer.rowBytes = CGImageGetBytesPerRow(img); 43 | 44 | inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData); 45 | 46 | pixelBuffer = malloc(CGImageGetBytesPerRow(img) * 47 | CGImageGetHeight(img)); 48 | 49 | if(pixelBuffer == NULL)NSLog(@"NO pixelBuffer"); 50 | 51 | 52 | outBuffer.data = pixelBuffer; 53 | outBuffer.width = CGImageGetWidth(img); 54 | outBuffer.height = CGImageGetHeight(img); 55 | outBuffer.rowBytes = CGImageGetBytesPerRow(img); 56 | 57 | error = vImageBoxConvolve_ARGB8888(&inBuffer, 58 | &outBuffer, 59 | NULL, 60 | 0, 61 | 0, 62 | boxSize, 63 | boxSize, 64 | NULL, 65 | kvImageEdgeExtend); 66 | 67 | 68 | if (error) { 69 | NSLog(@"error from convolution %ld", error); 70 | } 71 | 72 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 73 | CGContextRef ctx = CGBitmapContextCreate( 74 | outBuffer.data, 75 | outBuffer.width, 76 | outBuffer.height, 77 | 8, 78 | outBuffer.rowBytes, 79 | colorSpace, 80 | kCGImageAlphaNoneSkipLast); 81 | CGImageRef imageRef = CGBitmapContextCreateImage (ctx); 82 | UIImage *returnImage = [UIImage imageWithCGImage:imageRef]; 83 | 84 | //clean up 85 | CGContextRelease(ctx); 86 | CGColorSpaceRelease(colorSpace); 87 | 88 | free(pixelBuffer); 89 | CFRelease(inBitmapData); 90 | 91 | CGColorSpaceRelease(colorSpace); 92 | CGImageRelease(imageRef); 93 | 94 | return returnImage; 95 | } 96 | 97 | 98 | + (UIImage *)cropImage:(UIImage*)image toRect:(CGRect)rect { 99 | CGFloat (^rad)(CGFloat) = ^CGFloat(CGFloat deg) { 100 | return deg / 180.0f * (CGFloat) M_PI; 101 | }; 102 | 103 | // determine the orientation of the image and apply a transformation to the crop rectangle to shift it to the correct position 104 | CGAffineTransform rectTransform; 105 | switch (image.imageOrientation) { 106 | case UIImageOrientationLeft: 107 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(rad(90)), 0, -image.size.height); 108 | break; 109 | case UIImageOrientationRight: 110 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(rad(-90)), -image.size.width, 0); 111 | break; 112 | case UIImageOrientationDown: 113 | rectTransform = CGAffineTransformTranslate(CGAffineTransformMakeRotation(rad(-180)), -image.size.width, -image.size.height); 114 | break; 115 | default: 116 | rectTransform = CGAffineTransformIdentity; 117 | }; 118 | 119 | // adjust the transformation scale based on the image scale 120 | rectTransform = CGAffineTransformScale(rectTransform, image.scale, image.scale); 121 | 122 | // apply the transformation to the rect to create a new, shifted rect 123 | CGRect transformedCropSquare = CGRectApplyAffineTransform(rect, rectTransform); 124 | // use the rect to crop the image 125 | CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, transformedCropSquare); 126 | // create a new UIImage and set the scale and orientation appropriately 127 | UIImage *result = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation]; 128 | // memory cleanup 129 | CGImageRelease(imageRef); 130 | 131 | return result; 132 | } 133 | 134 | + (UIImage *)fixOrientation:(UIImage* )aImage { 135 | 136 | if (aImage.imageOrientation == UIImageOrientationUp) return aImage; 137 | 138 | CGAffineTransform transform = CGAffineTransformIdentity; 139 | 140 | switch (aImage.imageOrientation) { case UIImageOrientationDown: case UIImageOrientationDownMirrored: transform = CGAffineTransformTranslate(transform, aImage.size.width, aImage.size.height); transform = CGAffineTransformRotate(transform, M_PI); break; 141 | 142 | case UIImageOrientationLeft: 143 | case UIImageOrientationLeftMirrored: 144 | transform = CGAffineTransformTranslate(transform, aImage.size.width, 0); 145 | transform = CGAffineTransformRotate(transform, M_PI_2); 146 | break; 147 | 148 | case UIImageOrientationRight: 149 | case UIImageOrientationRightMirrored: 150 | transform = CGAffineTransformTranslate(transform, 0, aImage.size.height); 151 | transform = CGAffineTransformRotate(transform, -M_PI_2); 152 | break; 153 | default: 154 | break; 155 | 156 | } 157 | 158 | switch (aImage.imageOrientation) { case UIImageOrientationUpMirrored: case UIImageOrientationDownMirrored: transform = CGAffineTransformTranslate(transform, aImage.size.width, 0); transform = CGAffineTransformScale(transform, -1, 1); break; 159 | 160 | case UIImageOrientationLeftMirrored: 161 | case UIImageOrientationRightMirrored: 162 | transform = CGAffineTransformTranslate(transform, aImage.size.height, 0); 163 | transform = CGAffineTransformScale(transform, -1, 1); 164 | break; 165 | default: 166 | break; 167 | 168 | } 169 | 170 | CGContextRef ctx = CGBitmapContextCreate(NULL, aImage.size.width, aImage.size.height, CGImageGetBitsPerComponent(aImage.CGImage), 0, CGImageGetColorSpace(aImage.CGImage), CGImageGetBitmapInfo(aImage.CGImage)); CGContextConcatCTM(ctx, transform); switch (aImage.imageOrientation) { case UIImageOrientationLeft: case UIImageOrientationLeftMirrored: case UIImageOrientationRight: case UIImageOrientationRightMirrored: 171 | 172 | CGContextDrawImage(ctx, CGRectMake(0,0,aImage.size.height,aImage.size.width), aImage.CGImage); 173 | break; 174 | 175 | default: 176 | CGContextDrawImage(ctx, CGRectMake(0,0,aImage.size.width,aImage.size.height), aImage.CGImage); 177 | break; 178 | 179 | } 180 | 181 | CGImageRef cgimg = CGBitmapContextCreateImage(ctx); UIImage *img = [UIImage imageWithCGImage:cgimg]; CGContextRelease(ctx); CGImageRelease(cgimg); 182 | return img; 183 | 184 | } 185 | #pragma mark 生成image 186 | + (UIImage *)makeImageWithView:(UIView *)view 187 | 188 | { 189 | CGSize s = view.bounds.size; 190 | 191 | // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了,关键就是第三个参数。 192 | 193 | UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale); 194 | 195 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 196 | 197 | UIImage*image = UIGraphicsGetImageFromCurrentImageContext(); 198 | 199 | UIGraphicsEndImageContext(); 200 | 201 | return image; 202 | } 203 | @end 204 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/ZHMacroDefinition.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZHMacroDefinition.h 3 | // 不忘初心,方得始终。 4 | // 5 | // Created by HenryVarro on 15/4/26. 6 | // Copyright © 2015年 丁子恒. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #ifndef ZHMacroDefinition_h 12 | #define ZHMacroDefinition_h 13 | 14 | ///------ 15 | /// NSLog 16 | ///------ 17 | 18 | #ifdef DEBUG 19 | #define ZHLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 20 | #else 21 | #define ZHLog(...) 22 | #endif 23 | 24 | #ifdef DEBUG // 处于开发阶段 25 | #define NSLog(...) NSLog(__VA_ARGS__) 26 | #else // 处于发布阶段 27 | #define NSLog(...) 28 | #endif 29 | 30 | ///------ 31 | /// Block 32 | ///------ 33 | 34 | typedef void (^voidBlock)(); 35 | typedef BOOL (^boolBlock)(); 36 | typedef int (^intBlock) (); 37 | typedef id (^idBlock) (); 38 | 39 | typedef void (^voidBlock_int)(int); 40 | typedef BOOL (^boolBlock_int)(int); 41 | typedef int (^intBlock_int) (int); 42 | typedef id (^idBlock_int) (int); 43 | 44 | typedef void (^voidBlock_string)(NSString *); 45 | typedef BOOL (^boolBlock_string)(NSString *); 46 | typedef int (^intBlock_string) (NSString *); 47 | typedef id (^idBlock_string) (NSString *); 48 | 49 | typedef void (^voidBlock_id)(id); 50 | typedef BOOL (^boolBlock_id)(id); 51 | typedef int (^intBlock_id) (id); 52 | typedef id (^idBlock_id) (id); 53 | 54 | ///------ 55 | /// Color 56 | ///------ 57 | #define kRGB(r, g, b) [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0] 58 | #define kRGBAlpha(r, g, b, a) [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)] 59 | #define kHexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 60 | #define kHexRGBAlpha(rgbValue, a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)] 61 | #define kRandomColor kRGB(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256)) 62 | 63 | ///--------- 64 | /// App Info 65 | ///--------- 66 | #define APP_NAME ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]) 67 | #define APP_VERSION ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]) 68 | #define APP_BUILD ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]) 69 | 70 | ///---------------------- 71 | /// Persistence Directory 72 | ///---------------------- 73 | #define kDOCUMENT_DIRECTORY NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject 74 | #define kLIBRARY_DIRECTORY NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0] 75 | #define kCACHES_DIRECTORY [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] 76 | 77 | ///---------------------- 78 | /// NSNotificationCenter 79 | ///---------------------- 80 | #define ZHNotificationCenter [NSNotificationCenter defaultCenter] 81 | 82 | ///---------------------- 83 | /// Window And ScreenSize 84 | ///---------------------- 85 | #define kWindow [UIApplication sharedApplication].keyWindow 86 | #define kTopWindow [[UIApplication sharedApplication].windows lastObject] 87 | 88 | #define kScreenSize [UIScreen mainScreen].bounds.size 89 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 90 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 91 | #define kScreenBounds [UIScreen mainScreen].bounds 92 | 93 | #define kIS_IPHONE_4 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )480) < DBL_EPSILON ) 94 | #define kIS_IPHONE_5 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )568) < DBL_EPSILON ) 95 | #define kIS_IPHONE_6SIZE (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )667) < DBL_EPSILON ) 96 | #define kIS_IPHONE_6_PLUSSIZE (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )736) < DBL_EPSILON ) 97 | 98 | #define kScaleWidth(iphone6Width) [[UIScreen mainScreen] bounds].size.width / 375.f * iphone6Width 99 | #define kScaleHeight(iphone6Height) [[UIScreen mainScreen] bounds].size.height / 667.f * iphone6Height 100 | 101 | 102 | ///------------------------------------ 103 | /// RAC Keywordify 104 | ///------------------------------------ 105 | #if DEBUG 106 | #define rac_keywordify autoreleasepool {} 107 | #else 108 | #define rac_keywordify try {} @catch (...) {} 109 | #endif 110 | 111 | 112 | ///------------------------------------ 113 | /// Weak Object or Strong Object 114 | ///------------------------------------ 115 | #define weakify(object) rac_keywordify __weak __typeof__(object) object##_##weak = object 116 | 117 | #define strongify(object) rac_keywordify __strong __typeof__(object) object = object##_##weak 118 | 119 | 120 | 121 | ///------------------------------------ 122 | /// Suppress PerformSelectorLeakWarning 123 | ///------------------------------------ 124 | #define SuppressPerformSelectorLeakWarning(Stuff) \ 125 | do { \ 126 | _Pragma("clang diagnostic push") \ 127 | _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ 128 | Stuff; \ 129 | _Pragma("clang diagnostic pop") \ 130 | } while (0) 131 | 132 | 133 | 134 | 135 | ///------------------------------ 136 | /// Table Register Nib For Cell 137 | ///------------------------------ 138 | #define TableRegisterNib(table,nibName,Identifier) [table registerNib:[UINib nibWithNibName:nibName bundle:nil] forCellReuseIdentifier:Identifier]; 139 | 140 | 141 | ///---------- 142 | /// Property 143 | ///---------- 144 | #define ZHString(x) @property(nonatomic,copy)NSString *x 145 | #define ZHArray(x) @property(nonatomic,copy)NSArray *x 146 | #define ZHMutableArray(x) @property(nonatomic,strong)NSMutableArray *x 147 | #define ZHID(x) @property(nonatomic,strong)id *x 148 | #define ZHIntger(x) @property (nonatomic,assign)NSInteger x 149 | 150 | 151 | ///---------------- 152 | /// System Version 153 | ///---------------- 154 | #define kSystemVersion [[UIDevice currentDevice].systemVersion doubleValue] 155 | #define iOS8 ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0) 156 | 157 | ///---------------- 158 | /// CGSize Scale 159 | ///---------------- 160 | #define CGSizeScale(size,scale) CGSizeMake(size.width * scale, size.height * scale) 161 | 162 | ///---------------- 163 | /// User Default 164 | ///---------------- 165 | #define ZHUserDefaults [NSUserDefaults standardUserDefaults] 166 | 167 | ///---------------- 168 | /// Angel To Randian 169 | ///---------------- 170 | #define angelToRandian(x) ((x)/180.0*M_PI) 171 | 172 | 173 | #endif /* ZHMacroDefinition_h */ 174 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/ZYFilterImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZYFilterImageView.h 3 | // ZYNaNian 4 | // 5 | // Created by HenryVarro on 16/11/18. 6 | // Copyright © 2016年 ZYNaNian. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol ZYFilterImageViewDelegate 12 | @required 13 | //滤镜选择后 14 | - (void)imageFilterDidChangeWithAfterImage:(UIImage *)afterImage; 15 | 16 | @end 17 | 18 | @interface ZYFilterImageView : UIView 19 | 20 | //代理 21 | @property (nonatomic,assign)id delegate; 22 | //原始图 23 | @property (nonatomic,copy)UIImage *originalImage; 24 | //滤镜后 25 | @property (nonatomic,copy)UIImage *afterImage; 26 | 27 | /** 28 | 滤镜工具 29 | 30 | @param originalImage 原始图片 31 | @param frame 滤镜工具条 32 | @return 滤镜工具条对象 33 | */ 34 | + (instancetype)filterViewWithImage:(UIImage *)originalImage andFrame:(CGRect)frame; 35 | @end 36 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/ZYFilterImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZYFilterImageView.m 3 | // ZYNaNian 4 | // 5 | // Created by HenryVarro on 16/11/18. 6 | // Copyright © 2016年 ZYNaNian. All rights reserved. 7 | // 8 | 9 | #import "ZYFilterImageView.h" 10 | #import "ZYFilterTool.h" 11 | #import "ColorMatrix.h" 12 | #import "UIImage+Resize.h" 13 | #import "UIImage+ZY.h" 14 | #import "ZHMacroDefinition.h" 15 | #define LeftMagin 54/2.f 16 | #define TopMagin 35/2.f 17 | //内间距 18 | #define InnerMagin 32/2.f 19 | //滤镜选图宽高 20 | #define WidthAndHeight 45 21 | //圆角 22 | #define CornerRadius 12/2.f 23 | @interface ZYFilterImageView() 24 | 25 | 26 | 27 | 28 | @end 29 | 30 | 31 | @implementation ZYFilterImageView 32 | { 33 | //滤镜名称 34 | NSArray * filterNameArray ; 35 | UIScrollView *scrollView; 36 | //选中框 37 | UIView * selectView; 38 | UILabel *_lastLabel; 39 | } 40 | 41 | 42 | /** 43 | 滤镜工具 44 | 45 | @param originalImage 原始图片 46 | @param frame 滤镜工具条 47 | @return 滤镜工具条对象 48 | */ 49 | + (instancetype)filterViewWithImage:(UIImage *)originalImage andFrame:(CGRect)frame{ 50 | ZYFilterImageView *filterView = [[ZYFilterImageView alloc] initWithFrame:frame]; 51 | filterView.originalImage = [UIImage fixOrientation:originalImage]; 52 | [filterView createUI]; 53 | 54 | return filterView; 55 | } 56 | #pragma mark - 创建UI界面 57 | - (void)createUI { 58 | filterNameArray = @[@"原图",@"LOMO",@"黑白",@"复古",@"哥特",@"锐色",@"淡雅",@"酒红",@"青柠",@"浪漫",@"光晕",@"蓝调",@"梦幻",@"夜色"]; 59 | 60 | scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 61 | scrollView.backgroundColor = [UIColor clearColor]; 62 | scrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack; 63 | scrollView.showsHorizontalScrollIndicator = NO; 64 | scrollView.showsVerticalScrollIndicator = NO; 65 | scrollView.bounces = YES; 66 | 67 | [self addSubview:scrollView]; 68 | [self createFilterBtn]; 69 | 70 | } 71 | #pragma mark - 创建滤镜选择 72 | - (void)createFilterBtn{ 73 | 74 | //选择框 75 | selectView = [[UIView alloc] initWithFrame:CGRectMake(LeftMagin-1, TopMagin-1, WidthAndHeight+2, WidthAndHeight+2)]; 76 | selectView.layer.cornerRadius = CornerRadius; 77 | selectView.layer.borderColor = [UIColor blackColor].CGColor; 78 | selectView.layer.borderWidth = 1; 79 | selectView.clipsToBounds = YES; 80 | [scrollView addSubview:selectView]; 81 | 82 | 83 | UIImage *smallImg = [_originalImage thumbnailImage:WidthAndHeight*2 transparentBorder:0 cornerRadius:0 interpolationQuality:kCGInterpolationDefault]; 84 | 85 | for (int i = 0; i 10 | #import 11 | @interface ZYFilterTool : NSObject 12 | 13 | 14 | 15 | /** 16 | 获取滤镜图 17 | 18 | @param inImage 原图 19 | @param f matrix矩阵 20 | @return 滤镜完成后图片 21 | */ 22 | + (UIImage*)imageWithImage:(UIImage*)inImage withColorMatrix:(const float*) f; 23 | @end 24 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrix/ZHImageFilterTool/ZYFilterTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZYFilterTool.m 3 | // ZYNaNian 4 | // 5 | // Created by HenryVarro on 16/11/18. 6 | // Copyright © 2016年 ZYNaNian. All rights reserved. 7 | // 8 | 9 | #import "ZYFilterTool.h" 10 | #import 11 | #import 12 | //#import "UIImage+ZY.h" 13 | @implementation ZYFilterTool 14 | //static void *bitmap; 15 | static CGContextRef CreateRGBABitmapContext (CGImageRef inImage)// 返回一个使用RGBA通道的位图上下文 16 | { 17 | CGContextRef context = NULL; 18 | CGColorSpaceRef colorSpace; 19 | void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数。 20 | unsigned long bitmapByteCount; 21 | unsigned long bitmapBytesPerRow; 22 | 23 | size_t pixelsWide = CGImageGetWidth(inImage); //获取横向的像素点的个数 24 | size_t pixelsHigh = CGImageGetHeight(inImage); //纵向 25 | 26 | bitmapBytesPerRow = (pixelsWide * 4); //每一行的像素点占用的字节数,每个像素点的ARGB四个通道各占8个bit(0-255)的空间 27 | bitmapByteCount = (bitmapBytesPerRow * pixelsHigh); //计算整张图占用的字节数 28 | 29 | colorSpace = CGColorSpaceCreateDeviceRGB();//创建依赖于设备的RGB通道 30 | 31 | bitmapData = malloc(bitmapByteCount); //分配足够容纳图片字节数的内存空间 32 | 33 | context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); 34 | //创建CoreGraphic的图形上下文,该上下文描述了bitmaData指向的内存空间需要绘制的图像的一些绘制参数 35 | 36 | CGColorSpaceRelease( colorSpace ); 37 | //Core Foundation中通过含有Create、Alloc的方法名字创建的指针,需要使用CFRelease()函数释放 38 | // free(bitmapData); 39 | return context; 40 | } 41 | 42 | static unsigned char *RequestImagePixelData(UIImage *inImage) 43 | // 返回一个指针,该指针指向一个数组,数组中的每四个元素都是图像上的一个像素点的RGBA的数值(0-255),用无符号的char是因为它正好的取值范围就是0-255 44 | { 45 | CGImageRef img = [inImage CGImage]; 46 | CGSize size = [inImage size]; 47 | 48 | CGContextRef cgctx = CreateRGBABitmapContext(img); //使用上面的函数创建上下文 49 | 50 | CGRect rect = {{0,0},{size.width, size.height}}; 51 | 52 | CGContextDrawImage(cgctx, rect, img); //将目标图像绘制到指定的上下文,实际为上下文内的bitmapData。 53 | unsigned char *data = CGBitmapContextGetData (cgctx); 54 | 55 | CGContextRelease(cgctx);//释放上面的函数创建的上下文 56 | 57 | return data; 58 | } 59 | 60 | static void changeRGBA(int *red,int *green,int *blue,int *alpha, const float* f)//修改RGB的值 61 | { 62 | int redV = *red; 63 | int greenV = *green; 64 | int blueV = *blue; 65 | int alphaV = *alpha; 66 | 67 | *red = f[0] * redV + f[1] * greenV + f[2] * blueV + f[3] * alphaV + f[4]; 68 | *green = f[0+5] * redV + f[1+5] * greenV + f[2+5] * blueV + f[3+5] * alphaV + f[4+5]; 69 | *blue = f[0+5*2] * redV + f[1+5*2] * greenV + f[2+5*2] * blueV + f[3+5*2] * alphaV + f[4+5*2]; 70 | *alpha = f[0+5*3] * redV + f[1+5*3] * greenV + f[2+5*3] * blueV + f[3+5*3] * alphaV + f[4+5*3]; 71 | 72 | if (*red > 255) 73 | { 74 | *red = 255; 75 | } 76 | if(*red < 0) 77 | { 78 | *red = 0; 79 | } 80 | if (*green > 255) 81 | { 82 | *green = 255; 83 | } 84 | if (*green < 0) 85 | { 86 | *green = 0; 87 | } 88 | if (*blue > 255) 89 | { 90 | *blue = 255; 91 | } 92 | if (*blue < 0) 93 | { 94 | *blue = 0; 95 | } 96 | if (*alpha > 255) 97 | { 98 | *alpha = 255; 99 | } 100 | if (*alpha < 0) 101 | { 102 | *alpha = 0; 103 | } 104 | } 105 | 106 | //bitmapData 手动释放 107 | 108 | + (UIImage*)imageWithImage:(UIImage*)inImage withColorMatrix:(const float*) f 109 | { 110 | 111 | CGImageRef img = [inImage CGImage]; 112 | CGSize size = [inImage size]; 113 | CGContextRef context = NULL; 114 | CGColorSpaceRef colorSpace; 115 | void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数。 116 | unsigned long bitmapByteCount; 117 | unsigned long bitmapBytesPerRow; 118 | 119 | size_t pixelsWide = CGImageGetWidth(img); //获取横向的像素点的个数 120 | size_t pixelsHigh = CGImageGetHeight(img); //纵向 121 | 122 | bitmapBytesPerRow = (pixelsWide * 4); //每一行的像素点占用的字节数,每个像素点的ARGB四个通道各占8个bit(0-255)的空间 123 | bitmapByteCount = (bitmapBytesPerRow * pixelsHigh); //计算整张图占用的字节数 124 | 125 | colorSpace = CGColorSpaceCreateDeviceRGB();//创建依赖于设备的RGB通道 126 | 127 | bitmapData = malloc(bitmapByteCount); //分配足够容纳图片字节数的内存空间 128 | 129 | context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); 130 | //创建CoreGraphic的图形上下文,该上下文描述了bitmaData指向的内存空间需要绘制的图像的一些绘制参数 131 | 132 | CGColorSpaceRelease( colorSpace ); 133 | 134 | 135 | 136 | CGRect rect = {{0,0},{size.width, size.height}}; 137 | //使用上面的函数创建上下文 138 | CGContextDrawImage(context, rect, img); //将目标图像绘制到指定的上下文,实际为上下文内的bitmapData。 139 | unsigned char *data = CGBitmapContextGetData (context); 140 | 141 | CGContextRelease(context); 142 | //释放上面的函数创建的上下文 143 | unsigned char *imgPixel = data; 144 | 145 | int wOff = 0; 146 | int pixOff = 0; 147 | 148 | 149 | for(GLuint y = 0;y< pixelsHigh;y++)//双层循环按照长宽的像素个数迭代每个像素点 150 | { 151 | pixOff = wOff; 152 | 153 | for (GLuint x = 0; x 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrixTests/ImageFilterByColorMatrixTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilterByColorMatrixTests.m 3 | // ImageFilterByColorMatrixTests 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageFilterByColorMatrixTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ImageFilterByColorMatrixTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrixTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrixUITests/ImageFilterByColorMatrixUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilterByColorMatrixUITests.m 3 | // ImageFilterByColorMatrixUITests 4 | // 5 | // Created by HenryVarro on 2017/7/17. 6 | // Copyright © 2017年 丁子恒. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageFilterByColorMatrixUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ImageFilterByColorMatrixUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ImageFilterByColorMatrix/ImageFilterByColorMatrixUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 基于ColorMatrix滤镜工具 2 | --------- 3 | 4 | 5 | 6 | ![Demo截图](http://img.blog.csdn.net/20170719103812736?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUmljaGFyX0RfVHlzb24=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) 7 | 8 | Demo链接:https://github.com/MrCoderDing/ImageFilterByColorMatrix 9 | 10 | 11 | 说到滤镜一般比较熟悉的是CIFilter、GPUImage、vImage API还有一种比较简单的滤镜ColorMatrix。 12 | 之前在项目中一个小功能要加滤镜,需求是要够用,方便。在没有考虑直接用第三方滤镜的情况下,最后还是选择使用ColorMatrix来完成任务。并且这个方案安卓和iOS通用,如果花时间做一套颜色矩阵,成本将降低很多。 13 | 14 | 1、颜色矩阵 15 | --------- 16 | 17 | lomo和黑白我做了细微调整,会稍微舒服一些: 18 | 19 | ``` // 1、LOMO 20 | const float colormatrix_lomo[] = { 21 | // 1.7f, 0.1f, 0.1f, 0, -73.1f, 22 | // 0, 1.7f, 0.1f, 0, -73.1f, 23 | // 0, 0.1f, 1.6f, 0, -73.1f, 24 | // 0, 0, 0, 1.0f, 0 25 | 1.20, 0.10, 0.10, 0.00, -73.10, 26 | 0.00, 1.20, 0.10, 0.00, -73.10, 27 | 0.00, 0.10, 1.10, 0.00, -73.10, 28 | 0.00, 0.00, 0.00, 0.00, 0.00 29 | }; 30 | 31 | // 2、黑白 32 | const float colormatrix_heibai[] = { 33 | 34 | 35 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 36 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 37 | // 0.8f, 1.6f, 0.2f, 0, -163.9f, 38 | // 0, 0, 0, 1.0f, 0 39 | 0.00, 0.00, 1.00, 0.00, -1, 40 | 0.00, 0.00, 1.00, 0.00, -1, 41 | 0.00, 0.00, 1.00, 0.00, -1, 42 | 0.00, 0.00, 0.00, 1.00, 0.00 43 | }; 44 | // 3、复古 45 | const float colormatrix_huajiu[] = { 46 | 0.2f,0.5f, 0.1f, 0, 40.8f, 47 | 0.2f, 0.5f, 0.1f, 0, 40.8f, 48 | 0.2f,0.5f, 0.1f, 0, 40.8f, 49 | 0, 0, 0, 1, 0 }; 50 | 51 | // 4、哥特 52 | const float colormatrix_gete[] = { 53 | 1.9f,-0.3f, -0.2f, 0,-87.0f, 54 | -0.2f, 1.7f, -0.1f, 0, -87.0f, 55 | -0.1f,-0.6f, 2.0f, 0, -87.0f, 56 | 0, 0, 0, 1.0f, 0 }; 57 | 58 | // 5、锐化 59 | const float colormatrix_ruise[] = { 60 | 4.8f,-1.0f, -0.1f, 0,-388.4f, 61 | -0.5f,4.4f, -0.1f, 0,-388.4f, 62 | -0.5f,-1.0f, 5.2f, 0,-388.4f, 63 | 0, 0, 0, 1.0f, 0 }; 64 | 65 | 66 | // 6、淡雅 67 | const float colormatrix_danya[] = { 68 | 0.6f,0.3f, 0.1f, 0,73.3f, 69 | 0.2f,0.7f, 0.1f, 0,73.3f, 70 | 0.2f,0.3f, 0.4f, 0,73.3f, 71 | 0, 0, 0, 1.0f, 0 }; 72 | 73 | // 7、酒红 74 | const float colormatrix_jiuhong[] = { 75 | 1.2f,0.0f, 0.0f, 0.0f,0.0f, 76 | 0.0f,0.9f, 0.0f, 0.0f,0.0f, 77 | 0.0f,0.0f, 0.8f, 0.0f,0.0f, 78 | 0, 0, 0, 1.0f, 0 }; 79 | 80 | // 8、清宁 81 | const float colormatrix_qingning[] = { 82 | 0.9f, 0, 0, 0, 0, 83 | 0, 1.1f,0, 0, 0, 84 | 0, 0, 0.9f, 0, 0, 85 | 0, 0, 0, 1.0f, 0 }; 86 | 87 | // 9、浪漫 88 | const float colormatrix_langman[] = { 89 | 0.9f, 0, 0, 0, 63.0f, 90 | 0, 0.9f,0, 0, 63.0f, 91 | 0, 0, 0.9f, 0, 63.0f, 92 | 0, 0, 0, 1.0f, 0 }; 93 | 94 | // 10、光晕 95 | const float colormatrix_guangyun[] = { 96 | 0.9f, 0, 0, 0, 64.9f, 97 | 0, 0.9f,0, 0, 64.9f, 98 | 0, 0, 0.9f, 0, 64.9f, 99 | 0, 0, 0, 1.0f, 0 }; 100 | 101 | // 11、蓝调 102 | const float colormatrix_landiao[] = { 103 | 2.1f, -1.4f, 0.6f, 0.0f, -31.0f, 104 | -0.3f, 2.0f, -0.3f, 0.0f, -31.0f, 105 | -1.1f, -0.2f, 2.6f, 0.0f, -31.0f, 106 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 107 | }; 108 | 109 | // 12、梦幻 110 | const float colormatrix_menghuan[] = { 111 | 0.8f, 0.3f, 0.1f, 0.0f, 46.5f, 112 | 0.1f, 0.9f, 0.0f, 0.0f, 46.5f, 113 | 0.1f, 0.3f, 0.7f, 0.0f, 46.5f, 114 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 115 | }; 116 | 117 | // 13、夜色 118 | const float colormatrix_yese[] = { 119 | 1.0f, 0.0f, 0.0f, 0.0f, -66.6f, 120 | 0.0f, 1.1f, 0.0f, 0.0f, -66.6f, 121 | 0.0f, 0.0f, 1.0f, 0.0f, -66.6f, 122 | 0.0f, 0.0f, 0.0f, 1.0f, 0.0f 123 | }; 124 | 125 | ``` 126 | 矩阵及代表每一种滤镜。 127 | 128 | 2、滤镜处理Image对象 129 | ------- 130 | ``` 131 | /** 132 | 获取滤镜图 133 | 134 | @param inImage 原图 135 | @param f matrix矩阵 136 | @return 滤镜完成后图片 137 | */ 138 | + (UIImage*)imageWithImage:(UIImage*)inImage withColorMatrix:(const float*) f; 139 | ``` 140 | 实现: 141 | 142 | 143 | ``` 144 | + (UIImage*)imageWithImage:(UIImage*)inImage withColorMatrix:(const float*) f 145 | { 146 | 147 | CGImageRef img = [inImage CGImage]; 148 | CGSize size = [inImage size]; 149 | CGContextRef context = NULL; 150 | CGColorSpaceRef colorSpace; 151 | void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数。 152 | unsigned long bitmapByteCount; 153 | unsigned long bitmapBytesPerRow; 154 | 155 | size_t pixelsWide = CGImageGetWidth(img); //获取横向的像素点的个数 156 | size_t pixelsHigh = CGImageGetHeight(img); //纵向 157 | 158 | bitmapBytesPerRow = (pixelsWide * 4); //每一行的像素点占用的字节数,每个像素点的ARGB四个通道各占8个bit(0-255)的空间 159 | bitmapByteCount = (bitmapBytesPerRow * pixelsHigh); //计算整张图占用的字节数 160 | 161 | colorSpace = CGColorSpaceCreateDeviceRGB();//创建依赖于设备的RGB通道 162 | 163 | bitmapData = malloc(bitmapByteCount); //分配足够容纳图片字节数的内存空间 164 | 165 | context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); 166 | //创建CoreGraphic的图形上下文,该上下文描述了bitmaData指向的内存空间需要绘制的图像的一些绘制参数 167 | 168 | CGColorSpaceRelease( colorSpace ); 169 | 170 | 171 | 172 | CGRect rect = {{0,0},{size.width, size.height}}; 173 | //使用上面的函数创建上下文 174 | CGContextDrawImage(context, rect, img); //将目标图像绘制到指定的上下文,实际为上下文内的bitmapData。 175 | unsigned char *data = CGBitmapContextGetData (context); 176 | 177 | CGContextRelease(context); 178 | //释放上面的函数创建的上下文 179 | unsigned char *imgPixel = data; 180 | 181 | int wOff = 0; 182 | int pixOff = 0; 183 | 184 | 185 | for(GLuint y = 0;y< pixelsHigh;y++)//双层循环按照长宽的像素个数迭代每个像素点 186 | { 187 | pixOff = wOff; 188 | 189 | for (GLuint x = 0; x