├── .gitignore ├── ImageFilterKit.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── .gitignore └── xcuserdata │ └── .gitignore ├── ImageFilterKit ├── .gitignore ├── External │ ├── UIImage+Alpha.h │ ├── UIImage+Alpha.m │ ├── UIImage+RawData.h │ ├── UIImage+RawData.m │ ├── UIImage+Resize.h │ ├── UIImage+Resize.m │ ├── UIImage+RoundedCorner.h │ └── UIImage+RoundedCorner.m ├── Filters │ ├── IFBlurFilter.h │ ├── IFBlurFilter.m │ ├── IFBrightnessFilter.h │ ├── IFBrightnessFilter.m │ ├── IFColorConversions.c │ ├── IFColorConversions.h │ ├── IFEmbossFilter.h │ ├── IFEmbossFilter.m │ ├── IFFilter.h │ ├── IFFilter.m │ ├── IFFilterOperation.h │ ├── IFFilterOperation.m │ ├── IFFindEdgesFilter.h │ ├── IFFindEdgesFilter.m │ ├── IFGreyscaleFilter.h │ ├── IFGreyscaleFilter.m │ ├── IFHueFilter.h │ ├── IFHueFilter.m │ ├── IFPixelationFilter.h │ ├── IFPixelationFilter.m │ ├── IFSaturationFilter.h │ ├── IFSaturationFilter.m │ ├── IFSharpenFilter.h │ ├── IFSharpenFilter.m │ ├── IFSimpleTintFilter.h │ ├── IFSimpleTintFilter.m │ ├── IFSnowFuzzFilter.h │ ├── IFSnowFuzzFilter.m │ ├── IFThermalFilter.h │ ├── IFThermalFilter.m │ ├── IFTiltShiftFilter.h │ └── IFTiltShiftFilter.m ├── ImageFilterKit-Info.plist ├── ImageFilterKit-Prefix.pch ├── ImageFilterKitAppDelegate.h ├── ImageFilterKitAppDelegate.m ├── View │ ├── IFFilterPreviewViewController.h │ ├── IFFilterPreviewViewController.m │ ├── IFFilterPreviewViewController.xib │ ├── IFPhotoSelectionViewController.h │ ├── IFPhotoSelectionViewController.m │ └── IFPhotoSelectionViewController.xib ├── en.lproj │ ├── InfoPlist.strings │ └── MainWindow.xib └── main.m └── README.mdown /.gitignore: -------------------------------------------------------------------------------- 1 | /*.DS_Store 2 | -------------------------------------------------------------------------------- /ImageFilterKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1F326E8E1343879B00E8F129 /* IFHueFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326E8D1343879B00E8F129 /* IFHueFilter.m */; }; 11 | 1F326E91134387DA00E8F129 /* IFColorConversions.c in Sources */ = {isa = PBXBuildFile; fileRef = 1F326E8F134387DA00E8F129 /* IFColorConversions.c */; }; 12 | 1F326E9413438FE800E8F129 /* IFBlurFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326E9313438FE800E8F129 /* IFBlurFilter.m */; }; 13 | 1F326E97134397D900E8F129 /* IFFindEdgesFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326E96134397D800E8F129 /* IFFindEdgesFilter.m */; }; 14 | 1F326E9A1343993A00E8F129 /* IFEmbossFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326E991343993900E8F129 /* IFEmbossFilter.m */; }; 15 | 1F326EAC1343A19B00E8F129 /* IFSharpenFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326EAB1343A19B00E8F129 /* IFSharpenFilter.m */; }; 16 | 1F326F651343E42D00E8F129 /* UIImage+Resize.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326F641343E42D00E8F129 /* UIImage+Resize.m */; }; 17 | 1F326F6B1343E44700E8F129 /* UIImage+Alpha.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326F681343E44700E8F129 /* UIImage+Alpha.m */; }; 18 | 1F326F6C1343E44700E8F129 /* UIImage+RoundedCorner.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F326F6A1343E44700E8F129 /* UIImage+RoundedCorner.m */; }; 19 | 1F3A025D1342358B000E6259 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F3A025C1342358B000E6259 /* UIKit.framework */; }; 20 | 1F3A025F1342358B000E6259 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F3A025E1342358B000E6259 /* Foundation.framework */; }; 21 | 1F3A02611342358B000E6259 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F3A02601342358B000E6259 /* CoreGraphics.framework */; }; 22 | 1F3A02671342358B000E6259 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F3A02651342358B000E6259 /* InfoPlist.strings */; }; 23 | 1F3A026A1342358B000E6259 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3A02691342358B000E6259 /* main.m */; }; 24 | 1F3A026D1342358B000E6259 /* ImageFilterKitAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3A026C1342358B000E6259 /* ImageFilterKitAppDelegate.m */; }; 25 | 1F3A02701342358C000E6259 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F3A026E1342358C000E6259 /* MainWindow.xib */; }; 26 | 1F3A0283134236BC000E6259 /* IFPhotoSelectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3A0281134236BC000E6259 /* IFPhotoSelectionViewController.m */; }; 27 | 1F3A0284134236BC000E6259 /* IFPhotoSelectionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F3A0282134236BC000E6259 /* IFPhotoSelectionViewController.xib */; }; 28 | 1F3A02901342381D000E6259 /* UIImage+RawData.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3A028F1342381D000E6259 /* UIImage+RawData.m */; }; 29 | 1F3A029513423861000E6259 /* IFFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3A029413423861000E6259 /* IFFilter.m */; }; 30 | 1F71143E134294050007676F /* IFSaturationFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F71143D134294050007676F /* IFSaturationFilter.m */; }; 31 | 1F868A5313423FED003B9488 /* IFFilterPreviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F868A5113423FED003B9488 /* IFFilterPreviewViewController.m */; }; 32 | 1F868A5413423FED003B9488 /* IFFilterPreviewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F868A5213423FED003B9488 /* IFFilterPreviewViewController.xib */; }; 33 | 1F868A58134247E1003B9488 /* IFSimpleTintFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F868A57134247E0003B9488 /* IFSimpleTintFilter.m */; }; 34 | 1F868A6C1342530B003B9488 /* IFPixelationFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F868A6B1342530B003B9488 /* IFPixelationFilter.m */; }; 35 | 1F868A7813426086003B9488 /* IFGreyscaleFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F868A7713426086003B9488 /* IFGreyscaleFilter.m */; }; 36 | 1F868A7B134263E1003B9488 /* IFBrightnessFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F868A7A134263E1003B9488 /* IFBrightnessFilter.m */; }; 37 | 1F99EF1F13427B4F005B2C28 /* IFFilterOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F99EF1E13427B4F005B2C28 /* IFFilterOperation.m */; }; 38 | 1FCF963213426D620071A341 /* IFThermalFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FCF963113426D620071A341 /* IFThermalFilter.m */; }; 39 | 1FCF9646134275480071A341 /* IFSnowFuzzFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FCF9645134275480071A341 /* IFSnowFuzzFilter.m */; }; 40 | 1FE8E042134CC0A700BAC389 /* IFTiltShiftFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FE8E041134CC0A700BAC389 /* IFTiltShiftFilter.m */; }; 41 | /* End PBXBuildFile section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 1F326E8C1343879B00E8F129 /* IFHueFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFHueFilter.h; path = Filters/IFHueFilter.h; sourceTree = ""; }; 45 | 1F326E8D1343879B00E8F129 /* IFHueFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFHueFilter.m; path = Filters/IFHueFilter.m; sourceTree = ""; }; 46 | 1F326E8F134387DA00E8F129 /* IFColorConversions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = IFColorConversions.c; path = Filters/IFColorConversions.c; sourceTree = ""; }; 47 | 1F326E90134387DA00E8F129 /* IFColorConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFColorConversions.h; path = Filters/IFColorConversions.h; sourceTree = ""; }; 48 | 1F326E9213438FE800E8F129 /* IFBlurFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFBlurFilter.h; path = Filters/IFBlurFilter.h; sourceTree = ""; }; 49 | 1F326E9313438FE800E8F129 /* IFBlurFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFBlurFilter.m; path = Filters/IFBlurFilter.m; sourceTree = ""; }; 50 | 1F326E95134397D800E8F129 /* IFFindEdgesFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFFindEdgesFilter.h; path = Filters/IFFindEdgesFilter.h; sourceTree = ""; }; 51 | 1F326E96134397D800E8F129 /* IFFindEdgesFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFFindEdgesFilter.m; path = Filters/IFFindEdgesFilter.m; sourceTree = ""; }; 52 | 1F326E981343993900E8F129 /* IFEmbossFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFEmbossFilter.h; path = Filters/IFEmbossFilter.h; sourceTree = ""; }; 53 | 1F326E991343993900E8F129 /* IFEmbossFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFEmbossFilter.m; path = Filters/IFEmbossFilter.m; sourceTree = ""; }; 54 | 1F326EAA1343A19B00E8F129 /* IFSharpenFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFSharpenFilter.h; path = Filters/IFSharpenFilter.h; sourceTree = ""; }; 55 | 1F326EAB1343A19B00E8F129 /* IFSharpenFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFSharpenFilter.m; path = Filters/IFSharpenFilter.m; sourceTree = ""; }; 56 | 1F326F631343E42D00E8F129 /* UIImage+Resize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Resize.h"; sourceTree = ""; }; 57 | 1F326F641343E42D00E8F129 /* UIImage+Resize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Resize.m"; sourceTree = ""; }; 58 | 1F326F671343E44700E8F129 /* UIImage+Alpha.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Alpha.h"; sourceTree = ""; }; 59 | 1F326F681343E44700E8F129 /* UIImage+Alpha.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Alpha.m"; sourceTree = ""; }; 60 | 1F326F691343E44700E8F129 /* UIImage+RoundedCorner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RoundedCorner.h"; sourceTree = ""; }; 61 | 1F326F6A1343E44700E8F129 /* UIImage+RoundedCorner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RoundedCorner.m"; sourceTree = ""; }; 62 | 1F3A02581342358B000E6259 /* ImageFilterKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageFilterKit.app; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 1F3A025C1342358B000E6259 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 64 | 1F3A025E1342358B000E6259 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 65 | 1F3A02601342358B000E6259 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 66 | 1F3A02641342358B000E6259 /* ImageFilterKit-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ImageFilterKit-Info.plist"; sourceTree = ""; }; 67 | 1F3A02661342358B000E6259 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 68 | 1F3A02681342358B000E6259 /* ImageFilterKit-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ImageFilterKit-Prefix.pch"; sourceTree = ""; }; 69 | 1F3A02691342358B000E6259 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 70 | 1F3A026B1342358B000E6259 /* ImageFilterKitAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageFilterKitAppDelegate.h; sourceTree = ""; }; 71 | 1F3A026C1342358B000E6259 /* ImageFilterKitAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageFilterKitAppDelegate.m; sourceTree = ""; }; 72 | 1F3A026F1342358C000E6259 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; 73 | 1F3A0280134236BC000E6259 /* IFPhotoSelectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFPhotoSelectionViewController.h; path = View/IFPhotoSelectionViewController.h; sourceTree = ""; }; 74 | 1F3A0281134236BC000E6259 /* IFPhotoSelectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFPhotoSelectionViewController.m; path = View/IFPhotoSelectionViewController.m; sourceTree = ""; }; 75 | 1F3A0282134236BC000E6259 /* IFPhotoSelectionViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = IFPhotoSelectionViewController.xib; path = View/IFPhotoSelectionViewController.xib; sourceTree = ""; }; 76 | 1F3A028E1342381D000E6259 /* UIImage+RawData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RawData.h"; sourceTree = ""; }; 77 | 1F3A028F1342381D000E6259 /* UIImage+RawData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RawData.m"; sourceTree = ""; }; 78 | 1F3A029313423861000E6259 /* IFFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFFilter.h; path = Filters/IFFilter.h; sourceTree = ""; }; 79 | 1F3A029413423861000E6259 /* IFFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFFilter.m; path = Filters/IFFilter.m; sourceTree = ""; }; 80 | 1F71143C134294050007676F /* IFSaturationFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFSaturationFilter.h; path = Filters/IFSaturationFilter.h; sourceTree = ""; }; 81 | 1F71143D134294050007676F /* IFSaturationFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFSaturationFilter.m; path = Filters/IFSaturationFilter.m; sourceTree = ""; }; 82 | 1F868A5013423FED003B9488 /* IFFilterPreviewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFFilterPreviewViewController.h; path = View/IFFilterPreviewViewController.h; sourceTree = ""; }; 83 | 1F868A5113423FED003B9488 /* IFFilterPreviewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFFilterPreviewViewController.m; path = View/IFFilterPreviewViewController.m; sourceTree = ""; }; 84 | 1F868A5213423FED003B9488 /* IFFilterPreviewViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = IFFilterPreviewViewController.xib; path = View/IFFilterPreviewViewController.xib; sourceTree = ""; }; 85 | 1F868A56134247E0003B9488 /* IFSimpleTintFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFSimpleTintFilter.h; path = Filters/IFSimpleTintFilter.h; sourceTree = ""; }; 86 | 1F868A57134247E0003B9488 /* IFSimpleTintFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFSimpleTintFilter.m; path = Filters/IFSimpleTintFilter.m; sourceTree = ""; }; 87 | 1F868A6A1342530A003B9488 /* IFPixelationFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFPixelationFilter.h; path = Filters/IFPixelationFilter.h; sourceTree = ""; }; 88 | 1F868A6B1342530B003B9488 /* IFPixelationFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFPixelationFilter.m; path = Filters/IFPixelationFilter.m; sourceTree = ""; }; 89 | 1F868A7613426086003B9488 /* IFGreyscaleFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFGreyscaleFilter.h; path = Filters/IFGreyscaleFilter.h; sourceTree = ""; }; 90 | 1F868A7713426086003B9488 /* IFGreyscaleFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFGreyscaleFilter.m; path = Filters/IFGreyscaleFilter.m; sourceTree = ""; }; 91 | 1F868A79134263E1003B9488 /* IFBrightnessFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFBrightnessFilter.h; path = Filters/IFBrightnessFilter.h; sourceTree = ""; }; 92 | 1F868A7A134263E1003B9488 /* IFBrightnessFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFBrightnessFilter.m; path = Filters/IFBrightnessFilter.m; sourceTree = ""; }; 93 | 1F99EF1D13427B4F005B2C28 /* IFFilterOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFFilterOperation.h; path = Filters/IFFilterOperation.h; sourceTree = ""; }; 94 | 1F99EF1E13427B4F005B2C28 /* IFFilterOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFFilterOperation.m; path = Filters/IFFilterOperation.m; sourceTree = ""; }; 95 | 1FCF963013426D620071A341 /* IFThermalFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFThermalFilter.h; path = Filters/IFThermalFilter.h; sourceTree = ""; }; 96 | 1FCF963113426D620071A341 /* IFThermalFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFThermalFilter.m; path = Filters/IFThermalFilter.m; sourceTree = ""; }; 97 | 1FCF9644134275480071A341 /* IFSnowFuzzFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFSnowFuzzFilter.h; path = Filters/IFSnowFuzzFilter.h; sourceTree = ""; }; 98 | 1FCF9645134275480071A341 /* IFSnowFuzzFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFSnowFuzzFilter.m; path = Filters/IFSnowFuzzFilter.m; sourceTree = ""; }; 99 | 1FE8E040134CC0A700BAC389 /* IFTiltShiftFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IFTiltShiftFilter.h; path = Filters/IFTiltShiftFilter.h; sourceTree = ""; }; 100 | 1FE8E041134CC0A700BAC389 /* IFTiltShiftFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IFTiltShiftFilter.m; path = Filters/IFTiltShiftFilter.m; sourceTree = ""; }; 101 | /* End PBXFileReference section */ 102 | 103 | /* Begin PBXFrameworksBuildPhase section */ 104 | 1F3A02551342358B000E6259 /* Frameworks */ = { 105 | isa = PBXFrameworksBuildPhase; 106 | buildActionMask = 2147483647; 107 | files = ( 108 | 1F3A025D1342358B000E6259 /* UIKit.framework in Frameworks */, 109 | 1F3A025F1342358B000E6259 /* Foundation.framework in Frameworks */, 110 | 1F3A02611342358B000E6259 /* CoreGraphics.framework in Frameworks */, 111 | ); 112 | runOnlyForDeploymentPostprocessing = 0; 113 | }; 114 | /* End PBXFrameworksBuildPhase section */ 115 | 116 | /* Begin PBXGroup section */ 117 | 1F3A024D1342358B000E6259 = { 118 | isa = PBXGroup; 119 | children = ( 120 | 1F3A02621342358B000E6259 /* ImageFilterKit */, 121 | 1F3A025B1342358B000E6259 /* Frameworks */, 122 | 1F3A02591342358B000E6259 /* Products */, 123 | ); 124 | sourceTree = ""; 125 | }; 126 | 1F3A02591342358B000E6259 /* Products */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 1F3A02581342358B000E6259 /* ImageFilterKit.app */, 130 | ); 131 | name = Products; 132 | sourceTree = ""; 133 | }; 134 | 1F3A025B1342358B000E6259 /* Frameworks */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 1F3A025C1342358B000E6259 /* UIKit.framework */, 138 | 1F3A025E1342358B000E6259 /* Foundation.framework */, 139 | 1F3A02601342358B000E6259 /* CoreGraphics.framework */, 140 | ); 141 | name = Frameworks; 142 | sourceTree = ""; 143 | }; 144 | 1F3A02621342358B000E6259 /* ImageFilterKit */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 1F3A029213423826000E6259 /* Filters */, 148 | 1F3A028D1342381D000E6259 /* External */, 149 | 1F3A027C134235E6000E6259 /* View */, 150 | 1F3A026B1342358B000E6259 /* ImageFilterKitAppDelegate.h */, 151 | 1F3A026C1342358B000E6259 /* ImageFilterKitAppDelegate.m */, 152 | 1F3A02631342358B000E6259 /* Supporting Files */, 153 | ); 154 | path = ImageFilterKit; 155 | sourceTree = ""; 156 | }; 157 | 1F3A02631342358B000E6259 /* Supporting Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 1F3A026E1342358C000E6259 /* MainWindow.xib */, 161 | 1F3A02641342358B000E6259 /* ImageFilterKit-Info.plist */, 162 | 1F3A02651342358B000E6259 /* InfoPlist.strings */, 163 | 1F3A02681342358B000E6259 /* ImageFilterKit-Prefix.pch */, 164 | 1F3A02691342358B000E6259 /* main.m */, 165 | ); 166 | name = "Supporting Files"; 167 | sourceTree = ""; 168 | }; 169 | 1F3A027C134235E6000E6259 /* View */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 1F3A0280134236BC000E6259 /* IFPhotoSelectionViewController.h */, 173 | 1F3A0281134236BC000E6259 /* IFPhotoSelectionViewController.m */, 174 | 1F3A0282134236BC000E6259 /* IFPhotoSelectionViewController.xib */, 175 | 1F868A5013423FED003B9488 /* IFFilterPreviewViewController.h */, 176 | 1F868A5113423FED003B9488 /* IFFilterPreviewViewController.m */, 177 | 1F868A5213423FED003B9488 /* IFFilterPreviewViewController.xib */, 178 | ); 179 | name = View; 180 | sourceTree = ""; 181 | }; 182 | 1F3A028D1342381D000E6259 /* External */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | 1F3A028E1342381D000E6259 /* UIImage+RawData.h */, 186 | 1F3A028F1342381D000E6259 /* UIImage+RawData.m */, 187 | 1F326F631343E42D00E8F129 /* UIImage+Resize.h */, 188 | 1F326F641343E42D00E8F129 /* UIImage+Resize.m */, 189 | 1F326F671343E44700E8F129 /* UIImage+Alpha.h */, 190 | 1F326F681343E44700E8F129 /* UIImage+Alpha.m */, 191 | 1F326F691343E44700E8F129 /* UIImage+RoundedCorner.h */, 192 | 1F326F6A1343E44700E8F129 /* UIImage+RoundedCorner.m */, 193 | ); 194 | path = External; 195 | sourceTree = ""; 196 | }; 197 | 1F3A029213423826000E6259 /* Filters */ = { 198 | isa = PBXGroup; 199 | children = ( 200 | 1F3A029313423861000E6259 /* IFFilter.h */, 201 | 1F3A029413423861000E6259 /* IFFilter.m */, 202 | 1F99EF1D13427B4F005B2C28 /* IFFilterOperation.h */, 203 | 1F99EF1E13427B4F005B2C28 /* IFFilterOperation.m */, 204 | 1F868A56134247E0003B9488 /* IFSimpleTintFilter.h */, 205 | 1F868A57134247E0003B9488 /* IFSimpleTintFilter.m */, 206 | 1F868A7613426086003B9488 /* IFGreyscaleFilter.h */, 207 | 1F868A7713426086003B9488 /* IFGreyscaleFilter.m */, 208 | 1F868A6A1342530A003B9488 /* IFPixelationFilter.h */, 209 | 1F868A6B1342530B003B9488 /* IFPixelationFilter.m */, 210 | 1F868A79134263E1003B9488 /* IFBrightnessFilter.h */, 211 | 1F868A7A134263E1003B9488 /* IFBrightnessFilter.m */, 212 | 1F71143C134294050007676F /* IFSaturationFilter.h */, 213 | 1F71143D134294050007676F /* IFSaturationFilter.m */, 214 | 1F326E8C1343879B00E8F129 /* IFHueFilter.h */, 215 | 1F326E8D1343879B00E8F129 /* IFHueFilter.m */, 216 | 1FCF963013426D620071A341 /* IFThermalFilter.h */, 217 | 1FCF963113426D620071A341 /* IFThermalFilter.m */, 218 | 1FCF9644134275480071A341 /* IFSnowFuzzFilter.h */, 219 | 1FCF9645134275480071A341 /* IFSnowFuzzFilter.m */, 220 | 1F326E9213438FE800E8F129 /* IFBlurFilter.h */, 221 | 1F326E9313438FE800E8F129 /* IFBlurFilter.m */, 222 | 1F326E95134397D800E8F129 /* IFFindEdgesFilter.h */, 223 | 1F326E96134397D800E8F129 /* IFFindEdgesFilter.m */, 224 | 1F326E981343993900E8F129 /* IFEmbossFilter.h */, 225 | 1F326E991343993900E8F129 /* IFEmbossFilter.m */, 226 | 1F326EAA1343A19B00E8F129 /* IFSharpenFilter.h */, 227 | 1F326EAB1343A19B00E8F129 /* IFSharpenFilter.m */, 228 | 1FE8E040134CC0A700BAC389 /* IFTiltShiftFilter.h */, 229 | 1FE8E041134CC0A700BAC389 /* IFTiltShiftFilter.m */, 230 | 1F326E90134387DA00E8F129 /* IFColorConversions.h */, 231 | 1F326E8F134387DA00E8F129 /* IFColorConversions.c */, 232 | ); 233 | name = Filters; 234 | sourceTree = ""; 235 | }; 236 | /* End PBXGroup section */ 237 | 238 | /* Begin PBXNativeTarget section */ 239 | 1F3A02571342358B000E6259 /* ImageFilterKit */ = { 240 | isa = PBXNativeTarget; 241 | buildConfigurationList = 1F3A02791342358C000E6259 /* Build configuration list for PBXNativeTarget "ImageFilterKit" */; 242 | buildPhases = ( 243 | 1F3A02541342358B000E6259 /* Sources */, 244 | 1F3A02551342358B000E6259 /* Frameworks */, 245 | 1F3A02561342358B000E6259 /* Resources */, 246 | ); 247 | buildRules = ( 248 | ); 249 | dependencies = ( 250 | ); 251 | name = ImageFilterKit; 252 | productName = ImageFilterKit; 253 | productReference = 1F3A02581342358B000E6259 /* ImageFilterKit.app */; 254 | productType = "com.apple.product-type.application"; 255 | }; 256 | /* End PBXNativeTarget section */ 257 | 258 | /* Begin PBXProject section */ 259 | 1F3A024F1342358B000E6259 /* Project object */ = { 260 | isa = PBXProject; 261 | attributes = { 262 | ORGANIZATIONNAME = "Resource Interactive"; 263 | }; 264 | buildConfigurationList = 1F3A02521342358B000E6259 /* Build configuration list for PBXProject "ImageFilterKit" */; 265 | compatibilityVersion = "Xcode 3.2"; 266 | developmentRegion = English; 267 | hasScannedForEncodings = 0; 268 | knownRegions = ( 269 | en, 270 | ); 271 | mainGroup = 1F3A024D1342358B000E6259; 272 | productRefGroup = 1F3A02591342358B000E6259 /* Products */; 273 | projectDirPath = ""; 274 | projectRoot = ""; 275 | targets = ( 276 | 1F3A02571342358B000E6259 /* ImageFilterKit */, 277 | ); 278 | }; 279 | /* End PBXProject section */ 280 | 281 | /* Begin PBXResourcesBuildPhase section */ 282 | 1F3A02561342358B000E6259 /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 1F3A02671342358B000E6259 /* InfoPlist.strings in Resources */, 287 | 1F3A02701342358C000E6259 /* MainWindow.xib in Resources */, 288 | 1F3A0284134236BC000E6259 /* IFPhotoSelectionViewController.xib in Resources */, 289 | 1F868A5413423FED003B9488 /* IFFilterPreviewViewController.xib in Resources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | /* End PBXResourcesBuildPhase section */ 294 | 295 | /* Begin PBXSourcesBuildPhase section */ 296 | 1F3A02541342358B000E6259 /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | 1F3A026A1342358B000E6259 /* main.m in Sources */, 301 | 1F3A026D1342358B000E6259 /* ImageFilterKitAppDelegate.m in Sources */, 302 | 1F3A0283134236BC000E6259 /* IFPhotoSelectionViewController.m in Sources */, 303 | 1F3A02901342381D000E6259 /* UIImage+RawData.m in Sources */, 304 | 1F3A029513423861000E6259 /* IFFilter.m in Sources */, 305 | 1F868A5313423FED003B9488 /* IFFilterPreviewViewController.m in Sources */, 306 | 1F868A58134247E1003B9488 /* IFSimpleTintFilter.m in Sources */, 307 | 1F868A6C1342530B003B9488 /* IFPixelationFilter.m in Sources */, 308 | 1F868A7813426086003B9488 /* IFGreyscaleFilter.m in Sources */, 309 | 1F868A7B134263E1003B9488 /* IFBrightnessFilter.m in Sources */, 310 | 1FCF963213426D620071A341 /* IFThermalFilter.m in Sources */, 311 | 1FCF9646134275480071A341 /* IFSnowFuzzFilter.m in Sources */, 312 | 1F99EF1F13427B4F005B2C28 /* IFFilterOperation.m in Sources */, 313 | 1F71143E134294050007676F /* IFSaturationFilter.m in Sources */, 314 | 1F326E8E1343879B00E8F129 /* IFHueFilter.m in Sources */, 315 | 1F326E91134387DA00E8F129 /* IFColorConversions.c in Sources */, 316 | 1F326E9413438FE800E8F129 /* IFBlurFilter.m in Sources */, 317 | 1F326E97134397D900E8F129 /* IFFindEdgesFilter.m in Sources */, 318 | 1F326E9A1343993A00E8F129 /* IFEmbossFilter.m in Sources */, 319 | 1F326EAC1343A19B00E8F129 /* IFSharpenFilter.m in Sources */, 320 | 1F326F651343E42D00E8F129 /* UIImage+Resize.m in Sources */, 321 | 1F326F6B1343E44700E8F129 /* UIImage+Alpha.m in Sources */, 322 | 1F326F6C1343E44700E8F129 /* UIImage+RoundedCorner.m in Sources */, 323 | 1FE8E042134CC0A700BAC389 /* IFTiltShiftFilter.m in Sources */, 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | /* End PBXSourcesBuildPhase section */ 328 | 329 | /* Begin PBXVariantGroup section */ 330 | 1F3A02651342358B000E6259 /* InfoPlist.strings */ = { 331 | isa = PBXVariantGroup; 332 | children = ( 333 | 1F3A02661342358B000E6259 /* en */, 334 | ); 335 | name = InfoPlist.strings; 336 | sourceTree = ""; 337 | }; 338 | 1F3A026E1342358C000E6259 /* MainWindow.xib */ = { 339 | isa = PBXVariantGroup; 340 | children = ( 341 | 1F3A026F1342358C000E6259 /* en */, 342 | ); 343 | name = MainWindow.xib; 344 | sourceTree = ""; 345 | }; 346 | /* End PBXVariantGroup section */ 347 | 348 | /* Begin XCBuildConfiguration section */ 349 | 1F3A02771342358C000E6259 /* Debug */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | GCC_C_LANGUAGE_STANDARD = gnu99; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 357 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 358 | GCC_VERSION = com.apple.compilers.llvmgcc42; 359 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 360 | GCC_WARN_UNUSED_VARIABLE = YES; 361 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 362 | SDKROOT = iphoneos; 363 | }; 364 | name = Debug; 365 | }; 366 | 1F3A02781342358C000E6259 /* Release */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 370 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_VERSION = com.apple.compilers.llvmgcc42; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 376 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 377 | SDKROOT = iphoneos; 378 | }; 379 | name = Release; 380 | }; 381 | 1F3A027A1342358C000E6259 /* Debug */ = { 382 | isa = XCBuildConfiguration; 383 | buildSettings = { 384 | ALWAYS_SEARCH_USER_PATHS = NO; 385 | COPY_PHASE_STRIP = NO; 386 | GCC_DYNAMIC_NO_PIC = NO; 387 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 388 | GCC_PREFIX_HEADER = "ImageFilterKit/ImageFilterKit-Prefix.pch"; 389 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 390 | INFOPLIST_FILE = "ImageFilterKit/ImageFilterKit-Info.plist"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | WRAPPER_EXTENSION = app; 393 | }; 394 | name = Debug; 395 | }; 396 | 1F3A027B1342358C000E6259 /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ALWAYS_SEARCH_USER_PATHS = NO; 400 | COPY_PHASE_STRIP = YES; 401 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 402 | GCC_PREFIX_HEADER = "ImageFilterKit/ImageFilterKit-Prefix.pch"; 403 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 404 | INFOPLIST_FILE = "ImageFilterKit/ImageFilterKit-Info.plist"; 405 | PRODUCT_NAME = "$(TARGET_NAME)"; 406 | VALIDATE_PRODUCT = YES; 407 | WRAPPER_EXTENSION = app; 408 | }; 409 | name = Release; 410 | }; 411 | /* End XCBuildConfiguration section */ 412 | 413 | /* Begin XCConfigurationList section */ 414 | 1F3A02521342358B000E6259 /* Build configuration list for PBXProject "ImageFilterKit" */ = { 415 | isa = XCConfigurationList; 416 | buildConfigurations = ( 417 | 1F3A02771342358C000E6259 /* Debug */, 418 | 1F3A02781342358C000E6259 /* Release */, 419 | ); 420 | defaultConfigurationIsVisible = 0; 421 | defaultConfigurationName = Release; 422 | }; 423 | 1F3A02791342358C000E6259 /* Build configuration list for PBXNativeTarget "ImageFilterKit" */ = { 424 | isa = XCConfigurationList; 425 | buildConfigurations = ( 426 | 1F3A027A1342358C000E6259 /* Debug */, 427 | 1F3A027B1342358C000E6259 /* Release */, 428 | ); 429 | defaultConfigurationIsVisible = 0; 430 | defaultConfigurationName = Release; 431 | }; 432 | /* End XCConfigurationList section */ 433 | }; 434 | rootObject = 1F3A024F1342358B000E6259 /* Project object */; 435 | } 436 | -------------------------------------------------------------------------------- /ImageFilterKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageFilterKit.xcodeproj/project.xcworkspace/xcuserdata/.gitignore: -------------------------------------------------------------------------------- 1 | /roth.xcuserdatad/ 2 | -------------------------------------------------------------------------------- /ImageFilterKit.xcodeproj/xcuserdata/.gitignore: -------------------------------------------------------------------------------- 1 | /roth.xcuserdatad/ 2 | -------------------------------------------------------------------------------- /ImageFilterKit/.gitignore: -------------------------------------------------------------------------------- 1 | /*.DS_Store 2 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | @interface UIImage (Alpha) 8 | - (BOOL)hasAlpha; 9 | - (UIImage *)imageWithAlpha; 10 | - (UIImage *)transparentBorderImage:(NSUInteger)borderSize; 11 | @end 12 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | // Private helper methods 9 | @interface UIImage () 10 | - (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size; 11 | @end 12 | 13 | @implementation UIImage (Alpha) 14 | 15 | // Returns true if the image has an alpha layer 16 | - (BOOL)hasAlpha { 17 | CGImageAlphaInfo alpha = CGImageGetAlphaInfo(self.CGImage); 18 | return (alpha == kCGImageAlphaFirst || 19 | alpha == kCGImageAlphaLast || 20 | alpha == kCGImageAlphaPremultipliedFirst || 21 | alpha == kCGImageAlphaPremultipliedLast); 22 | } 23 | 24 | // Returns a copy of the given image, adding an alpha channel if it doesn't already have one 25 | - (UIImage *)imageWithAlpha { 26 | if ([self hasAlpha]) { 27 | return self; 28 | } 29 | 30 | CGImageRef imageRef = self.CGImage; 31 | size_t width = CGImageGetWidth(imageRef); 32 | size_t height = CGImageGetHeight(imageRef); 33 | 34 | // The bitsPerComponent and bitmapInfo values are hard-coded to prevent an "unsupported parameter combination" error 35 | CGContextRef offscreenContext = CGBitmapContextCreate(NULL, 36 | width, 37 | height, 38 | 8, 39 | 0, 40 | CGImageGetColorSpace(imageRef), 41 | kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); 42 | 43 | // Draw the image into the context and retrieve the new image, which will now have an alpha layer 44 | CGContextDrawImage(offscreenContext, CGRectMake(0, 0, width, height), imageRef); 45 | CGImageRef imageRefWithAlpha = CGBitmapContextCreateImage(offscreenContext); 46 | UIImage *imageWithAlpha = [UIImage imageWithCGImage:imageRefWithAlpha]; 47 | 48 | // Clean up 49 | CGContextRelease(offscreenContext); 50 | CGImageRelease(imageRefWithAlpha); 51 | 52 | return imageWithAlpha; 53 | } 54 | 55 | // Returns a copy of the image with a transparent border of the given size added around its edges. 56 | // If the image has no alpha layer, one will be added to it. 57 | - (UIImage *)transparentBorderImage:(NSUInteger)borderSize { 58 | // If the image does not have an alpha layer, add one 59 | UIImage *image = [self imageWithAlpha]; 60 | 61 | CGRect newRect = CGRectMake(0, 0, image.size.width + borderSize * 2, image.size.height + borderSize * 2); 62 | 63 | // Build a context that's the same dimensions as the new size 64 | CGContextRef bitmap = CGBitmapContextCreate(NULL, 65 | newRect.size.width, 66 | newRect.size.height, 67 | CGImageGetBitsPerComponent(self.CGImage), 68 | 0, 69 | CGImageGetColorSpace(self.CGImage), 70 | CGImageGetBitmapInfo(self.CGImage)); 71 | 72 | // Draw the image in the center of the context, leaving a gap around the edges 73 | CGRect imageLocation = CGRectMake(borderSize, borderSize, image.size.width, image.size.height); 74 | CGContextDrawImage(bitmap, imageLocation, self.CGImage); 75 | CGImageRef borderImageRef = CGBitmapContextCreateImage(bitmap); 76 | 77 | // Create a mask to make the border transparent, and combine it with the image 78 | CGImageRef maskImageRef = [self newBorderMask:borderSize size:newRect.size]; 79 | CGImageRef transparentBorderImageRef = CGImageCreateWithMask(borderImageRef, maskImageRef); 80 | UIImage *transparentBorderImage = [UIImage imageWithCGImage:transparentBorderImageRef]; 81 | 82 | // Clean up 83 | CGContextRelease(bitmap); 84 | CGImageRelease(borderImageRef); 85 | CGImageRelease(maskImageRef); 86 | CGImageRelease(transparentBorderImageRef); 87 | 88 | return transparentBorderImage; 89 | } 90 | 91 | #pragma mark - 92 | #pragma mark Private helper methods 93 | 94 | // Creates a mask that makes the outer edges transparent and everything else opaque 95 | // The size must include the entire mask (opaque part + transparent border) 96 | // The caller is responsible for releasing the returned reference by calling CGImageRelease 97 | - (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size { 98 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); 99 | 100 | // Build a context that's the same dimensions as the new size 101 | CGContextRef maskContext = CGBitmapContextCreate(NULL, 102 | size.width, 103 | size.height, 104 | 8, // 8-bit grayscale 105 | 0, 106 | colorSpace, 107 | kCGBitmapByteOrderDefault | kCGImageAlphaNone); 108 | 109 | // Start with a mask that's entirely transparent 110 | CGContextSetFillColorWithColor(maskContext, [UIColor blackColor].CGColor); 111 | CGContextFillRect(maskContext, CGRectMake(0, 0, size.width, size.height)); 112 | 113 | // Make the inner part (within the border) opaque 114 | CGContextSetFillColorWithColor(maskContext, [UIColor whiteColor].CGColor); 115 | CGContextFillRect(maskContext, CGRectMake(borderSize, borderSize, size.width - borderSize * 2, size.height - borderSize * 2)); 116 | 117 | // Get an image of the context 118 | CGImageRef maskImageRef = CGBitmapContextCreateImage(maskContext); 119 | 120 | // Clean up 121 | CGContextRelease(maskContext); 122 | CGColorSpaceRelease(colorSpace); 123 | 124 | return maskImageRef; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /ImageFilterKit/External/UIImage+RawData.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+RawData.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/7/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface UIImage (RawData) 13 | 14 | + (UIImage *) imageWithRawImageData:(NSData *)data width:(int)width height:(int)height; 15 | - (NSData *) rawImageData; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ImageFilterKit/External/UIImage+RawData.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+RawData.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/7/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "UIImage+RawData.h" 10 | 11 | 12 | @implementation UIImage (RawData) 13 | 14 | + (UIImage *) imageWithRawImageData:(NSData *)data width:(int)width height:(int)height 15 | { 16 | CFDataRef imageData = (CFDataRef)data; 17 | CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(imageData); 18 | 19 | size_t bitsPerComponent = 8; 20 | size_t bitsPerPixel = 32; 21 | size_t bytesPerPixel = bitsPerPixel / 8; // 4 22 | size_t bytesPerRow = width * bytesPerPixel; 23 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 24 | CGBitmapInfo info = kCGImageAlphaPremultipliedFirst; 25 | CGColorRenderingIntent intent = kCGRenderingIntentDefault; 26 | 27 | // Create the new CGImageRef 28 | CGImageRef throughCGImage = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, info, imgDataProvider, NULL, NO, intent); 29 | CGDataProviderRelease(imgDataProvider); 30 | 31 | // make UIImage with CGImage 32 | UIImage *resultImage = [[UIImage alloc] initWithCGImage:throughCGImage]; 33 | 34 | CGImageRelease(throughCGImage); 35 | 36 | return [resultImage autorelease]; 37 | } 38 | 39 | - (NSData *) rawImageData 40 | { 41 | // Use ARGB ColorSpace 42 | size_t bytesPerPixel = 4; 43 | size_t bitsPerComponent = 8; 44 | 45 | CGImageAlphaInfo alphaInfo = kCGImageAlphaPremultipliedFirst; 46 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 47 | 48 | int width = self.size.width; 49 | int height = self.size.height; 50 | 51 | // Allocate memory for our bitmap context based on above sizes 52 | UInt8* pixelData = malloc( width * height * bytesPerPixel ); 53 | 54 | // Create the bitmap context 55 | CGContextRef context = CGBitmapContextCreate (pixelData, width, height, bitsPerComponent, width * bytesPerPixel, colorSpace, alphaInfo); 56 | 57 | if( !context ) 58 | { 59 | return nil; 60 | } 61 | 62 | // Render the image into the context (ending up in our buffer) 63 | CGContextDrawImage( context, CGRectMake(0, 0, width, height), self.CGImage ); 64 | CGContextRelease( context ); 65 | 66 | NSData *rawData = [NSData dataWithBytes:pixelData length:(width * height * bytesPerPixel)]; 67 | 68 | return rawData; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | @interface UIImage (Resize) 8 | - (UIImage *)croppedImage:(CGRect)bounds; 9 | - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize 10 | transparentBorder:(NSUInteger)borderSize 11 | cornerRadius:(NSUInteger)cornerRadius 12 | interpolationQuality:(CGInterpolationQuality)quality; 13 | - (UIImage *)resizedImage:(CGSize)newSize 14 | interpolationQuality:(CGInterpolationQuality)quality; 15 | - (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode 16 | bounds:(CGSize)bounds 17 | interpolationQuality:(CGInterpolationQuality)quality; 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | // Private helper methods 11 | @interface UIImage () 12 | - (UIImage *)resizedImage:(CGSize)newSize 13 | transform:(CGAffineTransform)transform 14 | drawTransposed:(BOOL)transpose 15 | interpolationQuality:(CGInterpolationQuality)quality; 16 | - (CGAffineTransform)transformForOrientation:(CGSize)newSize; 17 | @end 18 | 19 | @implementation UIImage (Resize) 20 | 21 | // Returns a copy of this image that is cropped to the given bounds. 22 | // The bounds will be adjusted using CGRectIntegral. 23 | // This method ignores the image's imageOrientation setting. 24 | - (UIImage *)croppedImage:(CGRect)bounds { 25 | CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds); 26 | UIImage *croppedImage = [UIImage imageWithCGImage:imageRef]; 27 | CGImageRelease(imageRef); 28 | return croppedImage; 29 | } 30 | 31 | // Returns a copy of this image that is squared to the thumbnail size. 32 | // 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.) 33 | - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize 34 | transparentBorder:(NSUInteger)borderSize 35 | cornerRadius:(NSUInteger)cornerRadius 36 | interpolationQuality:(CGInterpolationQuality)quality { 37 | UIImage *resizedImage = [self resizedImageWithContentMode:UIViewContentModeScaleAspectFill 38 | bounds:CGSizeMake(thumbnailSize, thumbnailSize) 39 | interpolationQuality:quality]; 40 | 41 | // Crop out any part of the image that's larger than the thumbnail size 42 | // The cropped rect must be centered on the resized image 43 | // Round the origin points so that the size isn't altered when CGRectIntegral is later invoked 44 | CGRect cropRect = CGRectMake(round((resizedImage.size.width - thumbnailSize) / 2), 45 | round((resizedImage.size.height - thumbnailSize) / 2), 46 | thumbnailSize, 47 | thumbnailSize); 48 | UIImage *croppedImage = [resizedImage croppedImage:cropRect]; 49 | 50 | UIImage *transparentBorderImage = borderSize ? [croppedImage transparentBorderImage:borderSize] : croppedImage; 51 | 52 | return [transparentBorderImage roundedCornerImage:cornerRadius borderSize:borderSize]; 53 | } 54 | 55 | // Returns a rescaled copy of the image, taking into account its orientation 56 | // The image will be scaled disproportionately if necessary to fit the bounds specified by the parameter 57 | - (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality { 58 | BOOL drawTransposed; 59 | 60 | switch (self.imageOrientation) { 61 | case UIImageOrientationLeft: 62 | case UIImageOrientationLeftMirrored: 63 | case UIImageOrientationRight: 64 | case UIImageOrientationRightMirrored: 65 | drawTransposed = YES; 66 | break; 67 | 68 | default: 69 | drawTransposed = NO; 70 | } 71 | 72 | return [self resizedImage:newSize 73 | transform:[self transformForOrientation:newSize] 74 | drawTransposed:drawTransposed 75 | interpolationQuality:quality]; 76 | } 77 | 78 | // Resizes the image according to the given content mode, taking into account the image's orientation 79 | - (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode 80 | bounds:(CGSize)bounds 81 | interpolationQuality:(CGInterpolationQuality)quality { 82 | CGFloat horizontalRatio = bounds.width / self.size.width; 83 | CGFloat verticalRatio = bounds.height / self.size.height; 84 | CGFloat ratio; 85 | 86 | switch (contentMode) { 87 | case UIViewContentModeScaleAspectFill: 88 | ratio = MAX(horizontalRatio, verticalRatio); 89 | break; 90 | 91 | case UIViewContentModeScaleAspectFit: 92 | ratio = MIN(horizontalRatio, verticalRatio); 93 | break; 94 | 95 | default: 96 | [NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %d", contentMode]; 97 | } 98 | 99 | CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio); 100 | 101 | return [self resizedImage:newSize interpolationQuality:quality]; 102 | } 103 | 104 | #pragma mark - 105 | #pragma mark Private helper methods 106 | 107 | // Returns a copy of the image that has been transformed using the given affine transform and scaled to the new size 108 | // The new image's orientation will be UIImageOrientationUp, regardless of the current image's orientation 109 | // If the new size is not integral, it will be rounded up 110 | - (UIImage *)resizedImage:(CGSize)newSize 111 | transform:(CGAffineTransform)transform 112 | drawTransposed:(BOOL)transpose 113 | interpolationQuality:(CGInterpolationQuality)quality { 114 | CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height)); 115 | CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width); 116 | CGImageRef imageRef = self.CGImage; 117 | 118 | // Build a context that's the same dimensions as the new size 119 | CGContextRef bitmap = CGBitmapContextCreate(NULL, 120 | newRect.size.width, 121 | newRect.size.height, 122 | CGImageGetBitsPerComponent(imageRef), 123 | 0, 124 | CGImageGetColorSpace(imageRef), 125 | CGImageGetBitmapInfo(imageRef)); 126 | 127 | // Rotate and/or flip the image if required by its orientation 128 | CGContextConcatCTM(bitmap, transform); 129 | 130 | // Set the quality level to use when rescaling 131 | CGContextSetInterpolationQuality(bitmap, quality); 132 | 133 | // Draw into the context; this scales the image 134 | CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef); 135 | 136 | // Get the resized image from the context and a UIImage 137 | CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap); 138 | UIImage *newImage = [UIImage imageWithCGImage:newImageRef]; 139 | 140 | // Clean up 141 | CGContextRelease(bitmap); 142 | CGImageRelease(newImageRef); 143 | 144 | return newImage; 145 | } 146 | 147 | // Returns an affine transform that takes into account the image orientation when drawing a scaled image 148 | - (CGAffineTransform)transformForOrientation:(CGSize)newSize { 149 | CGAffineTransform transform = CGAffineTransformIdentity; 150 | 151 | switch (self.imageOrientation) { 152 | case UIImageOrientationDown: // EXIF = 3 153 | case UIImageOrientationDownMirrored: // EXIF = 4 154 | transform = CGAffineTransformTranslate(transform, newSize.width, newSize.height); 155 | transform = CGAffineTransformRotate(transform, M_PI); 156 | break; 157 | 158 | case UIImageOrientationLeft: // EXIF = 6 159 | case UIImageOrientationLeftMirrored: // EXIF = 5 160 | transform = CGAffineTransformTranslate(transform, newSize.width, 0); 161 | transform = CGAffineTransformRotate(transform, M_PI_2); 162 | break; 163 | 164 | case UIImageOrientationRight: // EXIF = 8 165 | case UIImageOrientationRightMirrored: // EXIF = 7 166 | transform = CGAffineTransformTranslate(transform, 0, newSize.height); 167 | transform = CGAffineTransformRotate(transform, -M_PI_2); 168 | break; 169 | case UIImageOrientationUp: 170 | case UIImageOrientationUpMirrored: 171 | break; 172 | } 173 | 174 | switch (self.imageOrientation) { 175 | case UIImageOrientationUpMirrored: // EXIF = 2 176 | case UIImageOrientationDownMirrored: // EXIF = 4 177 | transform = CGAffineTransformTranslate(transform, newSize.width, 0); 178 | transform = CGAffineTransformScale(transform, -1, 1); 179 | break; 180 | 181 | case UIImageOrientationLeftMirrored: // EXIF = 5 182 | case UIImageOrientationRightMirrored: // EXIF = 7 183 | transform = CGAffineTransformTranslate(transform, newSize.height, 0); 184 | transform = CGAffineTransformScale(transform, -1, 1); 185 | break; 186 | case UIImageOrientationUp: 187 | case UIImageOrientationLeft: 188 | case UIImageOrientationDown: 189 | case UIImageOrientationRight: 190 | break; 191 | } 192 | 193 | return transform; 194 | } 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | @interface UIImage (RoundedCorner) 8 | - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize; 9 | @end 10 | -------------------------------------------------------------------------------- /ImageFilterKit/External/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 | // Private helper methods 10 | @interface UIImage () 11 | - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight; 12 | @end 13 | 14 | @implementation UIImage (RoundedCorner) 15 | 16 | // Creates a copy of this image with rounded corners 17 | // If borderSize is non-zero, a transparent border of the given size will also be added 18 | // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ 19 | - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize { 20 | // If the image does not have an alpha layer, add one 21 | UIImage *image = [self imageWithAlpha]; 22 | 23 | // Build a context that's the same dimensions as the new size 24 | CGContextRef context = CGBitmapContextCreate(NULL, 25 | image.size.width, 26 | image.size.height, 27 | CGImageGetBitsPerComponent(image.CGImage), 28 | 0, 29 | CGImageGetColorSpace(image.CGImage), 30 | CGImageGetBitmapInfo(image.CGImage)); 31 | 32 | // Create a clipping path with rounded corners 33 | CGContextBeginPath(context); 34 | [self addRoundedRectToPath:CGRectMake(borderSize, borderSize, image.size.width - borderSize * 2, image.size.height - borderSize * 2) 35 | context:context 36 | ovalWidth:cornerSize 37 | ovalHeight:cornerSize]; 38 | CGContextClosePath(context); 39 | CGContextClip(context); 40 | 41 | // Draw the image to the context; the clipping path will make anything outside the rounded rect transparent 42 | CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage); 43 | 44 | // Create a CGImage from the context 45 | CGImageRef clippedImage = CGBitmapContextCreateImage(context); 46 | CGContextRelease(context); 47 | 48 | // Create a UIImage from the CGImage 49 | UIImage *roundedImage = [UIImage imageWithCGImage:clippedImage]; 50 | CGImageRelease(clippedImage); 51 | 52 | return roundedImage; 53 | } 54 | 55 | #pragma mark - 56 | #pragma mark Private helper methods 57 | 58 | // Adds a rectangular path to the given context and rounds its corners by the given extents 59 | // Original author: Björn Sållarp. Used with permission. See: http://blog.sallarp.com/iphone-uiimage-round-corners/ 60 | - (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight { 61 | if (ovalWidth == 0 || ovalHeight == 0) { 62 | CGContextAddRect(context, rect); 63 | return; 64 | } 65 | CGContextSaveGState(context); 66 | CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); 67 | CGContextScaleCTM(context, ovalWidth, ovalHeight); 68 | CGFloat fw = CGRectGetWidth(rect) / ovalWidth; 69 | CGFloat fh = CGRectGetHeight(rect) / ovalHeight; 70 | CGContextMoveToPoint(context, fw, fh/2); 71 | CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); 72 | CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); 73 | CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); 74 | CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); 75 | CGContextClosePath(context); 76 | CGContextRestoreGState(context); 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFBlurFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFBlurFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | @interface IFBlurFilter : IFFilter 13 | { 14 | 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFBlurFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFBlurFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFBlurFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFBlurFilter 14 | 15 | #define filterWidth 5 16 | #define filterHeight 5 17 | 18 | double blurFilter[filterWidth][filterHeight] = 19 | { 20 | 0, 0, 1, 0, 0, 21 | 0, 1, 2, 1, 0, 22 | 1, 2, 3, 2, 1, 23 | 0, 1, 2, 1, 0, 24 | 0, 0, 1, 0, 0, 25 | }; 26 | 27 | double blurFactor = 1.0 / 19.0; // The number of 1s in the matrix to make them all add up to 1. 28 | double blurBias = 0.0; 29 | 30 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 31 | { 32 | static IFColorRGB image[2000][2000]; 33 | static IFColorRGB result[2000][2000]; 34 | 35 | if(width > 2000) width = 2000; 36 | if(height > 2000) height = 2000; 37 | 38 | // Set the RGB values for the image matrix 39 | for(int x = 0; x < width; x++) 40 | { 41 | for(int y = 0; y < height; y++) 42 | { 43 | int r = bytes[4 * (x + (y * width)) + 1]; 44 | int g = bytes[4 * (x + (y * width)) + 2]; 45 | int b = bytes[4 * (x + (y * width)) + 3]; 46 | 47 | image[x][y] = IFColorRGBMake(r, g, b); 48 | result[x][y] = IFColorRGBMake(0, 0, 0); 49 | } 50 | } 51 | 52 | // Apply the blur filter 53 | for(int x = 0; x < width; x++) 54 | { 55 | for(int y = 0; y < height; y++) 56 | { 57 | double red = 0.0, green = 0.0, blue = 0.0; 58 | 59 | // Multiply every value of the filter with corresponding image pixel 60 | for(int filterX = 0; filterX < filterWidth; filterX++) 61 | { 62 | for(int filterY = 0; filterY < filterHeight; filterY++) 63 | { 64 | int imageX = (x - filterWidth / 2 + filterX + width) % width; 65 | int imageY = (y - filterHeight / 2 + filterY + height) % height; 66 | 67 | red += image[imageX][imageY].r * blurFilter[filterX][filterY]; 68 | green += image[imageX][imageY].g * blurFilter[filterX][filterY]; 69 | blue += image[imageX][imageY].b * blurFilter[filterX][filterY]; 70 | } 71 | } 72 | 73 | // Truncate values smaller than zero and larger than 255 74 | result[x][y].r = MIN(MAX(round(blurFactor * red + blurBias), 0), 255); 75 | result[x][y].g = MIN(MAX(round(blurFactor * green + blurBias), 0), 255); 76 | result[x][y].b = MIN(MAX(round(blurFactor * blue + blurBias), 0), 255); 77 | } 78 | } 79 | 80 | for(int x = 0; x < width; x++) 81 | { 82 | for(int y = 0; y < height; y++) 83 | { 84 | bytes[4 * (x + (y * width)) + 1] = result[x][y].r; 85 | bytes[4 * (x + (y * width)) + 2] = result[x][y].g; 86 | bytes[4 * (x + (y * width)) + 3] = result[x][y].b; 87 | } 88 | } 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFBrightnessFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFBrightnessFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | @interface IFBrightnessFilter : IFFilter 13 | { 14 | int brightnessAdjustment; 15 | } 16 | 17 | @property (nonatomic) int brightnessAdjustment; // Amount to adjust brightness. Negative values decrease brightness. 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFBrightnessFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFBrightnessFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFBrightnessFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFBrightnessFilter 14 | 15 | @synthesize brightnessAdjustment; 16 | 17 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 18 | { 19 | for(int i=0; i < length; i+=4) 20 | { 21 | // HSL works better for lightness than HSV 22 | IFColorRGB rgb = IFColorRGBMake(bytes[i+1], bytes[i+2], bytes[i+3]); 23 | IFColorHSL hsl = IFConvertRGBToHSL(rgb); 24 | 25 | hsl.l = MIN(MAX(0, hsl.l + brightnessAdjustment), 255); 26 | 27 | rgb = IFConvertHSLToRGB(hsl); 28 | 29 | bytes[i+1] = rgb.r; 30 | bytes[i+2] = rgb.g; 31 | bytes[i+3] = rgb.b; 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFColorConversions.c: -------------------------------------------------------------------------------- 1 | // 2 | // IFColorConversions.c 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #include "IFColorConversions.h" 10 | #include 11 | 12 | #if !defined(MIN) 13 | #define MIN(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) 14 | #endif 15 | 16 | #if !defined(MAX) 17 | #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) 18 | #endif 19 | 20 | IFColorRGB IFColorRGBMake(int r, int g, int b) 21 | { 22 | IFColorRGB color; 23 | color.r = r; 24 | color.g = g; 25 | color.b = b; 26 | 27 | return color; 28 | } 29 | 30 | // Conversions from RGB 31 | IFColorHSL IFConvertRGBToHSL(IFColorRGB rgb) 32 | { 33 | IFColorHSL hsl; 34 | 35 | float r, g, b, h, s, l; 36 | r = rgb.r / 256.0; 37 | g = rgb.g / 256.0; 38 | b = rgb.b / 256.0; 39 | 40 | float maxColor = MAX(r, MAX(g, b)); 41 | float minColor = MIN(r, MIN(g, b)); 42 | 43 | if(maxColor == minColor) 44 | { 45 | // If max and min are equal, then the color is a shade of grey 46 | h = 0.0; 47 | s = 0.0; 48 | l = r; 49 | } 50 | else 51 | { 52 | l = (minColor + maxColor) / 2; 53 | 54 | if(l < 0.5) s = (maxColor - minColor) / (maxColor + minColor); 55 | else s = (maxColor - minColor) / (2.0 - maxColor - minColor); 56 | 57 | if(r == maxColor) h = (g - b) / (maxColor - minColor); 58 | else if(g == maxColor) h = 2.0 + (b - r) / (maxColor - minColor); 59 | else h = 4.0 + (r - g) / (maxColor - minColor); 60 | 61 | h /= 6; 62 | if(h < 0) h ++; 63 | } 64 | 65 | hsl.h = round(h * 255.0); 66 | hsl.s = round(s * 255.0); 67 | hsl.l = round(l * 255.0); 68 | 69 | return hsl; 70 | } 71 | 72 | IFColorHSV IFConvertRGBToHSV(IFColorRGB rgb) 73 | { 74 | IFColorHSV hsv; 75 | 76 | float r, g, b, h, s, v; 77 | r = rgb.r / 256.0; 78 | g = rgb.g / 256.0; 79 | b = rgb.b / 256.0; 80 | float maxColor = MAX(r, MAX(g, b)); 81 | float minColor = MIN(r, MIN(g, b)); 82 | v = maxColor; 83 | 84 | if(maxColor == 0) 85 | { 86 | s = 0; 87 | } 88 | else 89 | { 90 | s = (maxColor - minColor) / maxColor; 91 | } 92 | 93 | if(s == 0) 94 | { 95 | h = 0; 96 | } 97 | else 98 | { 99 | if(r == maxColor) h = (g - b) / (maxColor-minColor); 100 | else if(g == maxColor) h = 2.0 + (b - r) / (maxColor - minColor); 101 | else h = 4.0 + (r - g) / (maxColor - minColor); 102 | h /= 6.0; 103 | if (h < 0) h++; 104 | } 105 | 106 | hsv.h = round(h * 255.0); 107 | hsv.s = round(s * 255.0); 108 | hsv.v = round(v * 255.0); 109 | 110 | return hsv; 111 | } 112 | 113 | // Conversions to RGB 114 | IFColorRGB IFConvertHSLToRGB(IFColorHSL hsl) 115 | { 116 | IFColorRGB rgb; 117 | 118 | float r, g, b, h, s, l; 119 | float temp1, temp2, tempr, tempg, tempb; 120 | h = hsl.h / 256.0; 121 | s = hsl.s / 256.0; 122 | l = hsl.l / 256.0; 123 | 124 | // If saturation is 0, the color is a shade of gray 125 | if(s == 0) 126 | { 127 | r = g = b = l; 128 | } 129 | else 130 | { 131 | //Set the temporary values 132 | if(l < 0.5) temp2 = l * (1 + s); 133 | else temp2 = (l + s) - (l * s); 134 | temp1 = 2 * l - temp2; 135 | tempr = h + 1.0 / 3.0; 136 | if(tempr > 1) tempr--; 137 | tempg = h; 138 | tempb = h - 1.0 / 3.0; 139 | if(tempb < 0) tempb++; 140 | 141 | //Red 142 | if(tempr < 1.0 / 6.0) r = temp1 + (temp2 - temp1) * 6.0 * tempr; 143 | else if(tempr < 0.5) r = temp2; 144 | else if(tempr < 2.0 / 3.0) r = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempr) * 6.0; 145 | else r = temp1; 146 | 147 | //Green 148 | if(tempg < 1.0 / 6.0) g = temp1 + (temp2 - temp1) * 6.0 * tempg; 149 | else if(tempg < 0.5) g = temp2; 150 | else if(tempg < 2.0 / 3.0) g = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempg) * 6.0; 151 | else g = temp1; 152 | 153 | //Blue 154 | if(tempb < 1.0 / 6.0) b = temp1 + (temp2 - temp1) * 6.0 * tempb; 155 | else if(tempb < 0.5) b = temp2; 156 | else if(tempb < 2.0 / 3.0) b = temp1 + (temp2 - temp1) * ((2.0 / 3.0) - tempb) * 6.0; 157 | else b = temp1; 158 | } 159 | 160 | rgb.r = round(r * 255.0); 161 | rgb.g = round(g * 255.0); 162 | rgb.b = round(b * 255.0); 163 | 164 | return rgb; 165 | } 166 | 167 | IFColorRGB IFConvertHSVToRGB(IFColorHSV hsv) 168 | { 169 | IFColorRGB rgb; 170 | 171 | float r, g, b, h, s, v; 172 | h = hsv.h / 256.0; 173 | s = hsv.s / 256.0; 174 | v = hsv.v / 256.0; 175 | 176 | //If saturation is 0, the color is a shade of gray 177 | if(s == 0) 178 | { 179 | r = g = b = v; 180 | } 181 | else 182 | { 183 | float f, p, q, t; 184 | int i; 185 | h *= 6; 186 | i = floor(h); 187 | f = h - i; 188 | p = v * (1 - s); 189 | q = v * (1 - (s * f)); 190 | t = v * (1 - (s * (1 - f))); 191 | 192 | switch(i) 193 | { 194 | case 0: r = v; g = t; b = p; break; 195 | case 1: r = q; g = v; b = p; break; 196 | case 2: r = p; g = v; b = t; break; 197 | case 3: r = p; g = q; b = v; break; 198 | case 4: r = t; g = p; b = v; break; 199 | case 5: r = v; g = p; b = q; break; 200 | } 201 | } 202 | 203 | rgb.r = round(r * 255.0); 204 | rgb.g = round(g * 255.0); 205 | rgb.b = round(b * 255.0); 206 | 207 | return rgb; 208 | } -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFColorConversions.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFColorConversions.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | struct IFColorRGB 10 | { 11 | int r; 12 | int g; 13 | int b; 14 | }; 15 | typedef struct IFColorRGB IFColorRGB; 16 | 17 | struct IFColorHSL 18 | { 19 | int h; 20 | int s; 21 | int l; 22 | }; 23 | typedef struct IFColorHSL IFColorHSL; 24 | 25 | struct IFColorHSV 26 | { 27 | int h; 28 | int s; 29 | int v; 30 | }; 31 | typedef struct IFColorHSV IFColorHSV; 32 | 33 | IFColorRGB IFColorRGBMake(int r, int g, int b); 34 | 35 | // Conversions from RGB 36 | IFColorHSL IFConvertRGBToHSL(IFColorRGB rgb); 37 | IFColorHSV IFConvertRGBToHSV(IFColorRGB rgb); 38 | 39 | // Conversions to RGB 40 | IFColorRGB IFConvertHSLToRGB(IFColorHSL hsl); 41 | IFColorRGB IFConvertHSVToRGB(IFColorHSV hsv); -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFEmbossFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFEmbossFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFEmbossFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFEmbossFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFEmbossFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFEmbossFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFEmbossFilter 14 | 15 | #define filterWidth 3 16 | #define filterHeight 3 17 | 18 | double embossFilter[filterWidth][filterHeight] = 19 | { 20 | -1, 0, -1, 21 | 0, 4, 0, 22 | -1, 0, -1 23 | }; 24 | 25 | double embossFactor = 1.0; 26 | double embossBias = 127.0; 27 | 28 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 29 | { 30 | static IFColorRGB image[2000][2000]; 31 | static IFColorRGB result[2000][2000]; 32 | 33 | if(width > 2000) width = 2000; 34 | if(height > 2000) height = 2000; 35 | 36 | // Set the RGB values for the image matrix 37 | for(int x = 0; x < width; x++) 38 | { 39 | for(int y = 0; y < height; y++) 40 | { 41 | int r = bytes[4 * (x + (y * width)) + 1]; 42 | int g = bytes[4 * (x + (y * width)) + 2]; 43 | int b = bytes[4 * (x + (y * width)) + 3]; 44 | 45 | image[x][y] = IFColorRGBMake(r, g, b); 46 | result[x][y] = IFColorRGBMake(0, 0, 0); 47 | } 48 | } 49 | 50 | // Apply the blur filter 51 | for(int x = 0; x < width; x++) 52 | { 53 | for(int y = 0; y < height; y++) 54 | { 55 | double red = 0.0, green = 0.0, blue = 0.0; 56 | 57 | // Multiply every value of the filter with corresponding image pixel 58 | for(int filterX = 0; filterX < filterWidth; filterX++) 59 | { 60 | for(int filterY = 0; filterY < filterHeight; filterY++) 61 | { 62 | int imageX = (x - filterWidth / 2 + filterX + width) % width; 63 | int imageY = (y - filterHeight / 2 + filterY + height) % height; 64 | 65 | red += image[imageX][imageY].r * embossFilter[filterX][filterY]; 66 | green += image[imageX][imageY].g * embossFilter[filterX][filterY]; 67 | blue += image[imageX][imageY].b * embossFilter[filterX][filterY]; 68 | } 69 | } 70 | 71 | // Truncate values smaller than zero and larger than 255 72 | result[x][y].r = MIN(MAX(round(embossFactor * red + embossBias), 0), 255); 73 | result[x][y].g = MIN(MAX(round(embossFactor * green + embossBias), 0), 255); 74 | result[x][y].b = MIN(MAX(round(embossFactor * blue + embossBias), 0), 255); 75 | } 76 | } 77 | 78 | for(int x = 0; x < width; x++) 79 | { 80 | for(int y = 0; y < height; y++) 81 | { 82 | bytes[4 * (x + (y * width)) + 1] = result[x][y].r; 83 | bytes[4 * (x + (y * width)) + 2] = result[x][y].g; 84 | bytes[4 * (x + (y * width)) + 3] = result[x][y].b; 85 | } 86 | } 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol IFFilterDelegate 12 | 13 | - (void) filterDidApplyWithResult:(UIImage *)result; 14 | 15 | @end 16 | 17 | @interface IFFilter : NSObject 18 | { 19 | UIImage *originalImage; 20 | id delegate; 21 | NSOperationQueue *operationQueue; 22 | } 23 | 24 | @property (nonatomic, retain) UIImage *originalImage; 25 | @property (nonatomic, assign) id delegate; 26 | 27 | - (id) initWithOriginalImage:(UIImage *)image; 28 | 29 | // Main methods 30 | - (UIImage *) imageWithFilterApplied; 31 | - (void) applyFilterOnNewThread; 32 | 33 | // Override these methods in filter implementations 34 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height; 35 | - (UIImage *) imageWithPostProcessedFilter:(UIImage *)processedImage; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFFilter.h" 10 | #import "UIImage+RawData.h" 11 | #import "IFFilterOperation.h" 12 | 13 | 14 | @implementation IFFilter 15 | 16 | @synthesize originalImage, delegate; 17 | 18 | #pragma mark - Initialization 19 | 20 | - (id) initWithOriginalImage:(UIImage *)image 21 | { 22 | self = [super init]; 23 | if(self) 24 | { 25 | self.originalImage = image; 26 | operationQueue = [[NSOperationQueue alloc] init]; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | #pragma mark - Image Processing 33 | 34 | - (UIImage *) imageWithFilterApplied 35 | { 36 | NSData *rawData = [originalImage rawImageData]; 37 | [self manipulateRawBytes:(UInt8 *)[rawData bytes] length:[rawData length] width:self.originalImage.size.width height:self.originalImage.size.height]; 38 | UIImage *processedImage = [UIImage imageWithRawImageData:rawData width:self.originalImage.size.width height:self.originalImage.size.height]; 39 | UIImage *postProcessedImage = [self imageWithPostProcessedFilter:processedImage]; 40 | 41 | return postProcessedImage; 42 | } 43 | 44 | - (void) applyFilterOnNewThread 45 | { 46 | IFFilterOperation *operation = [[IFFilterOperation alloc] init]; 47 | operation.delegate = delegate; 48 | operation.filter = self; 49 | 50 | [operationQueue addOperation:operation]; 51 | [operation release]; 52 | } 53 | 54 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 55 | { 56 | // Do nothing in base implementation 57 | } 58 | 59 | - (UIImage *) imageWithPostProcessedFilter:(UIImage *)processedImage 60 | { 61 | return processedImage; 62 | } 63 | 64 | #pragma mark - Cleanup 65 | 66 | - (void) dealloc 67 | { 68 | delegate = nil; 69 | [operationQueue release]; 70 | [originalImage release]; 71 | [super dealloc]; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFilterOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilterOperation.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFFilterOperation : NSOperation 14 | { 15 | IFFilter *filter; 16 | NSObject *delegate; 17 | } 18 | 19 | @property (nonatomic, retain) IFFilter *filter; 20 | @property (nonatomic, assign) NSObject *delegate; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFilterOperation.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilterOperation.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFFilterOperation.h" 10 | 11 | 12 | @implementation IFFilterOperation 13 | 14 | @synthesize filter, delegate; 15 | 16 | - (void)main 17 | { 18 | UIImage *image = [filter imageWithFilterApplied]; 19 | [delegate performSelectorOnMainThread:@selector(filterDidApplyWithResult:) withObject:image waitUntilDone:NO]; 20 | } 21 | 22 | - (void) dealloc 23 | { 24 | delegate = nil; 25 | [filter release]; 26 | [super dealloc]; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFindEdgesFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFFindEdgesFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFFindEdgesFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFFindEdgesFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFFindEdgesFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFFindEdgesFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | @implementation IFFindEdgesFilter 13 | 14 | #define filterWidth 3 15 | #define filterHeight 3 16 | 17 | // Find edges in all directions 18 | /* 19 | double edgesFilter[filterWidth][filterHeight] = 20 | { 21 | 1, 1, 1, 22 | 1, -7, 1, 23 | 1, 1, 1 24 | }; 25 | */ 26 | 27 | // Note: There are a number of different edge detection matrices we can use here. 28 | double edgesFilter[filterWidth][filterHeight] = 29 | { 30 | 1, 1, 1, 31 | 0, 0, 0, 32 | -1, -1, -1 33 | }; 34 | 35 | double edgesFactor = 1.0; 36 | double edgesBias = 127.0; 37 | 38 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 39 | { 40 | static IFColorRGB image[2000][2000]; 41 | static IFColorRGB result[2000][2000]; 42 | 43 | if(width > 2000) width = 2000; 44 | if(height > 2000) height = 2000; 45 | 46 | // Set the RGB values for the image matrix 47 | for(int x = 0; x < width; x++) 48 | { 49 | for(int y = 0; y < height; y++) 50 | { 51 | int r = bytes[4 * (x + (y * width)) + 1]; 52 | int g = bytes[4 * (x + (y * width)) + 2]; 53 | int b = bytes[4 * (x + (y * width)) + 3]; 54 | 55 | image[x][y] = IFColorRGBMake(r, g, b); 56 | result[x][y] = IFColorRGBMake(0, 0, 0); 57 | } 58 | } 59 | 60 | // Apply the blur filter 61 | for(int x = 0; x < width; x++) 62 | { 63 | for(int y = 0; y < height; y++) 64 | { 65 | double red = 0.0, green = 0.0, blue = 0.0; 66 | 67 | // Multiply every value of the filter with corresponding image pixel 68 | for(int filterX = 0; filterX < filterWidth; filterX++) 69 | { 70 | for(int filterY = 0; filterY < filterHeight; filterY++) 71 | { 72 | int imageX = (x - filterWidth / 2 + filterX + width) % width; 73 | int imageY = (y - filterHeight / 2 + filterY + height) % height; 74 | 75 | red += image[imageX][imageY].r * edgesFilter[filterX][filterY]; 76 | green += image[imageX][imageY].g * edgesFilter[filterX][filterY]; 77 | blue += image[imageX][imageY].b * edgesFilter[filterX][filterY]; 78 | } 79 | } 80 | 81 | // Truncate values smaller than zero and larger than 255 82 | result[x][y].r = MIN(MAX(round(edgesFactor * red + edgesBias), 0), 255); 83 | result[x][y].g = MIN(MAX(round(edgesFactor * green + edgesBias), 0), 255); 84 | result[x][y].b = MIN(MAX(round(edgesFactor * blue + edgesBias), 0), 255); 85 | } 86 | } 87 | 88 | for(int x = 0; x < width; x++) 89 | { 90 | for(int y = 0; y < height; y++) 91 | { 92 | bytes[4 * (x + (y * width)) + 1] = result[x][y].r; 93 | bytes[4 * (x + (y * width)) + 2] = result[x][y].g; 94 | bytes[4 * (x + (y * width)) + 3] = result[x][y].b; 95 | } 96 | } 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFGreyscaleFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFGreyscaleFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFGreyscaleFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFGreyscaleFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFGreyscaleFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFGreyscaleFilter.h" 10 | 11 | 12 | @implementation IFGreyscaleFilter 13 | 14 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 15 | { 16 | for(int i=0; i < length; i+=4) 17 | { 18 | int averageColor = round((bytes[i+1] + bytes[i+2] + bytes[i+3]) / 3); 19 | bytes[i+1] = averageColor; 20 | bytes[i+2] = averageColor; 21 | bytes[i+3] = averageColor; 22 | } 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFHueFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFHueFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFHueFilter : IFFilter 14 | { 15 | int hueAdjustment; 16 | } 17 | 18 | @property (nonatomic) int hueAdjustment; // The amount to adjust in degrees. 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFHueFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFHueFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFHueFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFHueFilter 14 | 15 | @synthesize hueAdjustment; 16 | 17 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 18 | { 19 | for(int i=0; i < length; i+=4) 20 | { 21 | IFColorRGB rgb = IFColorRGBMake(bytes[i+1], bytes[i+2], bytes[i+3]); 22 | IFColorHSL hsl = IFConvertRGBToHSL(rgb); 23 | 24 | hsl.h = hsl.h + hueAdjustment; 25 | 26 | if(hsl.h > 360) hsl.h = hsl.h - 360; 27 | if(hsl.h < 0) hsl.h = hsl.h + 360; 28 | 29 | rgb = IFConvertHSLToRGB(hsl); 30 | 31 | bytes[i+1] = rgb.r; 32 | bytes[i+2] = rgb.g; 33 | bytes[i+3] = rgb.b; 34 | } 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFPixelationFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFPixelationFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFPixelationFilter : IFFilter 14 | { 15 | int pixelSize; 16 | } 17 | 18 | @property (nonatomic) int pixelSize; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFPixelationFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFPixelationFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFPixelationFilter.h" 10 | 11 | 12 | @implementation IFPixelationFilter 13 | 14 | @synthesize pixelSize; 15 | 16 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 17 | { 18 | if(pixelSize == 0) pixelSize = 10; 19 | 20 | for(int x = 0; x < width; x += pixelSize) 21 | { 22 | for(int y = 0; y < height; y += pixelSize) 23 | { 24 | int a = bytes[4 * (x + (y * width))]; 25 | int r = bytes[4 * (x + (y * width)) + 1]; 26 | int g = bytes[4 * (x + (y * width)) + 2]; 27 | int b = bytes[4 * (x + (y * width)) + 3]; 28 | 29 | for(int x2 = 0; x2 < pixelSize; x2++) 30 | { 31 | for(int y2 = 0; y2 < pixelSize; y2++) 32 | { 33 | int realX = x + x2; 34 | int realY = y + y2; 35 | if(realX < width && realY < height) 36 | { 37 | bytes[4 * (realX + (realY * width))] = a; 38 | bytes[4 * (realX + (realY * width)) + 1] = r; 39 | bytes[4 * (realX + (realY * width)) + 2] = g; 40 | bytes[4 * (realX + (realY * width)) + 3] = b; 41 | } 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSaturationFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFSaturationFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFSaturationFilter : IFFilter 14 | { 15 | int saturationAdjustment; 16 | } 17 | 18 | @property (nonatomic) int saturationAdjustment; // Amount to adjust saturation. Negative values decrease saturation. 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSaturationFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFSaturationFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFSaturationFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFSaturationFilter 14 | 15 | @synthesize saturationAdjustment; 16 | 17 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 18 | { 19 | for(int i=0; i < length; i+=4) 20 | { 21 | // Use the HSV color model, it works better with saturation than HSL 22 | IFColorRGB rgb = IFColorRGBMake(bytes[i+1], bytes[i+2], bytes[i+3]); 23 | IFColorHSV hsv = IFConvertRGBToHSV(rgb); 24 | 25 | hsv.s = MIN(MAX(0, hsv.s + saturationAdjustment), 255); 26 | 27 | rgb = IFConvertHSVToRGB(hsv); 28 | 29 | bytes[i+1] = rgb.r; 30 | bytes[i+2] = rgb.g; 31 | bytes[i+3] = rgb.b; 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSharpenFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFSharpenFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFSharpenFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSharpenFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFSharpenFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/30/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFSharpenFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFSharpenFilter 14 | 15 | #define filterWidth 3 16 | #define filterHeight 3 17 | 18 | double sharpenFilter[filterWidth][filterHeight] = 19 | { 20 | 0, -2, 0, 21 | -2, 11, -2, 22 | 0, -2, 0 23 | }; 24 | 25 | double sharpenFactor = 1.0 / 3.0; 26 | double sharpenBias = 0.0; 27 | 28 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 29 | { 30 | static IFColorRGB image[2000][2000]; 31 | static IFColorRGB result[2000][2000]; 32 | 33 | if(width > 2000) width = 2000; 34 | if(height > 2000) height = 2000; 35 | 36 | // Set the RGB values for the image matrix 37 | for(int x = 0; x < width; x++) 38 | { 39 | for(int y = 0; y < height; y++) 40 | { 41 | int r = bytes[4 * (x + (y * width)) + 1]; 42 | int g = bytes[4 * (x + (y * width)) + 2]; 43 | int b = bytes[4 * (x + (y * width)) + 3]; 44 | 45 | image[x][y] = IFColorRGBMake(r, g, b); 46 | result[x][y] = IFColorRGBMake(0, 0, 0); 47 | } 48 | } 49 | 50 | // Apply the blur filter 51 | for(int x = 0; x < width; x++) 52 | { 53 | for(int y = 0; y < height; y++) 54 | { 55 | double red = 0.0, green = 0.0, blue = 0.0; 56 | 57 | // Multiply every value of the filter with corresponding image pixel 58 | for(int filterX = 0; filterX < filterWidth; filterX++) 59 | { 60 | for(int filterY = 0; filterY < filterHeight; filterY++) 61 | { 62 | int imageX = (x - filterWidth / 2 + filterX + width) % width; 63 | int imageY = (y - filterHeight / 2 + filterY + height) % height; 64 | 65 | red += image[imageX][imageY].r * sharpenFilter[filterX][filterY]; 66 | green += image[imageX][imageY].g * sharpenFilter[filterX][filterY]; 67 | blue += image[imageX][imageY].b * sharpenFilter[filterX][filterY]; 68 | } 69 | } 70 | 71 | // Truncate values smaller than zero and larger than 255 72 | result[x][y].r = MIN(MAX(round(sharpenFactor * red + sharpenBias), 0), 255); 73 | result[x][y].g = MIN(MAX(round(sharpenFactor * green + sharpenBias), 0), 255); 74 | result[x][y].b = MIN(MAX(round(sharpenFactor * blue + sharpenBias), 0), 255); 75 | } 76 | } 77 | 78 | for(int x = 0; x < width; x++) 79 | { 80 | for(int y = 0; y < height; y++) 81 | { 82 | bytes[4 * (x + (y * width)) + 1] = result[x][y].r; 83 | bytes[4 * (x + (y * width)) + 2] = result[x][y].g; 84 | bytes[4 * (x + (y * width)) + 3] = result[x][y].b; 85 | } 86 | } 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSimpleTintFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFSimpleTintFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFSimpleTintFilter : IFFilter 14 | { 15 | UIColor *tintColor; 16 | } 17 | 18 | @property (nonatomic, retain) UIColor *tintColor; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSimpleTintFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFSimpleTintFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFSimpleTintFilter.h" 10 | 11 | 12 | @implementation IFSimpleTintFilter 13 | 14 | @synthesize tintColor; 15 | 16 | - (UIImage *) imageWithPostProcessedFilter:(UIImage *)processedImage 17 | { 18 | if(!tintColor) return processedImage; 19 | 20 | // Construct new image the same size as this one. 21 | UIImage *image; 22 | UIGraphicsBeginImageContextWithOptions(processedImage.size, NO, 0.0); 23 | CGRect rect = CGRectZero; 24 | rect.size = processedImage.size; 25 | 26 | // Tint the image 27 | [processedImage drawInRect:rect]; 28 | [tintColor set]; 29 | UIRectFillUsingBlendMode(rect, kCGBlendModeColor); 30 | 31 | // Restore alpha channel 32 | [processedImage drawInRect:rect blendMode:kCGBlendModeDestinationIn alpha:1.0f]; 33 | 34 | image = UIGraphicsGetImageFromCurrentImageContext(); 35 | UIGraphicsEndImageContext(); 36 | 37 | return image; 38 | } 39 | 40 | - (void) dealloc 41 | { 42 | [tintColor release]; 43 | [super dealloc]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSnowFuzzFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFAcidFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFSnowFuzzFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFSnowFuzzFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFAcidFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFSnowFuzzFilter.h" 10 | 11 | 12 | @implementation IFSnowFuzzFilter 13 | 14 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 15 | { 16 | for(int i=0; i < length; i+=4) 17 | { 18 | float sine = sin(i); 19 | 20 | bytes[i+1] = MAX(0, MIN(255, bytes[i+1] + round(255 * sin(bytes[i+1]) * sine))); 21 | bytes[i+2] = MAX(0, MIN(255, bytes[i+2] + round(255 * sin(bytes[i+1]) * sine))); 22 | bytes[i+3] = MAX(0, MIN(255, bytes[i+3] + round(255 * sin(bytes[i+1]) * sine))); 23 | } 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFThermalFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFThermalFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFThermalFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFThermalFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFThermalFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFThermalFilter.h" 10 | 11 | 12 | @implementation IFThermalFilter 13 | 14 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 15 | { 16 | for(int i=0; i < length; i+=4) 17 | { 18 | int totalBrightness = bytes[i+1] + bytes[i+2] + bytes[i+3]; 19 | int averageBrightness = round(totalBrightness / 3); 20 | 21 | if(averageBrightness > 127) 22 | { 23 | bytes[i+1] = MIN(255, MAX(0, bytes[i+1] + (averageBrightness-127))); 24 | bytes[i+2] = (averageBrightness - 127); 25 | bytes[i+3] = 0; 26 | } 27 | else 28 | { 29 | bytes[i+1] = 0; 30 | bytes[i+2] = averageBrightness; 31 | bytes[i+3] = MIN(255, MAX(0, bytes[i+3] + (127-averageBrightness))); 32 | } 33 | } 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFTiltShiftFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFTiltShiftFilter.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 4/6/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | 13 | @interface IFTiltShiftFilter : IFFilter 14 | { 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ImageFilterKit/Filters/IFTiltShiftFilter.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFTiltShiftFilter.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 4/6/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFTiltShiftFilter.h" 10 | #import "IFColorConversions.h" 11 | 12 | 13 | @implementation IFTiltShiftFilter 14 | 15 | #define largeBlurSize 7 16 | 17 | double largeBlur[largeBlurSize][largeBlurSize] = 18 | { 19 | 0, 0, 0, 2, 0, 0, 0, 20 | 0, 0, 2, 4, 2, 0, 0, 21 | 0, 2, 4, 6, 4, 2, 0, 22 | 2, 4, 6, 8, 6, 3, 2, 23 | 0, 2, 4, 6, 4, 2, 0, 24 | 0, 0, 2, 4, 2, 0, 0, 25 | 0, 0, 0, 2, 0, 0, 0, 26 | }; 27 | 28 | double largeBlurFactor = 1.0 / 88.0; // The number of 1s in the matrix to make them all add up to 1. 29 | double largeBlurBias = 0.0; 30 | 31 | #define mediumBlurSize 5 32 | 33 | double mediumBlur[mediumBlurSize][mediumBlurSize] = 34 | { 35 | 0, 0, 2, 0, 0, 36 | 0, 2, 4, 2, 0, 37 | 2, 4, 6, 4, 2, 38 | 0, 2, 4, 2, 0, 39 | 0, 0, 2, 0, 0, 40 | }; 41 | 42 | double mediumBlurFactor = 1.0 / 38.0; // The number of 1s in the matrix to make them all add up to 1. 43 | double mediumBlurBias = 0.0; 44 | 45 | #define smallBlurSize 3 46 | 47 | double smallBlur[smallBlurSize][smallBlurSize] = 48 | { 49 | 0, 1, 0, 50 | 1, 2, 1, 51 | 0, 1, 0, 52 | }; 53 | 54 | double smallBlurFactor = 1.0 / 6.0; // The number of 1s in the matrix to make them all add up to 1. 55 | double smallBlurBias = 0.0; 56 | 57 | - (void) manipulateRawBytes:(UInt8 *)bytes length:(int)length width:(int)width height:(int)height 58 | { 59 | static IFColorRGB image[2000][2000]; 60 | static IFColorRGB result[2000][2000]; 61 | 62 | if(width > 2000) width = 2000; 63 | if(height > 2000) height = 2000; 64 | 65 | // Set the RGB values for the image matrix 66 | for(int x = 0; x < width; x++) 67 | { 68 | for(int y = 0; y < height; y++) 69 | { 70 | int r = bytes[4 * (x + (y * width)) + 1]; 71 | int g = bytes[4 * (x + (y * width)) + 2]; 72 | int b = bytes[4 * (x + (y * width)) + 3]; 73 | 74 | image[x][y] = IFColorRGBMake(r, g, b); 75 | result[x][y] = IFColorRGBMake(0, 0, 0); 76 | } 77 | } 78 | 79 | // Apply the blur filter 80 | for(int x = 0; x < width; x++) 81 | { 82 | for(int y = 0; y < height; y++) 83 | { 84 | double red = 0.0, green = 0.0, blue = 0.0; 85 | 86 | // Check which sized filter to use 87 | if((x < (width/7) || x > (width - (width/7))) || (y < (height/7) || y > (height - (height/7)))) 88 | { 89 | // Use the largest blur 90 | 91 | // Multiply every value of the filter with corresponding image pixel 92 | for(int filterX = 0; filterX < largeBlurSize; filterX++) 93 | { 94 | for(int filterY = 0; filterY < largeBlurSize; filterY++) 95 | { 96 | int imageX = (x - largeBlurSize / 2 + filterX + width) % width; 97 | int imageY = (y - largeBlurSize / 2 + filterY + height) % height; 98 | 99 | red += image[imageX][imageY].r * largeBlur[filterX][filterY]; 100 | green += image[imageX][imageY].g * largeBlur[filterX][filterY]; 101 | blue += image[imageX][imageY].b * largeBlur[filterX][filterY]; 102 | } 103 | } 104 | 105 | // Truncate values smaller than zero and larger than 255 106 | result[x][y].r = MIN(MAX(round(largeBlurFactor * red + largeBlurBias), 0), 255); 107 | result[x][y].g = MIN(MAX(round(largeBlurFactor * green + largeBlurBias), 0), 255); 108 | result[x][y].b = MIN(MAX(round(largeBlurFactor * blue + largeBlurBias), 0), 255); 109 | } 110 | else if((x < (width/7)*2 || x > (width - (width/7)*2)) || (y < (height/7)*2 || y > (height - (height/7)*2))) 111 | { 112 | // Use the medium blur 113 | 114 | // Multiply every value of the filter with corresponding image pixel 115 | for(int filterX = 0; filterX < mediumBlurSize; filterX++) 116 | { 117 | for(int filterY = 0; filterY < mediumBlurSize; filterY++) 118 | { 119 | int imageX = (x - mediumBlurSize / 2 + filterX + width) % width; 120 | int imageY = (y - mediumBlurSize / 2 + filterY + height) % height; 121 | 122 | red += image[imageX][imageY].r * mediumBlur[filterX][filterY]; 123 | green += image[imageX][imageY].g * mediumBlur[filterX][filterY]; 124 | blue += image[imageX][imageY].b * mediumBlur[filterX][filterY]; 125 | } 126 | } 127 | 128 | // Truncate values smaller than zero and larger than 255 129 | result[x][y].r = MIN(MAX(round(mediumBlurFactor * red + mediumBlurBias), 0), 255); 130 | result[x][y].g = MIN(MAX(round(mediumBlurFactor * green + mediumBlurBias), 0), 255); 131 | result[x][y].b = MIN(MAX(round(mediumBlurFactor * blue + mediumBlurBias), 0), 255); 132 | } 133 | else if((x < (width/7)*3 || x > (width - (width/7)*3)) || (y < (height/7)*3 || y > (height - (height/7)*3))) 134 | { 135 | // Use the small blur 136 | 137 | // Multiply every value of the filter with corresponding image pixel 138 | for(int filterX = 0; filterX < smallBlurSize; filterX++) 139 | { 140 | for(int filterY = 0; filterY < smallBlurSize; filterY++) 141 | { 142 | int imageX = (x - smallBlurSize / 2 + filterX + width) % width; 143 | int imageY = (y - smallBlurSize / 2 + filterY + height) % height; 144 | 145 | red += image[imageX][imageY].r * smallBlur[filterX][filterY]; 146 | green += image[imageX][imageY].g * smallBlur[filterX][filterY]; 147 | blue += image[imageX][imageY].b * smallBlur[filterX][filterY]; 148 | } 149 | } 150 | 151 | // Truncate values smaller than zero and larger than 255 152 | result[x][y].r = MIN(MAX(round(smallBlurFactor * red + smallBlurBias), 0), 255); 153 | result[x][y].g = MIN(MAX(round(smallBlurFactor * green + smallBlurBias), 0), 255); 154 | result[x][y].b = MIN(MAX(round(smallBlurFactor * blue + smallBlurBias), 0), 255); 155 | } 156 | else 157 | { 158 | // Identity 159 | result[x][y].r = image[x][y].r; 160 | result[x][y].g = image[x][y].g; 161 | result[x][y].b = image[x][y].b; 162 | } 163 | } 164 | } 165 | 166 | for(int x = 0; x < width; x++) 167 | { 168 | for(int y = 0; y < height; y++) 169 | { 170 | bytes[4 * (x + (y * width)) + 1] = result[x][y].r; 171 | bytes[4 * (x + (y * width)) + 2] = result[x][y].g; 172 | bytes[4 * (x + (y * width)) + 3] = result[x][y].b; 173 | } 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /ImageFilterKit/ImageFilterKit-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | net.roozy.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ImageFilterKit/ImageFilterKit-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ImageFilterKit' target in the 'ImageFilterKit' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /ImageFilterKit/ImageFilterKitAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilterKitAppDelegate.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFPhotoSelectionViewController.h" 11 | 12 | @interface ImageFilterKitAppDelegate : NSObject 13 | { 14 | UINavigationController *navigationController; 15 | IFPhotoSelectionViewController *photoSelectionViewController; 16 | } 17 | 18 | @property (nonatomic, retain) IBOutlet UIWindow *window; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/ImageFilterKitAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageFilterKitAppDelegate.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "ImageFilterKitAppDelegate.h" 10 | 11 | @implementation ImageFilterKitAppDelegate 12 | 13 | @synthesize window=_window; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | photoSelectionViewController = [[IFPhotoSelectionViewController alloc] init]; 18 | navigationController = [[UINavigationController alloc] initWithRootViewController:photoSelectionViewController]; 19 | [self.window addSubview:navigationController.view]; 20 | 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | /* 28 | 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. 29 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | */ 31 | } 32 | 33 | - (void)applicationDidEnterBackground:(UIApplication *)application 34 | { 35 | /* 36 | 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. 37 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | */ 39 | } 40 | 41 | - (void)applicationWillEnterForeground:(UIApplication *)application 42 | { 43 | /* 44 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 45 | */ 46 | } 47 | 48 | - (void)applicationDidBecomeActive:(UIApplication *)application 49 | { 50 | /* 51 | 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. 52 | */ 53 | } 54 | 55 | - (void)applicationWillTerminate:(UIApplication *)application 56 | { 57 | /* 58 | Called when the application is about to terminate. 59 | Save data if appropriate. 60 | See also applicationDidEnterBackground:. 61 | */ 62 | } 63 | 64 | - (void)dealloc 65 | { 66 | [photoSelectionViewController release]; 67 | [navigationController release]; 68 | [_window release]; 69 | [super dealloc]; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFFilterPreviewViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilterPreviewViewController.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IFFilter.h" 11 | 12 | enum 13 | { 14 | IFFilterPreviewSliderModePixelate = 0, 15 | IFFilterPreviewSliderModeBrightness = 1, 16 | IFFilterPreviewSliderModeSaturation = 2, 17 | IFFilterPreviewSliderModeHue = 3 18 | } IFFilterPreviewSliderMode; 19 | 20 | @interface IFFilterPreviewViewController : UIViewController 21 | { 22 | UIImage *originalImage; 23 | 24 | IBOutlet UISlider *slider; 25 | IBOutlet UIImageView *imageView; 26 | IBOutlet UIView *activityView; 27 | 28 | int sliderMode; 29 | } 30 | 31 | @property (nonatomic, retain) UIImage *originalImage; 32 | 33 | - (void) openFilterOptions; 34 | - (IBAction) sliderMoved:(id)sender; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFFilterPreviewViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFFilterPreviewViewController.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFFilterPreviewViewController.h" 10 | #import "ImageFilterKitAppDelegate.h" 11 | #import "IFSimpleTintFilter.h" 12 | #import "IFGreyscaleFilter.h" 13 | #import "IFPixelationFilter.h" 14 | #import "IFBrightnessFilter.h" 15 | #import "IFThermalFilter.h" 16 | #import "IFSnowFuzzFilter.h" 17 | #import "IFSaturationFilter.h" 18 | #import "IFHueFilter.h" 19 | #import "IFBlurFilter.h" 20 | #import "IFFindEdgesFilter.h" 21 | #import "IFEmbossFilter.h" 22 | #import "IFSharpenFilter.h" 23 | #import "IFTiltShiftFilter.h" 24 | 25 | 26 | @implementation IFFilterPreviewViewController 27 | 28 | @synthesize originalImage; 29 | 30 | #pragma mark - Initialization 31 | 32 | - (void)viewDidLoad 33 | { 34 | [super viewDidLoad]; 35 | 36 | imageView.image = originalImage; 37 | 38 | // Add the nav bar button 39 | UIBarButtonItem *openFiltersButton = [[UIBarButtonItem alloc] initWithTitle:@"Filters" style:UIBarButtonItemStyleBordered target:self action:@selector(openFilterOptions)]; 40 | self.navigationItem.rightBarButtonItem = openFiltersButton; 41 | [openFiltersButton release]; 42 | 43 | slider.hidden = YES; 44 | } 45 | 46 | #pragma mark - Button Actions 47 | 48 | - (void) openFilterOptions 49 | { 50 | UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Tint Red", @"Greyscale", @"Pixelate", @"Brightness", @"Saturation", @"Hue", @"Thermal", @"Snow Fuzz", @"Blur", @"Find Edges", @"Emboss", @"Sharpen", @"Tilt Shift", nil]; 51 | [actionSheet showInView:((ImageFilterKitAppDelegate *)[UIApplication sharedApplication].delegate).window]; 52 | [actionSheet release]; 53 | } 54 | 55 | - (IBAction) sliderMoved:(id)sender 56 | { 57 | if(sliderMode == IFFilterPreviewSliderModePixelate) 58 | { 59 | IFPixelationFilter *pixels = [[IFPixelationFilter alloc] initWithOriginalImage:originalImage]; 60 | pixels.pixelSize = roundf(slider.value); 61 | imageView.image = [pixels imageWithFilterApplied]; 62 | [pixels release]; 63 | } 64 | else if(sliderMode == IFFilterPreviewSliderModeBrightness) 65 | { 66 | IFBrightnessFilter *brightness = [[IFBrightnessFilter alloc] initWithOriginalImage:originalImage]; 67 | brightness.brightnessAdjustment = roundf(slider.value); 68 | imageView.image = [brightness imageWithFilterApplied]; 69 | [brightness release]; 70 | } 71 | else if(sliderMode == IFFilterPreviewSliderModeSaturation) 72 | { 73 | IFSaturationFilter *saturation = [[IFSaturationFilter alloc] initWithOriginalImage:originalImage]; 74 | saturation.saturationAdjustment = roundf(slider.value); 75 | imageView.image = [saturation imageWithFilterApplied]; 76 | [saturation release]; 77 | } 78 | 79 | else if(sliderMode == IFFilterPreviewSliderModeHue) 80 | { 81 | IFHueFilter *hue = [[IFHueFilter alloc] initWithOriginalImage:originalImage]; 82 | hue.hueAdjustment = roundf(slider.value); 83 | imageView.image = [hue imageWithFilterApplied]; 84 | [hue release]; 85 | } 86 | } 87 | 88 | #pragma mark - Action Sheet Delegate 89 | 90 | - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 91 | { 92 | slider.hidden = YES; 93 | 94 | if(buttonIndex == 0) 95 | { 96 | IFSimpleTintFilter *tinter = [[IFSimpleTintFilter alloc] initWithOriginalImage:originalImage]; 97 | tinter.tintColor = [UIColor redColor]; 98 | imageView.image = [tinter imageWithFilterApplied]; 99 | [tinter release]; 100 | } 101 | else if(buttonIndex == 1) 102 | { 103 | IFGreyscaleFilter *grey = [[IFGreyscaleFilter alloc] initWithOriginalImage:originalImage]; 104 | imageView.image = [grey imageWithFilterApplied]; 105 | [grey release]; 106 | } 107 | else if(buttonIndex == 2) 108 | { 109 | slider.minimumValue = 1.0; 110 | slider.maximumValue = 20.0; 111 | slider.value = 1.0; 112 | sliderMode = IFFilterPreviewSliderModePixelate; 113 | slider.hidden = NO; 114 | [self sliderMoved:slider]; 115 | } 116 | else if(buttonIndex == 3) 117 | { 118 | slider.minimumValue = -150.0; 119 | slider.maximumValue = 150.0; 120 | slider.value = 0.0; 121 | sliderMode = IFFilterPreviewSliderModeBrightness; 122 | slider.hidden = NO; 123 | [self sliderMoved:slider]; 124 | } 125 | else if(buttonIndex == 4) 126 | { 127 | slider.minimumValue = -150.0; 128 | slider.maximumValue = 150.0; 129 | slider.value = 0.0; 130 | sliderMode = IFFilterPreviewSliderModeSaturation; 131 | slider.hidden = NO; 132 | [self sliderMoved:slider]; 133 | } 134 | else if(buttonIndex == 5) 135 | { 136 | slider.minimumValue = 0; 137 | slider.maximumValue = 360.0; 138 | slider.value = 0.0; 139 | sliderMode = IFFilterPreviewSliderModeHue; 140 | slider.hidden = NO; 141 | } 142 | else if(buttonIndex == 6) 143 | { 144 | IFThermalFilter *thermal = [[IFThermalFilter alloc] initWithOriginalImage:originalImage]; 145 | imageView.image = [thermal imageWithFilterApplied]; 146 | [thermal release]; 147 | } 148 | else if(buttonIndex == 7) 149 | { 150 | IFSnowFuzzFilter *snow = [[IFSnowFuzzFilter alloc] initWithOriginalImage:originalImage]; 151 | imageView.image = [snow imageWithFilterApplied]; 152 | [snow release]; 153 | } 154 | else if(buttonIndex == 8) 155 | { 156 | IFBlurFilter *blur = [[IFBlurFilter alloc] initWithOriginalImage:originalImage]; 157 | imageView.image = [blur imageWithFilterApplied]; 158 | [blur release]; 159 | } 160 | else if(buttonIndex == 9) 161 | { 162 | IFFindEdgesFilter *edges = [[IFFindEdgesFilter alloc] initWithOriginalImage:originalImage]; 163 | imageView.image = [edges imageWithFilterApplied]; 164 | [edges release]; 165 | } 166 | else if(buttonIndex == 10) 167 | { 168 | IFEmbossFilter *emboss = [[IFEmbossFilter alloc] initWithOriginalImage:originalImage]; 169 | imageView.image = [emboss imageWithFilterApplied]; 170 | [emboss release]; 171 | } 172 | else if(buttonIndex == 11) 173 | { 174 | IFSharpenFilter *sharpen = [[IFSharpenFilter alloc] initWithOriginalImage:originalImage]; 175 | imageView.image = [sharpen imageWithFilterApplied]; 176 | [sharpen release]; 177 | } 178 | else if(buttonIndex == 12) 179 | { 180 | activityView.hidden = NO; 181 | 182 | IFTiltShiftFilter *tilt = [[IFTiltShiftFilter alloc] initWithOriginalImage:originalImage]; 183 | tilt.delegate = self; 184 | //imageView.image = [tilt imageWithFilterApplied]; 185 | [tilt applyFilterOnNewThread]; 186 | [tilt release]; 187 | } 188 | } 189 | 190 | #pragma mark - Filter Delegate 191 | 192 | - (void) filterDidApplyWithResult:(UIImage *)result 193 | { 194 | activityView.hidden = YES; 195 | imageView.image = result; 196 | } 197 | 198 | #pragma mark - Cleanup 199 | 200 | - (void)dealloc 201 | { 202 | [super dealloc]; 203 | 204 | [originalImage release]; 205 | } 206 | 207 | @end 208 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFFilterPreviewViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBUISlider 16 | IBUILabel 17 | IBUIImageView 18 | IBUIView 19 | IBUIActivityIndicatorView 20 | IBProxyObject 21 | 22 | 23 | YES 24 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 25 | 26 | 27 | YES 28 | 29 | YES 30 | 31 | 32 | 33 | 34 | YES 35 | 36 | IBFilesOwner 37 | IBCocoaTouchFramework 38 | 39 | 40 | IBFirstResponder 41 | IBCocoaTouchFramework 42 | 43 | 44 | 45 | 274 46 | 47 | YES 48 | 49 | 50 | 274 51 | {320, 370} 52 | 53 | 54 | 55 | 1 56 | NO 57 | IBCocoaTouchFramework 58 | 59 | 60 | 61 | 292 62 | {{13, 383}, {290, 23}} 63 | 64 | 65 | 66 | NO 67 | IBCocoaTouchFramework 68 | 0 69 | 0 70 | 1 71 | 1 72 | 20 73 | 74 | 75 | 76 | -2147483356 77 | 78 | YES 79 | 80 | 81 | 292 82 | {{142, 169}, {37, 37}} 83 | 84 | 85 | 86 | NO 87 | IBCocoaTouchFramework 88 | NO 89 | YES 90 | 0 91 | 92 | 93 | 94 | 292 95 | {{100, 135}, {120, 21}} 96 | 97 | 98 | 99 | NO 100 | YES 101 | 7 102 | NO 103 | IBCocoaTouchFramework 104 | Applying Filter 105 | 106 | 1 107 | MSAxIDEAA 108 | 109 | 1 110 | 111 | 112 | 113 | 1 114 | 10 115 | 1 116 | 117 | 118 | {320, 416} 119 | 120 | 121 | 122 | 123 | 3 124 | MCAwLjYAA 125 | 126 | 2 127 | 128 | 129 | IBCocoaTouchFramework 130 | 131 | 132 | {{0, 64}, {320, 416}} 133 | 134 | 135 | 136 | 137 | 3 138 | MQA 139 | 140 | 141 | 142 | 143 | NO 144 | 145 | IBCocoaTouchFramework 146 | 147 | 148 | 149 | 150 | YES 151 | 152 | 153 | view 154 | 155 | 156 | 157 | 3 158 | 159 | 160 | 161 | imageView 162 | 163 | 164 | 165 | 5 166 | 167 | 168 | 169 | sliderMoved: 170 | 171 | 172 | 13 173 | 174 | 7 175 | 176 | 177 | 178 | slider 179 | 180 | 181 | 182 | 8 183 | 184 | 185 | 186 | activityView 187 | 188 | 189 | 190 | 12 191 | 192 | 193 | 194 | 195 | YES 196 | 197 | 0 198 | 199 | 200 | 201 | 202 | 203 | 1 204 | 205 | 206 | YES 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -1 215 | 216 | 217 | File's Owner 218 | 219 | 220 | -2 221 | 222 | 223 | 224 | 225 | 4 226 | 227 | 228 | 229 | 230 | 6 231 | 232 | 233 | 234 | 235 | 9 236 | 237 | 238 | YES 239 | 240 | 241 | 242 | 243 | 244 | 245 | 10 246 | 247 | 248 | 249 | 250 | 11 251 | 252 | 253 | 254 | 255 | 256 | 257 | YES 258 | 259 | YES 260 | -1.CustomClassName 261 | -2.CustomClassName 262 | 1.IBEditorWindowLastContentRect 263 | 1.IBPluginDependency 264 | 10.IBPluginDependency 265 | 11.IBPluginDependency 266 | 4.IBPluginDependency 267 | 6.IBPluginDependency 268 | 9.IBPluginDependency 269 | 270 | 271 | YES 272 | IFFilterPreviewViewController 273 | UIResponder 274 | {{556, 412}, {320, 480}} 275 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 276 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 277 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 278 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 279 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 280 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 281 | 282 | 283 | 284 | YES 285 | 286 | 287 | 288 | 289 | 290 | YES 291 | 292 | 293 | 294 | 295 | 12 296 | 297 | 298 | 299 | YES 300 | 301 | IFFilterPreviewViewController 302 | UIViewController 303 | 304 | sliderMoved: 305 | id 306 | 307 | 308 | sliderMoved: 309 | 310 | sliderMoved: 311 | id 312 | 313 | 314 | 315 | YES 316 | 317 | YES 318 | activityView 319 | imageView 320 | slider 321 | 322 | 323 | YES 324 | UIView 325 | UIImageView 326 | UISlider 327 | 328 | 329 | 330 | YES 331 | 332 | YES 333 | activityView 334 | imageView 335 | slider 336 | 337 | 338 | YES 339 | 340 | activityView 341 | UIView 342 | 343 | 344 | imageView 345 | UIImageView 346 | 347 | 348 | slider 349 | UISlider 350 | 351 | 352 | 353 | 354 | IBProjectSource 355 | ./Classes/IFFilterPreviewViewController.h 356 | 357 | 358 | 359 | 360 | 0 361 | IBCocoaTouchFramework 362 | 363 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 364 | 365 | 366 | YES 367 | 3 368 | 301 369 | 370 | 371 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFPhotoSelectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // IFPhotoSelectionViewController.h 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface IFPhotoSelectionViewController : UIViewController 13 | { 14 | UIImagePickerController *imagePicker; 15 | } 16 | 17 | - (IBAction) openCamera; 18 | - (IBAction) openLibrary; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFPhotoSelectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // IFPhotoSelectionViewController.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import "IFPhotoSelectionViewController.h" 10 | #import "IFFilterPreviewViewController.h" 11 | #import "UIImage+Resize.h" 12 | 13 | 14 | @implementation IFPhotoSelectionViewController 15 | 16 | #pragma mark - Initialization 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | imagePicker = [[UIImagePickerController alloc] init]; 23 | imagePicker.delegate = self; 24 | imagePicker.allowsEditing = YES; 25 | } 26 | 27 | #pragma mark - Button Actions 28 | 29 | - (IBAction) openCamera 30 | { 31 | imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 32 | [self presentModalViewController:imagePicker animated:YES]; 33 | } 34 | 35 | - (IBAction) openLibrary 36 | { 37 | imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 38 | [self presentModalViewController:imagePicker animated:YES]; 39 | } 40 | 41 | #pragma mark - Image Picker Delegate 42 | 43 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 44 | { 45 | [self dismissModalViewControllerAnimated:YES]; 46 | 47 | UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; 48 | UIImage *smallImage = [image resizedImageWithContentMode:UIViewContentModeScaleAspectFit bounds:CGSizeMake(640, 960) interpolationQuality:kCGInterpolationDefault]; 49 | 50 | IFFilterPreviewViewController *preview = [[IFFilterPreviewViewController alloc] init]; 51 | preview.originalImage = smallImage; 52 | [self.navigationController pushViewController:preview animated:YES]; 53 | [preview release]; 54 | } 55 | 56 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 57 | { 58 | [self dismissModalViewControllerAnimated:YES]; 59 | } 60 | 61 | #pragma mark - Cleanup 62 | 63 | - (void)dealloc 64 | { 65 | [imagePicker release]; 66 | 67 | [super dealloc]; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /ImageFilterKit/View/IFPhotoSelectionViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUIView 17 | IBUIButton 18 | 19 | 20 | YES 21 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 22 | 23 | 24 | YES 25 | 26 | YES 27 | 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | 42 | 274 43 | 44 | YES 45 | 46 | 47 | 292 48 | {{66, 66}, {188, 39}} 49 | 50 | 51 | 52 | NO 53 | IBCocoaTouchFramework 54 | 0 55 | 0 56 | 57 | Helvetica-Bold 58 | 15 59 | 16 60 | 61 | 1 62 | Camera 63 | 64 | 3 65 | MQA 66 | 67 | 68 | 1 69 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 70 | 71 | 72 | 3 73 | MC41AA 74 | 75 | 76 | 77 | 78 | 292 79 | {{66, 130}, {188, 39}} 80 | 81 | 82 | NO 83 | IBCocoaTouchFramework 84 | 0 85 | 0 86 | 87 | 1 88 | Library 89 | 90 | 91 | 1 92 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 93 | 94 | 95 | 96 | 97 | {{0, 64}, {320, 416}} 98 | 99 | 100 | 101 | 102 | 3 103 | MQA 104 | 105 | 2 106 | 107 | 108 | 109 | 110 | NO 111 | 112 | IBCocoaTouchFramework 113 | 114 | 115 | 116 | 117 | YES 118 | 119 | 120 | view 121 | 122 | 123 | 124 | 3 125 | 126 | 127 | 128 | openCamera 129 | 130 | 131 | 7 132 | 133 | 6 134 | 135 | 136 | 137 | openLibrary 138 | 139 | 140 | 7 141 | 142 | 7 143 | 144 | 145 | 146 | 147 | YES 148 | 149 | 0 150 | 151 | 152 | 153 | 154 | 155 | 1 156 | 157 | 158 | YES 159 | 160 | 161 | 162 | 163 | 164 | 165 | -1 166 | 167 | 168 | File's Owner 169 | 170 | 171 | -2 172 | 173 | 174 | 175 | 176 | 4 177 | 178 | 179 | 180 | 181 | 5 182 | 183 | 184 | 185 | 186 | 187 | 188 | YES 189 | 190 | YES 191 | -1.CustomClassName 192 | -2.CustomClassName 193 | 1.IBEditorWindowLastContentRect 194 | 1.IBPluginDependency 195 | 4.IBPluginDependency 196 | 5.IBPluginDependency 197 | 198 | 199 | YES 200 | IFPhotoSelectionViewController 201 | UIResponder 202 | {{556, 412}, {320, 480}} 203 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 204 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 205 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 206 | 207 | 208 | 209 | YES 210 | 211 | 212 | 213 | 214 | 215 | YES 216 | 217 | 218 | 219 | 220 | 7 221 | 222 | 223 | 224 | YES 225 | 226 | IFPhotoSelectionViewController 227 | UIViewController 228 | 229 | YES 230 | 231 | YES 232 | openCamera 233 | openLibrary 234 | 235 | 236 | YES 237 | id 238 | id 239 | 240 | 241 | 242 | YES 243 | 244 | YES 245 | openCamera 246 | openLibrary 247 | 248 | 249 | YES 250 | 251 | openCamera 252 | id 253 | 254 | 255 | openLibrary 256 | id 257 | 258 | 259 | 260 | 261 | IBProjectSource 262 | ./Classes/IFPhotoSelectionViewController.h 263 | 264 | 265 | 266 | 267 | 0 268 | IBCocoaTouchFramework 269 | 270 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 271 | 272 | 273 | YES 274 | 3 275 | 301 276 | 277 | 278 | -------------------------------------------------------------------------------- /ImageFilterKit/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ImageFilterKit/en.lproj/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUICustomObject 17 | IBUIWindow 18 | 19 | 20 | YES 21 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 22 | 23 | 24 | YES 25 | 26 | YES 27 | 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | 45 | 292 46 | {320, 480} 47 | 48 | 49 | 50 | 51 | 1 52 | MSAxIDEAA 53 | 54 | NO 55 | NO 56 | 57 | IBCocoaTouchFramework 58 | YES 59 | 60 | 61 | 62 | 63 | YES 64 | 65 | 66 | delegate 67 | 68 | 69 | 70 | 4 71 | 72 | 73 | 74 | window 75 | 76 | 77 | 78 | 14 79 | 80 | 81 | 82 | 83 | YES 84 | 85 | 0 86 | 87 | 88 | 89 | 90 | 91 | -1 92 | 93 | 94 | File's Owner 95 | 96 | 97 | 3 98 | 99 | 100 | ImageFilterKit App Delegate 101 | 102 | 103 | -2 104 | 105 | 106 | 107 | 108 | 12 109 | 110 | 111 | 112 | 113 | 114 | 115 | YES 116 | 117 | YES 118 | -1.CustomClassName 119 | -2.CustomClassName 120 | 12.IBEditorWindowLastContentRect 121 | 12.IBPluginDependency 122 | 3.CustomClassName 123 | 3.IBPluginDependency 124 | 125 | 126 | YES 127 | UIApplication 128 | UIResponder 129 | {{525, 346}, {320, 480}} 130 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 131 | ImageFilterKitAppDelegate 132 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 133 | 134 | 135 | 136 | YES 137 | 138 | 139 | 140 | 141 | 142 | YES 143 | 144 | 145 | 146 | 147 | 15 148 | 149 | 150 | 151 | YES 152 | 153 | ImageFilterKitAppDelegate 154 | NSObject 155 | 156 | window 157 | UIWindow 158 | 159 | 160 | window 161 | 162 | window 163 | UIWindow 164 | 165 | 166 | 167 | IBProjectSource 168 | ./Classes/ImageFilterKitAppDelegate.h 169 | 170 | 171 | 172 | 173 | 0 174 | IBCocoaTouchFramework 175 | 176 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 177 | 178 | 179 | 180 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 181 | 182 | 183 | YES 184 | 3 185 | 301 186 | 187 | 188 | -------------------------------------------------------------------------------- /ImageFilterKit/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ImageFilterKit 4 | // 5 | // Created by Andy Roth on 3/29/11. 6 | // Copyright 2011 Roozy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | ImageFilterKit is a collection of image filters that can be applied to images using CoreGraphics. --------------------------------------------------------------------------------