├── .circleci └── config.yml ├── .dockerignore ├── .gitattributes ├── .github └── issue_template.md ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── RELEASE_NOTES.md ├── RNIFKTest ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .inferconfig ├── .watchmanconfig ├── App.js ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rnifktest │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── rnifktest │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── RNIFKTest.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── RNIFKTest.xcscheme │ ├── RNIFKTest.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── RNIFKTest │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m ├── metro.config.js ├── package-lock.json └── package.json ├── android ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── iyegoroff │ │ └── imagefilterkit │ │ ├── AuxCache.java │ │ ├── ExtractedImagesCacheModule.java │ │ ├── FilterableImage.java │ │ ├── FrescoControllerListener.java │ │ ├── Functor.java │ │ ├── ImageFilter.java │ │ ├── ImageFilterEvent.java │ │ ├── ImageFilterKitPackage.java │ │ ├── ImageFilterManager.java │ │ ├── InputConverter.java │ │ ├── MainReactPackageWithFrescoCache.java │ │ ├── MemoryTrimmer.java │ │ ├── MixStep.java │ │ ├── PostProcessorRegistry.java │ │ ├── ReactImageViewUtils.java │ │ ├── RenderscriptUtils.java │ │ ├── Scale.java │ │ ├── SharedRenderscript.java │ │ ├── TempFileUtils.java │ │ ├── Transform.java │ │ ├── WeakFilterableImage.java │ │ ├── blend │ │ ├── ColorBlendPostProcessor.java │ │ ├── ColorBurnBlendPostProcessor.java │ │ ├── ColorDodgeBlendPostProcessor.java │ │ ├── DifferenceBlendPostProcessor.java │ │ ├── ExclusionBlendPostProcessor.java │ │ ├── HardLightBlendPostProcessor.java │ │ ├── HueBlendPostProcessor.java │ │ ├── LuminosityBlendPostProcessor.java │ │ ├── MultiplyBlendPostProcessor.java │ │ ├── SaturationBlendPostProcessor.java │ │ └── SoftLightBlendPostProcessor.java │ │ ├── compositing │ │ ├── DestinationATopCompositingPostProcessor.java │ │ ├── DestinationInCompositingPostProcessor.java │ │ ├── SourceInCompositingPostProcessor.java │ │ └── SourceOutCompositingPostProcessor.java │ │ ├── gradients │ │ ├── EllipticalGradientPostProcessor.java │ │ ├── QuadGradientPostProcessor.java │ │ ├── RectangularGradientPostProcessor.java │ │ ├── SmoothLinearGradientPostProcessor.java │ │ ├── SmoothRadialGradientPostProcessor.java │ │ └── SmoothSweepGradientPostProcessor.java │ │ ├── nativeplatform │ │ ├── ColorMatrixColorFilterPostProcessor.java │ │ ├── ColorPostProcessor.java │ │ ├── IterativeBoxBlurPostProcessor.java │ │ ├── LightingColorFilterPostProcessor.java │ │ ├── LinearGradientPostProcessor.java │ │ ├── PorterDuffColorFilterPostProcessor.java │ │ ├── PorterDuffXfermodePostProcessor.java │ │ ├── RadialGradientPostProcessor.java │ │ ├── RoundAsCirclePostProcessor.java │ │ ├── SweepGradientPostProcessor.java │ │ ├── TextImagePostProcessor.java │ │ ├── scriptintrinsic │ │ │ ├── ScriptIntrinsicBlurPostProcessor.java │ │ │ ├── ScriptIntrinsicConvolve3x3PostProcessor.java │ │ │ └── ScriptIntrinsicConvolve5x5PostProcessor.java │ │ └── shape │ │ │ ├── CircleShapePostProcessor.java │ │ │ ├── OvalShapePostProcessor.java │ │ │ ├── PathShapePostProcessor.java │ │ │ └── RegularPolygonShapePostProcessor.java │ │ └── utility │ │ ├── CacheablePostProcessor.java │ │ ├── CompositionPostProcessor.java │ │ ├── DummyPostProcessor.java │ │ ├── GeneratorPostProcessor.java │ │ ├── MultiPostProcessor.java │ │ ├── RenderscriptCompositionPostProcessor.java │ │ ├── RenderscriptGeneratorPostProcessor.java │ │ └── RenderscriptSingularPostProcessor.java │ └── rs │ ├── blend │ ├── BlendUtils.rsh │ ├── ColorBlend.rs │ ├── ColorBurnBlend.rs │ ├── ColorDodgeBlend.rs │ ├── DifferenceBlend.rs │ ├── ExclusionBlend.rs │ ├── HardLightBlend.rs │ ├── HueBlend.rs │ ├── LuminosityBlend.rs │ ├── MultiplyBlend.rs │ ├── SaturationBlend.rs │ └── SoftLightBlend.rs │ ├── compositing │ ├── DestinationATopCompositing.rs │ ├── DestinationInCompositing.rs │ ├── SourceInCompositing.rs │ └── SourceOutCompositing.rs │ └── gradients │ ├── EllipticalGradient.rs │ ├── GradientUtils.rsh │ ├── QuadGradient.rs │ ├── RectangularGradient.rs │ ├── SmoothLinearGradient.rs │ ├── SmoothRadialGradient.rs │ └── SmoothSweepGradient.rs ├── docs ├── blend_filters.md ├── blur_filters.md ├── color_matrix_filters.md ├── composition_filters.md ├── convolve_matrix_filters.md ├── cssgram_filters.md ├── functions.md ├── generators.md ├── image_extraction.md ├── manual_installation.md └── types.md ├── examples ├── CustomFilter │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── Dockerfile │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ ├── debug.keystore │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ ├── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── customfilter │ │ │ │ │ └── ReactNativeFlipper.java │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── assets │ │ │ │ └── .gitkeep │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── customfilter │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ │ ├── .gitignore │ │ ├── CustomFilter.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── CustomFilter.xcscheme │ │ ├── CustomFilter.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ ├── CustomFilter │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Images.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ │ └── Contents.json │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── main.m │ │ ├── Podfile │ │ └── Podfile.lock │ ├── metro.config.js │ ├── package.json │ ├── src │ │ ├── App.tsx │ │ ├── InstagramCSS.tsx │ │ └── tsconfig.json │ └── yarn.lock ├── CustomNativeFilter │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── Dockerfile │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ ├── debug.keystore │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ ├── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── customnativefilter │ │ │ │ │ └── ReactNativeFlipper.java │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── assets │ │ │ │ └── .gitkeep │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── customnativefilter │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ │ ├── .gitignore │ │ ├── CustomNativeFilter.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── CustomNativeFilter.xcscheme │ │ ├── CustomNativeFilter.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ ├── CustomNativeFilter │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Images.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ │ └── Contents.json │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── main.m │ │ ├── Podfile │ │ └── Podfile.lock │ ├── local_modules │ │ └── react-native-image-filter-kit-haze-removal │ │ │ ├── .gitattributes │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── android │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ ├── settings.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── iyegoroff │ │ │ │ │ └── imagefilterkit │ │ │ │ │ └── hazeremoval │ │ │ │ │ ├── HazeRemovalPostProcessor.java │ │ │ │ │ └── ImageFilterKitHazeRemovalPackage.java │ │ │ │ └── rs │ │ │ │ └── HazeRemoval.rs │ │ │ ├── ios │ │ │ ├── IFKHRHazeRemoval.h │ │ │ ├── IFKHRHazeRemoval.m │ │ │ ├── RNImageFilterKitHazeRemoval.xcodeproj │ │ │ │ └── project.pbxproj │ │ │ └── Resources │ │ │ │ └── IFKHRHazeRemoval.cikernel │ │ │ ├── package.json │ │ │ ├── react-native-image-filter-kit-haze-removal.podspec │ │ │ ├── src │ │ │ ├── index.ts │ │ │ └── tsconfig.json │ │ │ └── yarn.lock │ ├── metro.config.js │ ├── package.json │ ├── patches │ │ └── react-native-gesture-handler+1.10.3.patch │ ├── src │ │ ├── App.tsx │ │ └── tsconfig.json │ └── yarn.lock └── ImageExtraction │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── Dockerfile │ ├── README.md │ ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── imageextraction │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── assets │ │ │ └── .gitkeep │ │ │ ├── java │ │ │ └── com │ │ │ │ └── imageextraction │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── .gitignore │ ├── ImageExtraction.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── ImageExtraction.xcscheme │ ├── ImageExtraction.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── ImageExtraction │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── Podfile │ └── Podfile.lock │ ├── metro.config.js │ ├── package.json │ ├── src │ ├── App.tsx │ └── tsconfig.json │ └── yarn.lock ├── img ├── coordinates.png ├── earlybird.png ├── emboss.png ├── invert.png ├── maven.jpg ├── maven_compat.jpg ├── parrot.png ├── porter_duff.png ├── radial_gradient.png └── soft_light_blend.png ├── ios ├── .gitignore ├── IFKCacheable.h ├── IFKCircleShape.h ├── IFKCircleShape.m ├── IFKCompositionPostProcessor.h ├── IFKCompositionPostProcessor.m ├── IFKConfigHelper.h ├── IFKConfigHelper.m ├── IFKEllipticalGradient.h ├── IFKEllipticalGradient.m ├── IFKExtractedImagesCache.h ├── IFKExtractedImagesCache.m ├── IFKFilterConstructor.h ├── IFKFilterConstructor.m ├── IFKFilterableImage.h ├── IFKFilterableImage.m ├── IFKGradient.h ├── IFKGradient.m ├── IFKImage.h ├── IFKImage.m ├── IFKImageCache.h ├── IFKImageCache.m ├── IFKImageFilter.h ├── IFKImageFilter.m ├── IFKImageFilterManager.h ├── IFKImageFilterManager.m ├── IFKInputConverter.h ├── IFKInputConverter.m ├── IFKLinearGradient.h ├── IFKLinearGradient.m ├── IFKOutputExtentHandler.h ├── IFKOutputExtentHandler.m ├── IFKOvalShape.h ├── IFKOvalShape.m ├── IFKPathShape.h ├── IFKPathShape.m ├── IFKPostProcessor.h ├── IFKPostProcessor.m ├── IFKQuadGradient.h ├── IFKQuadGradient.m ├── IFKRadialGradient.h ├── IFKRadialGradient.m ├── IFKRectangularGradient.h ├── IFKRectangularGradient.m ├── IFKRegularPolygonShape.h ├── IFKRegularPolygonShape.m ├── IFKScale.h ├── IFKScale.m ├── IFKShape.h ├── IFKShape.m ├── IFKSweepGradient.h ├── IFKSweepGradient.m ├── IFKTextImage.h ├── IFKTextImage.m ├── IFKTransform.h ├── IFKTransform.m ├── IFKXorCompositing.h ├── IFKXorCompositing.m ├── NSArray+FilterMapReduce.h ├── NSArray+FilterMapReduce.m ├── RCTImageView+CacheKey.h ├── RCTImageView+CacheKey.m ├── RNImageFilterKit.xcodeproj │ └── project.pbxproj ├── Resources │ ├── IFKEllipticalGradient.cikernel │ ├── IFKLinearGradient.cikernel │ ├── IFKQuadGradient.cikernel │ ├── IFKRadialGradient.cikernel │ ├── IFKRectangularGradient.cikernel │ ├── IFKSweepGradient.cikernel │ └── IFKXorCompositing.cikernel ├── UIColor+CIColorComponents.h └── UIColor+CIColorComponents.m ├── package.json ├── react-native-image-filter-kit.podspec ├── src ├── blend-filters │ ├── index.ts │ ├── shape-transforms.android.ts │ ├── shape-transforms.d.ts │ ├── shape-transforms.ios.ts │ └── shapes.ts ├── blur-filters │ ├── index.ts │ ├── shape-transforms.ts │ └── shapes.ts ├── color-matrix-filters │ ├── index.ts │ ├── shape-transforms.ts │ └── shapes.ts ├── common │ ├── config.tsx │ ├── configs.d.ts │ ├── convert-image-name.ts │ ├── extracted-images-cache.ts │ ├── image-filter.tsx │ ├── image-placeholder.tsx │ ├── inputs.ts │ ├── path.ts │ ├── register-filter.ts │ ├── shape-registry.ts │ ├── shapes-to-components.ts │ ├── shapes.ts │ ├── style.ts │ ├── swap-composition.tsx │ └── util.ts ├── composition-filters │ ├── index.ts │ ├── shape-transforms.android.ts │ ├── shape-transforms.d.ts │ ├── shape-transforms.ios.ts │ └── shapes.ts ├── convolve-matrix-filters │ ├── index.ts │ ├── shape-transforms.ts │ └── shapes.ts ├── cssgram-filters │ ├── index.ts │ ├── shape-transforms.ts │ └── shapes.ts ├── generators │ ├── index.ts │ ├── shape-transforms.android.ts │ ├── shape-transforms.d.ts │ ├── shape-transforms.ios.ts │ └── shapes.ts ├── index.ts ├── misc-filters │ ├── index.ts │ ├── shapes.android.ts │ ├── shapes.d.ts │ └── shapes.ios.ts ├── native-platform-filters │ ├── index.ts │ ├── shapes.android.ts │ ├── shapes.d.ts │ └── shapes.ios.ts ├── tsconfig.json └── typings │ └── index.d.ts ├── tslint.json └── yarn.lock /.dockerignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | node_modules 3 | .github 4 | .git 5 | img 6 | LICENSE 7 | README.md 8 | RELEASE_NOTES.md 9 | *.podspec 10 | **/*.md 11 | *.tgz 12 | **/.gitignore 13 | 14 | **/bin 15 | **/obj 16 | **/packages 17 | **/paket-files 18 | fable-typed/paket.* 19 | fable-typed/*.fsproj 20 | fable-typed/publish.js 21 | fable-typed/.paket 22 | 23 | **/android/build 24 | **/android/app/build 25 | **/android/app/src/main/assets/*.bundle 26 | **/android/local.properties 27 | **/.gradle 28 | **/.idea 29 | **/*.iml 30 | **/*.apk 31 | 32 | **/ios/build 33 | **/ios/infer-out 34 | 35 | **/out 36 | 37 | **/infer-out 38 | **/compile_commands.json 39 | **/xcodebuild.log 40 | RNIFKTest 41 | examples/Sim* 42 | examples/*old 43 | 44 | .circleci 45 | .github 46 | .ionide 47 | .vscode 48 | 49 | blueprint-templates 50 | docs 51 | **/ios 52 | RNIFKTest 53 | ios-filters.txt 54 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | - Please specify your mobile platform(s) and react-native & react-native-image-filter-kit versions. Also check https://github.com/iyegoroff/react-native-image-filter-kit#status if your react-native-image-filter-kit version corresponds with your react-native version and ensure that you followed this installation guide - https://github.com/iyegoroff/react-native-image-filter-kit#installation 2 | 3 | - Sometimes cleaning the project could resolve build issues: press `Shift + Cmd + K` in Xcode and run `cd android && ./gradlew clean` in terminal 4 | 5 | - In case you use Expo you have to switch to 'bare workflow' in order to use this module 6 | 7 | - If your app crashed due to react-native-image-filter-kit, please attach a crash log or provide a minimal repro 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Dependency directories 17 | node_modules/ 18 | 19 | # Optional npm cache directory 20 | .npm 21 | 22 | # Optional REPL history 23 | .node_repl_history 24 | 25 | # Output of 'npm pack' 26 | *.tgz 27 | 28 | # Yarn Integrity file 29 | .yarn-integrity 30 | 31 | **/out/ 32 | 33 | blueprint-templates/ 34 | 35 | .vscode/ 36 | 37 | dist/ 38 | 39 | **/index.android.bundle 40 | 41 | **/infer-out 42 | examples/*old 43 | RNIFKTest_old 44 | .ionide 45 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "jsxSingleQuote": true, 5 | "trailingComma": "none", 6 | "printWidth": 100 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2021 iyegoroff 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | [release notes](https://github.com/iyegoroff/react-native-image-filter-kit/releases) -------------------------------------------------------------------------------- /RNIFKTest/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /RNIFKTest/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /RNIFKTest/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | -------------------------------------------------------------------------------- /RNIFKTest/.inferconfig: -------------------------------------------------------------------------------- 1 | { 2 | "infer-blacklist-path-regex": [ 3 | ".*/react-native/.*", 4 | ".*/ScriptC_.*", 5 | ".*/Bolts/.*", 6 | ".*/yoga/.*", 7 | ".*/React/.*", 8 | ".*/React-\\w+/.*", 9 | ".*/Folly/.*", 10 | ".*/glog/.*", 11 | ".*/DoubleConversion/.*", 12 | ".*/boost-for-react-native/.*", 13 | ".*/NSMutableArray.m" 14 | ], 15 | 16 | "skip-analysis-in-path": [ 17 | "Pods/Folly", 18 | "Pods/Bolts", 19 | "Pods/bolts-for-react-native", 20 | "Pods/DoubleConversion", 21 | "Pods/glog" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /RNIFKTest/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /RNIFKTest/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { View } from 'react-native' 3 | 4 | export default class App extends Component { 5 | render() { 6 | return 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/debug.keystore -------------------------------------------------------------------------------- /RNIFKTest/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/java/com/rnifktest/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rnifktest; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "RNIFKTest"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RNIFKTest 3 | 4 | -------------------------------------------------------------------------------- /RNIFKTest/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /RNIFKTest/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | ndkVersion = "20.1.5948944" 10 | renderscriptVersion = 21 11 | } 12 | repositories { 13 | google() 14 | jcenter() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:4.1.0") 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | 35 | google() 36 | jcenter() 37 | maven { url 'https://www.jitpack.io' } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /RNIFKTest/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.75.1 29 | -------------------------------------------------------------------------------- /RNIFKTest/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/RNIFKTest/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /RNIFKTest/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /RNIFKTest/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'RNIFKTest' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /RNIFKTest/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RNIFKTest", 3 | "displayName": "RNIFKTest" 4 | } -------------------------------------------------------------------------------- /RNIFKTest/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /RNIFKTest/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /RNIFKTest/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'RNIFKTest' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | post_install do |installer| 16 | react_native_post_install(installer) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | @implementation AppDelegate 8 | 9 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 10 | { 11 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 12 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 13 | moduleName:@"RNIFKTest" 14 | initialProperties:nil]; 15 | 16 | if (@available(iOS 13.0, *)) { 17 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 18 | } else { 19 | rootView.backgroundColor = [UIColor whiteColor]; 20 | } 21 | 22 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 23 | UIViewController *rootViewController = [UIViewController new]; 24 | rootViewController.view = rootView; 25 | self.window.rootViewController = rootViewController; 26 | [self.window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | 30 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 31 | { 32 | #if DEBUG 33 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 34 | #else 35 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 36 | #endif 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /RNIFKTest/ios/RNIFKTest/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /RNIFKTest/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path') 9 | 10 | const extraNodeModules = { 11 | react: path.resolve(__dirname, 'node_modules/react'), 12 | 'react-native': path.resolve(__dirname, 'node_modules/react-native'), 13 | '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'), 14 | 'react-native-image-filter-kit': path.resolve(__dirname, '../../') 15 | } 16 | const watchFolders = [path.resolve(__dirname, '../../')] 17 | 18 | module.exports = { 19 | resolver: { 20 | extraNodeModules 21 | }, 22 | watchFolders, 23 | transformer: { 24 | getTransformOptions: async () => ({ 25 | transform: { 26 | experimentalImportSupport: false, 27 | inlineRequires: false 28 | } 29 | }) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /RNIFKTest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RNIFKTest", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "preinstall": "cd .. && npm i", 7 | "reset:packager": "watchman watch-del-all && node_modules/react-native/scripts/packager.sh --reset-cache", 8 | "start:packager": "node node_modules/react-native/local-cli/cli.js start", 9 | "clean:android": "cd android && ./gradlew clean", 10 | "infer:android": "cd android && infer --fail-on-issue -- ./gradlew build -x :app:bundleReleaseJsAndAssets", 11 | "clean:ios": "cd ios && xcodebuild clean -workspace RNIFKTest.xcworkspace -configuration Debug -scheme RNIFKTest -derivedDataPath build", 12 | "infer:ios": "cd ios && infer --fail-on-issue -- xcodebuild -workspace RNIFKTest.xcworkspace -configuration Debug -scheme RNIFKTest -destination 'platform=iOS Simulator,OS=12.1,name=iPhone 7' -derivedDataPath build", 13 | "patch:pbxproj": "python ./patch-tvos.py", 14 | "install:pods": "cd ios && pod install" 15 | }, 16 | "dependencies": { 17 | "react": "17.0.1", 18 | "react-native": "0.64.1", 19 | "react-native-image-filter-kit": "file:../" 20 | }, 21 | "devDependencies": { 22 | "@babel/core": "^7.12.9", 23 | "@babel/runtime": "^7.12.5", 24 | "metro-react-native-babel-preset": "^0.64.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | build/ 3 | .idea 4 | .gradle 5 | local.properties 6 | *.iml -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def _ext = rootProject.ext; 4 | 5 | def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'; 6 | def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 29; 7 | def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '29.0.3'; 8 | def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21; 9 | def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 29; 10 | 11 | android { 12 | compileSdkVersion _compileSdkVersion 13 | buildToolsVersion _buildToolsVersion 14 | 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | 20 | defaultConfig { 21 | minSdkVersion _minSdkVersion 22 | targetSdkVersion _targetSdkVersion 23 | versionCode 1 24 | versionName "1.0" 25 | } 26 | lintOptions { 27 | abortOnError false 28 | } 29 | } 30 | 31 | dependencies { 32 | compileOnly "com.facebook.react:react-native:${_reactNativeVersion}" 33 | //noinspection GradleDynamicVersion 34 | compileOnly "com.parse.bolts:bolts-tasks:+" 35 | implementation 'com.github.iyegoroff:ReflectUtils:1.2.1' 36 | } 37 | 38 | repositories { 39 | maven { 40 | url "https://jitpack.io" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/ExtractedImagesCacheModule.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import android.os.AsyncTask; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 9 | import com.facebook.react.bridge.ReactMethod; 10 | import com.facebook.react.module.annotations.ReactModule; 11 | 12 | import java.util.Collections; 13 | import java.util.Map; 14 | 15 | @ReactModule(name = ExtractedImagesCacheModule.REACT_CLASS) 16 | public class ExtractedImagesCacheModule extends ReactContextBaseJavaModule { 17 | 18 | static final String REACT_CLASS = "IFKExtractedImagesCache"; 19 | 20 | ExtractedImagesCacheModule(ReactApplicationContext reactContext) { 21 | super(reactContext); 22 | } 23 | 24 | @Override 25 | public @NonNull String getName() { 26 | return REACT_CLASS; 27 | } 28 | 29 | @Override 30 | public Map getConstants() { 31 | return Collections.emptyMap(); 32 | } 33 | 34 | @Override 35 | public void onCatalystInstanceDestroy() { 36 | super.onCatalystInstanceDestroy(); 37 | 38 | this.clean(); 39 | } 40 | 41 | @ReactMethod 42 | public void clean() { 43 | new TempFileUtils.CleanTask(getReactApplicationContext()) 44 | .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/FilterableImage.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import com.facebook.cache.common.CacheKey; 4 | import com.facebook.cache.common.MultiCacheKey; 5 | import com.facebook.imagepipeline.request.Postprocessor; 6 | import com.facebook.react.views.image.ReactImageView; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | 11 | import javax.annotation.Nonnull; 12 | 13 | import iyegoroff.imagefilterkit.utility.CacheablePostProcessor; 14 | 15 | public class FilterableImage { 16 | 17 | private final @Nonnull ReactImageView mImage; 18 | private final @Nonnull ArrayList mPostProcessors; 19 | private final boolean mCacheDisabled; 20 | 21 | FilterableImage( 22 | final @Nonnull ReactImageView image, 23 | final @Nonnull ArrayList postProcessors, 24 | final boolean cacheDisabled 25 | ) { 26 | mImage = image; 27 | mPostProcessors = postProcessors; 28 | mCacheDisabled = cacheDisabled; 29 | } 30 | 31 | CacheKey generatedCacheKey() { 32 | final ArrayList keys = new ArrayList<>( 33 | Collections.singletonList(ReactImageViewUtils.getCacheKey(mImage)) 34 | ); 35 | 36 | for (Postprocessor p : mPostProcessors) { 37 | keys.add( 38 | p instanceof CacheablePostProcessor 39 | ? ((CacheablePostProcessor) p).generateCacheKey() 40 | : p.getPostprocessorCacheKey() 41 | ); 42 | } 43 | 44 | return new MultiCacheKey(keys); 45 | } 46 | 47 | public ReactImageView getImage() { 48 | return mImage; 49 | } 50 | 51 | ArrayList getPostProcessors() { 52 | return mPostProcessors; 53 | } 54 | 55 | boolean isCacheDisabled() { 56 | return mCacheDisabled; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/Functor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | interface Functor { 4 | interface Arity0 { 5 | void call(); 6 | } 7 | 8 | interface Arity1 { 9 | void call(T arg1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/ImageFilterEvent.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import javax.annotation.Nonnull; 4 | 5 | class ImageFilterEvent { 6 | 7 | static final @Nonnull String ON_FILTERING_START = "onIFKFilteringStart"; 8 | static final @Nonnull String ON_FILTERING_FINISH = "onIFKFilteringFinish"; 9 | static final @Nonnull String ON_FILTERING_ERROR = "onIFKFilteringError"; 10 | static final @Nonnull String ON_EXTRACT_IMAGE = "onIFKExtractImage"; 11 | } 12 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/ImageFilterKitPackage.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | import com.facebook.react.ReactPackage; 7 | import com.facebook.react.bridge.NativeModule; 8 | import com.facebook.react.bridge.ReactApplicationContext; 9 | import com.facebook.react.uimanager.ViewManager; 10 | 11 | import javax.annotation.Nonnull; 12 | 13 | public class ImageFilterKitPackage implements ReactPackage { 14 | @Override 15 | public @Nonnull List createViewManagers( 16 | @Nonnull ReactApplicationContext reactContext 17 | ) { 18 | return Collections.singletonList(new ImageFilterManager()); 19 | } 20 | 21 | @Override 22 | public @Nonnull List createNativeModules( 23 | @Nonnull ReactApplicationContext reactContext 24 | ) { 25 | return Collections.singletonList(new ExtractedImagesCacheModule(reactContext)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/MemoryTrimmer.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import com.facebook.common.memory.MemoryTrimType; 4 | import com.facebook.common.memory.MemoryTrimmable; 5 | import com.facebook.common.memory.MemoryTrimmableRegistry; 6 | 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | public class MemoryTrimmer implements MemoryTrimmableRegistry { 11 | 12 | private static final MemoryTrimmer sInstance = 13 | new MemoryTrimmer(); 14 | 15 | static MemoryTrimmer getInstance() { 16 | return sInstance; 17 | } 18 | 19 | private MemoryTrimmer() { 20 | } 21 | 22 | private final List mTrimmables = new LinkedList<>(); 23 | 24 | @Override 25 | public void registerMemoryTrimmable(final MemoryTrimmable trimmable) { 26 | mTrimmables.add(trimmable); 27 | } 28 | 29 | @Override 30 | public void unregisterMemoryTrimmable(final MemoryTrimmable trimmable) { 31 | mTrimmables.remove(trimmable); 32 | } 33 | 34 | synchronized void trim() { 35 | for (MemoryTrimmable trimmable : mTrimmables) { 36 | trimmable.trim(MemoryTrimType.OnCloseToDalvikHeapLimit); 37 | } 38 | } 39 | 40 | boolean isUsed() { 41 | return !mTrimmables.isEmpty(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/MixStep.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | public enum MixStep { 4 | CLAMP, 5 | SMOOTH 6 | } 7 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/RenderscriptUtils.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import android.graphics.Color; 4 | 5 | import android.renderscript.Float4; 6 | 7 | public class RenderscriptUtils { 8 | 9 | private static int sMaxColors = 10; 10 | 11 | public static Float4 toRenderscriptColor(final int color) { 12 | return new Float4( 13 | Color.red(color) / 255.0f, 14 | Color.green(color) / 255.0f, 15 | Color.blue(color) / 255.0f, 16 | Color.alpha(color) / 255.0f 17 | ); 18 | } 19 | 20 | public static Float4[] renderscriptColors(int[] colors) { 21 | Float4[] converted = new Float4[sMaxColors]; 22 | 23 | for (int i = 0; i < sMaxColors; i++) { 24 | converted[i] = toRenderscriptColor(colors.length > i ? colors[i] : Color.TRANSPARENT); 25 | } 26 | 27 | return converted; 28 | } 29 | 30 | public static float[] renderscriptPositions(float[] positions) { 31 | float[] converted = new float[sMaxColors]; 32 | 33 | for (int i = 0; i < sMaxColors; i++) { 34 | converted[i] = positions.length > i ? positions[i] : 0.0f; 35 | } 36 | 37 | return converted; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/Scale.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import android.graphics.PointF; 4 | 5 | import com.facebook.infer.annotation.Assertions; 6 | 7 | import java.util.Locale; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | public class Scale { 12 | 13 | public enum Mode { 14 | STRETCH, 15 | CONTAIN, 16 | COVER 17 | } 18 | 19 | private Scale() { 20 | 21 | } 22 | 23 | public static class WithMode extends Scale { 24 | public final Mode mode; 25 | 26 | public WithMode(Mode mode) { 27 | this.mode = mode; 28 | } 29 | } 30 | 31 | public static class WithSize extends Scale { 32 | public final @Nonnull PointF scale; 33 | 34 | WithSize(float x, float y) { 35 | this.scale = new PointF(x, y); 36 | } 37 | } 38 | 39 | @Nonnull 40 | @Override 41 | public String toString() { 42 | if (this instanceof WithMode) { 43 | return String.format(Locale.ROOT, "Scale.WithMode(%s)", ((WithMode) this).mode.toString()); 44 | } 45 | 46 | if (this instanceof WithSize) { 47 | return String.format( 48 | Locale.ROOT, "Scale.WithSize(%f, %f)", ((WithSize) this).scale.x, ((WithSize) this).scale.y 49 | ); 50 | } 51 | 52 | throw Assertions.assertUnreachable("ImageFilterKit: unknown Scale subclass"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/SharedRenderscript.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import android.content.Context; 4 | 5 | import android.renderscript.RenderScript; 6 | 7 | public class SharedRenderscript { 8 | private static volatile SharedRenderscript sInstance = null; 9 | 10 | private final RenderScript mRenderscript; 11 | 12 | private SharedRenderscript(final Context context) { 13 | mRenderscript = RenderScript.create(context); 14 | } 15 | 16 | public RenderScript script() { 17 | return mRenderscript; 18 | } 19 | 20 | public static SharedRenderscript getInstance(final Context context) { 21 | if (sInstance == null) { 22 | synchronized (SharedRenderscript.class) { 23 | if (sInstance == null) { 24 | sInstance = new SharedRenderscript(context); 25 | } 26 | } 27 | } 28 | 29 | return sInstance; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/Transform.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import android.graphics.PointF; 4 | 5 | import java.util.Locale; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | public class Transform { 10 | public final @Nonnull PointF anchor; 11 | public final @Nonnull PointF translate; 12 | public final @Nonnull Scale scale; 13 | public final float rotate; 14 | 15 | public Transform( 16 | @Nonnull PointF anchor, 17 | @Nonnull PointF translate, 18 | @Nonnull Scale scale, 19 | float rotate 20 | ) { 21 | this.anchor = anchor; 22 | this.translate = translate; 23 | this.rotate = rotate; 24 | this.scale = scale; 25 | } 26 | 27 | @Nonnull 28 | @Override 29 | public String toString() { 30 | return String.format( 31 | Locale.ROOT, 32 | "Transform(%f, %f, %f, %f, %s, %f)", 33 | anchor.x, 34 | anchor.y, 35 | translate.x, 36 | translate.y, 37 | scale.toString(), 38 | rotate 39 | ); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/WeakFilterableImage.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit; 2 | 3 | import com.facebook.imagepipeline.request.Postprocessor; 4 | 5 | import java.lang.ref.WeakReference; 6 | import java.util.ArrayList; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | class WeakFilterableImage { 12 | 13 | private final @Nonnull ArrayList> mPostProcessors; 14 | private final boolean mCacheDisabled; 15 | 16 | WeakFilterableImage( 17 | final @Nonnull ArrayList postProcessors, 18 | final boolean cacheDisabled 19 | ) { 20 | mCacheDisabled = cacheDisabled; 21 | mPostProcessors = new ArrayList<>(); 22 | 23 | for (Postprocessor p : postProcessors) { 24 | mPostProcessors.add(new WeakReference<>(p)); 25 | } 26 | } 27 | 28 | @Nullable ArrayList getPostProcessors() { 29 | ArrayList ps = new ArrayList<>(); 30 | 31 | for (WeakReference weak : mPostProcessors) { 32 | Postprocessor p = weak.get(); 33 | 34 | if (p == null) { 35 | return null; 36 | } 37 | 38 | ps.add(p); 39 | } 40 | 41 | return ps; 42 | } 43 | 44 | boolean isCacheDisabled() { 45 | return mCacheDisabled; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/nativeplatform/ColorPostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.nativeplatform; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.facebook.cache.common.CacheKey; 7 | import com.facebook.cache.common.SimpleCacheKey; 8 | 9 | import org.json.JSONObject; 10 | 11 | import java.util.Locale; 12 | 13 | import javax.annotation.Nonnull; 14 | import javax.annotation.Nullable; 15 | 16 | import iyegoroff.imagefilterkit.InputConverter; 17 | import iyegoroff.imagefilterkit.utility.GeneratorPostProcessor; 18 | 19 | public class ColorPostProcessor extends GeneratorPostProcessor { 20 | 21 | private final int mColor; 22 | 23 | public ColorPostProcessor(int width, int height, @Nullable JSONObject config) { 24 | super(width, height, config); 25 | 26 | InputConverter converter = new InputConverter(width, height); 27 | 28 | mColor = converter.convertColor(config, "color", 0); 29 | } 30 | 31 | @Override 32 | public String getName() { 33 | return "ColorPostProcessor"; 34 | } 35 | 36 | @Override 37 | public void processGenerated(@Nonnull Paint paint, @Nonnull Canvas canvas) { 38 | paint.setColor(mColor); 39 | 40 | super.processGenerated(paint, canvas); 41 | } 42 | 43 | @Nonnull 44 | @Override 45 | public CacheKey generateCacheKey() { 46 | return new SimpleCacheKey( 47 | String.format(Locale.ROOT,"color_%d_%d_%d", mColor, mWidth, mHeight) 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/nativeplatform/IterativeBoxBlurPostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.nativeplatform; 2 | 3 | import com.facebook.cache.common.CacheKey; 4 | 5 | import org.json.JSONObject; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | 10 | import iyegoroff.imagefilterkit.InputConverter; 11 | import iyegoroff.imagefilterkit.utility.CacheablePostProcessor; 12 | 13 | public class IterativeBoxBlurPostProcessor extends com.facebook.imagepipeline.postprocessors.IterativeBoxBlurPostProcessor { 14 | 15 | private final boolean mCacheDisabled; 16 | 17 | private static int iterations( 18 | @Nullable JSONObject config, 19 | @Nonnull InputConverter converter 20 | ) { 21 | return (int) converter.convertScalar(config, "iterations", 3); 22 | } 23 | 24 | private static int blurRadius( 25 | @Nullable JSONObject config, 26 | @Nonnull InputConverter converter 27 | ) { 28 | return (int) converter.convertScalar(config, "blurRadius", 3); 29 | } 30 | 31 | public IterativeBoxBlurPostProcessor(int width, int height, @Nullable JSONObject config) { 32 | super( 33 | IterativeBoxBlurPostProcessor.iterations(config, new InputConverter(width, height)), 34 | IterativeBoxBlurPostProcessor.blurRadius(config, new InputConverter(width, height)) 35 | ); 36 | 37 | mCacheDisabled = CacheablePostProcessor.cacheDisabled(config); 38 | } 39 | 40 | @Override 41 | public String getName() { 42 | return "IterativeBoxBlurPostProcessor"; 43 | } 44 | 45 | @Nullable 46 | @Override 47 | public CacheKey getPostprocessorCacheKey() { 48 | return mCacheDisabled ? null : super.getPostprocessorCacheKey(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/nativeplatform/RoundAsCirclePostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.nativeplatform; 2 | 3 | import com.facebook.cache.common.CacheKey; 4 | import com.facebook.imagepipeline.postprocessors.RoundAsCirclePostprocessor; 5 | 6 | import org.json.JSONObject; 7 | 8 | import javax.annotation.Nullable; 9 | 10 | import iyegoroff.imagefilterkit.utility.CacheablePostProcessor; 11 | 12 | public class RoundAsCirclePostProcessor extends RoundAsCirclePostprocessor { 13 | 14 | private final boolean mCacheDisabled; 15 | 16 | public RoundAsCirclePostProcessor(@Nullable JSONObject config) { 17 | super(); 18 | 19 | mCacheDisabled = CacheablePostProcessor.cacheDisabled(config); 20 | } 21 | 22 | @Override 23 | public String getName() { 24 | return "RoundAsCirclePostProcessor"; 25 | } 26 | 27 | @Nullable 28 | @Override 29 | public CacheKey getPostprocessorCacheKey() { 30 | return mCacheDisabled ? null : super.getPostprocessorCacheKey(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/nativeplatform/shape/CircleShapePostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.nativeplatform.shape; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.graphics.Paint; 6 | 7 | import com.facebook.cache.common.CacheKey; 8 | import com.facebook.cache.common.SimpleCacheKey; 9 | 10 | import org.json.JSONObject; 11 | 12 | import java.util.Locale; 13 | 14 | import javax.annotation.Nonnull; 15 | import javax.annotation.Nullable; 16 | 17 | import iyegoroff.imagefilterkit.InputConverter; 18 | import iyegoroff.imagefilterkit.utility.GeneratorPostProcessor; 19 | 20 | public class CircleShapePostProcessor extends GeneratorPostProcessor { 21 | 22 | private final float mRadius; 23 | private final int mColor; 24 | 25 | public CircleShapePostProcessor(int width, int height, @Nullable JSONObject config) { 26 | super(width, height, config); 27 | 28 | InputConverter converter = new InputConverter(width, height); 29 | 30 | mRadius = converter.convertDistance(config, "radius", "50min"); 31 | mColor = converter.convertColor(config, "color", Color.BLACK); 32 | } 33 | 34 | @Override 35 | public String getName() { 36 | return "CircleShapePostProcessor"; 37 | } 38 | 39 | @Override 40 | public void processGenerated(@Nonnull Paint paint, @Nonnull Canvas canvas) { 41 | paint.setAntiAlias(true); 42 | paint.setColor(mColor); 43 | 44 | canvas.drawCircle(mWidth / 2.0f, mHeight / 2.0f, mRadius, paint); 45 | } 46 | 47 | @Nonnull 48 | @Override 49 | public CacheKey generateCacheKey() { 50 | return new SimpleCacheKey( 51 | String.format(Locale.ROOT, "circle_shape_%f_%d_%d_%d", mRadius, mColor, mWidth, mHeight) 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/utility/CacheablePostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.utility; 2 | 3 | import com.facebook.cache.common.CacheKey; 4 | import com.facebook.imagepipeline.request.BasePostprocessor; 5 | 6 | import org.json.JSONObject; 7 | 8 | import java.util.Objects; 9 | 10 | import javax.annotation.Nullable; 11 | 12 | public abstract class CacheablePostProcessor extends BasePostprocessor { 13 | 14 | private CacheKey mCacheKey = null; 15 | private final boolean mCacheDisabled; 16 | 17 | public static boolean cacheDisabled(@Nullable JSONObject config) { 18 | return (config != null && config.optJSONObject("disableCache") != null) && 19 | Objects.requireNonNull(config.optJSONObject("disableCache")).optBoolean("bool", false); 20 | } 21 | 22 | public CacheablePostProcessor(@Nullable JSONObject config) { 23 | mCacheDisabled = cacheDisabled(config); 24 | } 25 | 26 | @Nullable 27 | @Override 28 | public CacheKey getPostprocessorCacheKey() { 29 | if (mCacheKey == null && !mCacheDisabled) { 30 | mCacheKey = generateCacheKey(); 31 | } 32 | 33 | return mCacheKey; 34 | } 35 | 36 | public abstract CacheKey generateCacheKey(); 37 | } 38 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/utility/DummyPostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.utility; 2 | 3 | import com.facebook.cache.common.CacheKey; 4 | import com.facebook.cache.common.SimpleCacheKey; 5 | import com.facebook.imagepipeline.request.BasePostprocessor; 6 | 7 | public class DummyPostProcessor extends BasePostprocessor { 8 | 9 | private CacheKey mCacheKey = new SimpleCacheKey("dummy"); 10 | 11 | public DummyPostProcessor() { 12 | } 13 | 14 | @Override 15 | public String getName() { 16 | return "DummyPostProcessor"; 17 | } 18 | 19 | @Override 20 | public CacheKey getPostprocessorCacheKey() { 21 | return mCacheKey; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /android/src/main/java/iyegoroff/imagefilterkit/utility/GeneratorPostProcessor.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.utility; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Rect; 7 | 8 | import com.facebook.common.references.CloseableReference; 9 | import com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory; 10 | 11 | import org.json.JSONObject; 12 | 13 | import javax.annotation.Nonnull; 14 | import javax.annotation.Nullable; 15 | 16 | import iyegoroff.imagefilterkit.MainReactPackageWithFrescoCache; 17 | 18 | public abstract class GeneratorPostProcessor extends CacheablePostProcessor { 19 | 20 | protected final int mWidth; 21 | protected final int mHeight; 22 | 23 | public GeneratorPostProcessor(int width, int height, @Nullable JSONObject config) { 24 | super(config); 25 | 26 | mWidth = width; 27 | mHeight = height; 28 | } 29 | 30 | public void processGenerated(@Nonnull Paint paint, @Nonnull Canvas canvas) { 31 | canvas.drawRect(new Rect(0, 0, mWidth, mHeight), paint); 32 | } 33 | 34 | @Override 35 | public CloseableReference process( 36 | Bitmap src, 37 | PlatformBitmapFactory bitmapFactory 38 | ) { 39 | final CloseableReference bitmapRef = bitmapFactory 40 | .createBitmap(mWidth, mHeight, MainReactPackageWithFrescoCache.bitmapsConfig()); 41 | 42 | try { 43 | final Bitmap dst = bitmapRef.get(); 44 | final Canvas canvas = new Canvas(dst); 45 | final Paint paint = new Paint(); 46 | 47 | processGenerated(paint, canvas); 48 | 49 | return CloseableReference.cloneOrNull(bitmapRef); 50 | } finally { 51 | CloseableReference.closeSafely(bitmapRef); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/ColorBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "BlendUtils.rsh" 6 | 7 | rs_allocation srcImage; 8 | float4 srcColor; 9 | 10 | static inline float4 color(const float4 dst, const float4 src) { 11 | float4 srcDstAlpha = src * dst.a; 12 | float4 out; 13 | 14 | out.a = src.a + (1.0f - src.a) * dst.a; 15 | out.rgb = setLuminance(srcDstAlpha.rgb, srcDstAlpha.a, dst.rgb * src.a); 16 | out.rgb += (1.0 - src.a) * dst.rgb + (1.0 - dst.a) * src.rgb; 17 | 18 | return out; 19 | } 20 | 21 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 22 | return rsPackColorTo8888(color( 23 | rsUnpackColor8888(dst), 24 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 25 | )); 26 | } 27 | 28 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 29 | return rsPackColorTo8888(color(rsUnpackColor8888(dst), srcColor)); 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/ColorBurnBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float colorBurnComponent(float dstC, float srcC, float dstA, float srcA) { 9 | if (dstA == dstC) { 10 | return srcA * dstA + srcC * (1.0f - dstA) + dstC * (1.0f - srcA); 11 | 12 | } else if (0.0f == srcC) { 13 | return dstC * (1.0f - srcA); 14 | 15 | } else { 16 | float d = max(0.0f, dstA - (dstA - dstC) * srcA / srcC); 17 | 18 | return srcA * d + srcC * (1.0f - dstA) + dstC * (1.0f - srcA); 19 | } 20 | } 21 | 22 | static inline float4 colorBurn(const float4 dst, const float4 src) { 23 | return (float4){ 24 | colorBurnComponent(dst.r, src.r, dst.a, src.a), 25 | colorBurnComponent(dst.g, src.g, dst.a, src.a), 26 | colorBurnComponent(dst.b, src.b, dst.a, src.a), 27 | src.a + (1.0f - src.a) * dst.a 28 | }; 29 | } 30 | 31 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 32 | return rsPackColorTo8888(colorBurn( 33 | rsUnpackColor8888(dst), 34 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 35 | )); 36 | } 37 | 38 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 39 | return rsPackColorTo8888(colorBurn(rsUnpackColor8888(dst), srcColor)); 40 | } 41 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/ColorDodgeBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float colorDodgeComponent(float dstC, float srcC, float dstA, float srcA) { 9 | if (0.0f == dstC) { 10 | return srcC * (1.0f - dstA); 11 | 12 | } else { 13 | float d = srcA - srcC; 14 | 15 | if (0.0f == d) { 16 | return srcA * dstA + srcC * (1.0f - dstA) + dstC * (1.0f - srcA); 17 | 18 | } else { 19 | d = min(dstA, dstC * srcA / d); 20 | 21 | return d * srcA + srcC * (1.0f - dstA) + dstC * (1.0f - srcA); 22 | } 23 | } 24 | } 25 | 26 | static inline float4 colorDodge(const float4 dst, const float4 src) { 27 | return (float4){ 28 | colorDodgeComponent(dst.r, src.r, dst.a, src.a), 29 | colorDodgeComponent(dst.g, src.g, dst.a, src.a), 30 | colorDodgeComponent(dst.b, src.b, dst.a, src.a), 31 | src.a + (1.0f - src.a) * dst.a 32 | }; 33 | } 34 | 35 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 36 | return rsPackColorTo8888(colorDodge( 37 | rsUnpackColor8888(dst), 38 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 39 | )); 40 | } 41 | 42 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 43 | return rsPackColorTo8888(colorDodge(rsUnpackColor8888(dst), srcColor)); 44 | } 45 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/DifferenceBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float4 difference(const float4 dst, const float4 src) { 9 | float4 out; 10 | 11 | out.a = src.a + (1.0f - src.a) * dst.a; 12 | out.rgb = src.rgb + dst.rgb - 2.0f * min(src.rgb * dst.a, dst.rgb * src.a); 13 | 14 | return out; 15 | } 16 | 17 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 18 | return rsPackColorTo8888(difference( 19 | rsUnpackColor8888(dst), 20 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 21 | )); 22 | } 23 | 24 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 25 | return rsPackColorTo8888(difference(rsUnpackColor8888(dst), srcColor)); 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/ExclusionBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float4 exclusion(const float4 dst, const float4 src) { 9 | float4 out; 10 | 11 | out.a = src.a + (1.0f - src.a) * dst.a; 12 | out.rgb = dst.rgb + src.rgb - 2.0f * dst.rgb * src.rgb; 13 | 14 | return out; 15 | } 16 | 17 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 18 | return rsPackColorTo8888(exclusion( 19 | rsUnpackColor8888(dst), 20 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 21 | )); 22 | } 23 | 24 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 25 | return rsPackColorTo8888(exclusion(rsUnpackColor8888(dst), srcColor)); 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/HardLightBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float hardLightComponent(float dstC, float srcC, float dstA, float srcA) { 9 | return (2.0f * srcC <= srcA) 10 | ? 2.0f * srcC * dstC 11 | : srcA * dstA - 2.0f * (dstA - dstC) * (srcA - srcC); 12 | } 13 | 14 | static inline float4 hardLight(const float4 dst, const float4 src) { 15 | float4 out = (float4){ 16 | hardLightComponent(dst.r, src.r, dst.a, src.a), 17 | hardLightComponent(dst.g, src.g, dst.a, src.a), 18 | hardLightComponent(dst.b, src.b, dst.a, src.a), 19 | src.a + (1.0f - src.a) * dst.a 20 | }; 21 | out.rgb += src.rgb * (1.0f - dst.a) + dst.rgb * (1.0f - src.a); 22 | 23 | return out; 24 | } 25 | 26 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 27 | return rsPackColorTo8888(hardLight( 28 | rsUnpackColor8888(dst), 29 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 30 | )); 31 | } 32 | 33 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 34 | return rsPackColorTo8888(hardLight(rsUnpackColor8888(dst), srcColor)); 35 | } 36 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/HueBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "BlendUtils.rsh" 6 | 7 | rs_allocation srcImage; 8 | float4 srcColor; 9 | 10 | static inline float4 hue(const float4 dst, const float4 src) { 11 | float4 dstSrcAlpha = dst * src.a; 12 | float4 out; 13 | 14 | out.a = src.a + (1.0f - src.a) * dst.a; 15 | out.rgb = setLuminance( 16 | setSaturation(src.rgb * dst.a, dstSrcAlpha.rgb), 17 | dstSrcAlpha.a, 18 | dstSrcAlpha.rgb 19 | ); 20 | out.rgb += (1.0f - src.a) * dst.rgb + (1.0f - dst.a) * src.rgb; 21 | 22 | return out; 23 | } 24 | 25 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 26 | return rsPackColorTo8888(hue( 27 | rsUnpackColor8888(dst), 28 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 29 | )); 30 | } 31 | 32 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 33 | return rsPackColorTo8888(hue(rsUnpackColor8888(dst), srcColor)); 34 | } 35 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/LuminosityBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "BlendUtils.rsh" 6 | 7 | rs_allocation srcImage; 8 | float4 srcColor; 9 | 10 | static inline float4 luminosity(const float4 dst, const float4 src) { 11 | float4 srcDstAlpha = src * dst.a; 12 | float4 out; 13 | 14 | out.a = src.a + (1.0f - src.a) * dst.a; 15 | out.rgb = setLuminance(dst.rgb * src.a, srcDstAlpha.a, srcDstAlpha.rgb); 16 | out.rgb += (1.0 - src.a) * dst.rgb + (1.0 - dst.a) * src.rgb; 17 | 18 | return out; 19 | } 20 | 21 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 22 | return rsPackColorTo8888(luminosity( 23 | rsUnpackColor8888(dst), 24 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 25 | )); 26 | } 27 | 28 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 29 | return rsPackColorTo8888(luminosity(rsUnpackColor8888(dst), srcColor)); 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/MultiplyBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | float4 srcColor; 7 | 8 | static inline float4 multiply(const float4 dst, const float4 src) { 9 | float4 out; 10 | 11 | out.a = src.a + (1.0f - src.a) * dst.a; 12 | out.rgb = (1.0f - src.a) * dst.rgb + (1.0f - dst.a) * src.rgb + src.rgb * dst.rgb; 13 | 14 | return out; 15 | } 16 | 17 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 18 | return rsPackColorTo8888(multiply( 19 | rsUnpackColor8888(dst), 20 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 21 | )); 22 | } 23 | 24 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 25 | return rsPackColorTo8888(multiply(rsUnpackColor8888(dst), srcColor)); 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/rs/blend/SaturationBlend.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.blend) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "BlendUtils.rsh" 6 | 7 | rs_allocation srcImage; 8 | float4 srcColor; 9 | 10 | static inline float4 saturation(const float4 dst, const float4 src) { 11 | float4 dstSrcAlpha = dst * src.a; 12 | float4 out; 13 | 14 | out.a = src.a + (1.0f - src.a) * dst.a; 15 | out.rgb = setLuminance( 16 | setSaturation(dstSrcAlpha.rgb, src.rgb * dst.a), 17 | dstSrcAlpha.a, 18 | dstSrcAlpha.rgb 19 | ); 20 | out.rgb += (1.0f - src.a) * dst.rgb + (1.0f - dst.a) * src.rgb; 21 | 22 | return out; 23 | } 24 | 25 | uchar4 RS_KERNEL blendImage(uchar4 dst, uint32_t x, uint32_t y) { 26 | return rsPackColorTo8888(saturation( 27 | rsUnpackColor8888(dst), 28 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 29 | )); 30 | } 31 | 32 | uchar4 RS_KERNEL blendColor(uchar4 dst, uint32_t x, uint32_t y) { 33 | return rsPackColorTo8888(saturation(rsUnpackColor8888(dst), srcColor)); 34 | } 35 | -------------------------------------------------------------------------------- /android/src/main/rs/compositing/DestinationATopCompositing.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.compositing) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | 7 | static inline float4 destinationATop(const float4 dst, const float4 src) { 8 | float4 out; 9 | 10 | out.rgb = src.a * dst.rgb + (1.0f - dst.a) * src.rgb; 11 | out.a = src.a; 12 | 13 | return out; 14 | } 15 | 16 | uchar4 RS_KERNEL composeImage(uchar4 dst, uint32_t x, uint32_t y) { 17 | return rsPackColorTo8888(destinationATop( 18 | rsUnpackColor8888(dst), 19 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 20 | )); 21 | } 22 | -------------------------------------------------------------------------------- /android/src/main/rs/compositing/DestinationInCompositing.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.compositing) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | 7 | static inline float4 destinationIn(const float4 dst, const float4 src) { 8 | float4 out; 9 | 10 | out.rgb = dst.rgb * src.a; 11 | out.a = src.a * dst.a; 12 | 13 | return out; 14 | } 15 | 16 | uchar4 RS_KERNEL composeImage(uchar4 dst, uint32_t x, uint32_t y) { 17 | return rsPackColorTo8888(destinationIn( 18 | rsUnpackColor8888(dst), 19 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 20 | )); 21 | } 22 | -------------------------------------------------------------------------------- /android/src/main/rs/compositing/SourceInCompositing.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.compositing) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | 7 | static inline float4 sourceIn(const float4 dst, const float4 src) { 8 | float4 out; 9 | 10 | out.rgb = src.rgb * dst.a; 11 | out.a = src.a * dst.a; 12 | 13 | return out; 14 | } 15 | 16 | uchar4 RS_KERNEL composeImage(uchar4 dst, uint32_t x, uint32_t y) { 17 | return rsPackColorTo8888(sourceIn( 18 | rsUnpackColor8888(dst), 19 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 20 | )); 21 | } 22 | -------------------------------------------------------------------------------- /android/src/main/rs/compositing/SourceOutCompositing.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.compositing) 3 | #pragma rs_fp_relaxed 4 | 5 | rs_allocation srcImage; 6 | 7 | static inline float4 sourceOut(const float4 dst, const float4 src) { 8 | float4 out; 9 | 10 | out.rgb = (1.0f - dst.a) * src.rgb; 11 | out.a = (1.0f - dst.a) * src.a; 12 | 13 | return out; 14 | } 15 | 16 | uchar4 RS_KERNEL composeImage(uchar4 dst, uint32_t x, uint32_t y) { 17 | return rsPackColorTo8888(sourceOut( 18 | rsUnpackColor8888(dst), 19 | rsUnpackColor8888(*(const uchar4*)rsGetElementAt(srcImage, x, y)) 20 | )); 21 | } 22 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/EllipticalGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "GradientUtils.rsh" 6 | 7 | int amount; 8 | int mixStep; 9 | float radiusX; 10 | float radiusY; 11 | float centerX; 12 | float centerY; 13 | float positions[MAX_COLORS]; 14 | float4 colors[MAX_COLORS]; 15 | 16 | static inline float radius(uint32_t x, uint32_t y, float2 center, float radiusX, float radiusY) { 17 | float rad = atan2((float)y - center.y, (float)x - center.x); 18 | 19 | return (radiusX * radiusY) / 20 | sqrt(radiusX * radiusX * sin(rad) * sin(rad) + radiusY * radiusY * cos(rad) * cos(rad)); 21 | } 22 | 23 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 24 | float2 center = (float2){centerX, centerY}; 25 | 26 | float d = distance(center, (float2){x, y}) / radius(x, y, center, radiusX, radiusY); 27 | float4 color = colors[0]; 28 | 29 | for (int i = 1; i < amount; i++) { 30 | color = mix( 31 | color, 32 | colors[i], 33 | mixStep == CLAMP_STEP 34 | ? clampstep(positions[i - 1], positions[i], d) 35 | : smoothstep(positions[i - 1], positions[i], d) 36 | ); 37 | } 38 | 39 | return rsPackColorTo8888(color); 40 | } 41 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/GradientUtils.rsh: -------------------------------------------------------------------------------- 1 | #ifndef __RNIFK_GRADIENT_UTILS_RSH__ 2 | #define __RNIFK_GRADIENT_UTILS_RSH__ 3 | 4 | #define MAX_COLORS 10 5 | 6 | #define CLAMP_STEP 0 7 | #define SMOOTH_STEP 1 8 | 9 | static inline float clampstep(float edge0, float edge1, float x) { 10 | return clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); 11 | } 12 | 13 | static inline float smoothstep(float edge0, float edge1, float x) { 14 | float value = clampstep(edge0, edge1, x); 15 | 16 | return value * value * (3.0f - 2.0f * value); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/QuadGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | uint32_t width; 6 | uint32_t height; 7 | float4 bottomLeftColor; 8 | float4 bottomRightColor; 9 | float4 topLeftColor; 10 | float4 topRightColor; 11 | 12 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 13 | float2 uv = (float2){x / (float)width, y / (float)height}; 14 | float4 color = mix( 15 | mix(bottomLeftColor, bottomRightColor, uv.x), 16 | mix(topLeftColor, topRightColor, uv.x), 17 | uv.y 18 | ); 19 | 20 | return rsPackColorTo8888(color); 21 | } 22 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/RectangularGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "GradientUtils.rsh" 6 | 7 | int amount; 8 | int mixStep; 9 | float halfWidth; 10 | float halfHeight; 11 | float centerX; 12 | float centerY; 13 | float positions[MAX_COLORS]; 14 | float4 colors[MAX_COLORS]; 15 | 16 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 17 | float2 uv = (float2){x, y}; 18 | float d = fmax( 19 | fabs(uv.x - centerX) / (halfWidth * 2.0f), 20 | fabs(uv.y - centerY) / (halfHeight * 2.0f) 21 | ) * 2.0f; 22 | float4 color = colors[0]; 23 | 24 | for (int i = 1; i < amount; i++) { 25 | color = mix( 26 | color, 27 | colors[i], 28 | mixStep == CLAMP_STEP 29 | ? clampstep(positions[i - 1], positions[i], d) 30 | : smoothstep(positions[i - 1], positions[i], d) 31 | ); 32 | } 33 | 34 | return rsPackColorTo8888(color); 35 | } 36 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/SmoothLinearGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "GradientUtils.rsh" 6 | 7 | int amount; 8 | float x0; 9 | float y0; 10 | float x1; 11 | float y1; 12 | float positions[MAX_COLORS]; 13 | float4 colors[MAX_COLORS]; 14 | 15 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 16 | float2 start = (float2){x0, y0}; 17 | float2 end = (float2){x1, y1}; 18 | float2 dt = end - start; 19 | float2 pt = (float2){(float)x, (float)y} - start; 20 | float d = dot(pt, dt) / dot(dt, dt); 21 | float4 color = colors[0]; 22 | 23 | for (int i = 1; i < amount; i++) { 24 | color = mix(color, colors[i], smoothstep(positions[i - 1], positions[i], d)); 25 | } 26 | 27 | return rsPackColorTo8888(color); 28 | } 29 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/SmoothRadialGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "GradientUtils.rsh" 6 | 7 | int amount; 8 | float radius; 9 | float centerX; 10 | float centerY; 11 | float positions[MAX_COLORS]; 12 | float4 colors[MAX_COLORS]; 13 | 14 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 15 | float d = distance((float2){centerX, centerY}, (float2){x, y}) / radius; 16 | float4 color = colors[0]; 17 | 18 | for (int i = 1; i < amount; i++) { 19 | color = mix(color, colors[i], smoothstep(positions[i - 1], positions[i], d)); 20 | } 21 | 22 | return rsPackColorTo8888(color); 23 | } 24 | -------------------------------------------------------------------------------- /android/src/main/rs/gradients/SmoothSweepGradient.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.gradients) 3 | #pragma rs_fp_relaxed 4 | 5 | #include "GradientUtils.rsh" 6 | 7 | int amount; 8 | float centerX; 9 | float centerY; 10 | float positions[MAX_COLORS]; 11 | float4 colors[MAX_COLORS]; 12 | 13 | uchar4 RS_KERNEL generate(uchar4 src, uint32_t x, uint32_t y) { 14 | float d = (atan2(-(float)y + centerY, -(float)x + centerX) + M_PI) / (2.0f * M_PI); 15 | float4 color = colors[0]; 16 | 17 | for (int i = 1; i < amount; i++) { 18 | color = mix(color, colors[i], smoothstep(positions[i - 1], positions[i], d)); 19 | } 20 | 21 | return rsPackColorTo8888(color); 22 | } 23 | -------------------------------------------------------------------------------- /docs/blur_filters.md: -------------------------------------------------------------------------------- 1 | # Blur filters 2 | 3 | - [BoxBlur](#BoxBlur) 4 | - [GaussianBlur](#GaussianBlur) 5 | 6 | ----- 7 | 8 | #### BoxBlur 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
proptypedefaultdesc
imageFilterable-required
radiusnumber5
30 | 31 | *** 32 | 33 | #### GaussianBlur 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
proptypedefaultdesc
imageFilterable-required
radiusnumber5between 1..12,5
-------------------------------------------------------------------------------- /docs/image_extraction.md: -------------------------------------------------------------------------------- 1 | # Image extraction 2 | 3 | Supported since v0.7.0 4 | 5 | Resulting images can be extracted into the file system with onExtractImage prop. It returns path to a temporary file inside cache folder that contains filtering result and triggers when 6 | extractImageEnabled changes to true. While extractImageEnabled 7 | remains truthy onExtractImage will trigger every time filtering result changes. 8 | To delete all temporary files created this way you need to call 9 | cleanExtractedImagesCache function. Since 10 | these files are saved to cache folder they can be removed by user or system at any time. Usage example. 11 | 12 | ```ts 13 | dispatch(['show-error', new Error(nativeEvent.message)]) 17 | } 18 | onExtractImage={({ nativeEvent }) => dispatch(['save-photo', nativeEvent.uri])} 19 | extractImageEnabled={true} 20 | image={ 21 | 25 | } 26 | /> 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/manual_installation.md: -------------------------------------------------------------------------------- 1 | ### Manual installation 2 | 3 | 4 | #### iOS 5 | 6 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` 7 | 2. Go to `node_modules` ➜ `react-native-image-filter-kit` and add `RNImageFilterKit.xcodeproj` 8 | 3. In XCode, in the project navigator, select your project. Add `libRNImageFilterKit.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` 9 | 4. Linking `cikernel` resources: add resources from `node_modules/react-native-image-filter-kit/ios/Resources` to your project's `Build Phases` ➜ `Copy Bundle Resources` 10 | 5. Run your project (`Cmd+R`)< 11 | 12 | #### Android 13 | 14 | 1. Open up `android/app/src/main/java/[...]/MainApplication.java` 15 | - Add `import iyegoroff.imagefilterkit.ImageFilterKitPackage;` to the imports at the top of the file 16 | - Add `new ImageFilterKitPackage()` to the list returned by the `getPackages()` method 17 | 2. Append the following lines to `android/settings.gradle`: 18 | ``` 19 | include ':react-native-image-filter-kit' 20 | project(':react-native-image-filter-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-filter-kit/android') 21 | ``` 22 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: 23 | ``` 24 | compile project(':react-native-image-filter-kit') 25 | ``` 26 | -------------------------------------------------------------------------------- /examples/CustomFilter/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /examples/CustomFilter/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /examples/CustomFilter/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | infer-out/ 3 | xcodebuild.log 4 | src/obj/ 5 | src/bin/ 6 | **/.DS_Store 7 | .gradle/ 8 | compile_commands.json 9 | rn-cli.config.js 10 | *.apk 11 | build/ 12 | -------------------------------------------------------------------------------- /examples/CustomFilter/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/CustomFilter/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM iyegoroff/ubuntu-node-android-git:3 2 | 3 | RUN mkdir /package 4 | COPY . /package 5 | WORKDIR /package/examples/CustomFilter 6 | 7 | RUN npm i -g yarn@1.22.4 8 | RUN yarn 9 | RUN npm run generate:android:bundle 10 | RUN rm -rf node_modules/.bin && rm -rf ../../node_modules/.bin 11 | RUN cd android && ./gradlew assembleRelease 12 | -------------------------------------------------------------------------------- /examples/CustomFilter/README.md: -------------------------------------------------------------------------------- 1 | #### Description 2 | Example shows how to create and use a set of JS/TS-only custom filters. 3 | 4 | ### Run debug version 5 | ```bash 6 | $ yarn 7 | $ yarn run:android 8 | ``` 9 | 10 | ### Build signed release apk with Docker 11 | - Generate keystore `yarn generate:android:signing-key` 12 | - Open `examples/CustomFilter/android/gradle.properties` file and replace `qwerty`s with your passwords 13 | - Run `yarn build:release:docker` - upon script completion apk will be copied to `examples/CustomFilter/custom-filter.apk` file 14 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | .idea 4 | .gradle 5 | local.properties 6 | *.iml 7 | .DS_Store 8 | app/*.keystore 9 | !app/debug.keystore 10 | app/src/main/assets/*.bundle 11 | app/src/main/res/drawable-* 12 | gradle-yandex.properties -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/debug.keystore -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/assets/.gitkeep -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/java/com/customfilter/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.customfilter; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "CustomFilter"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomFilter 3 | 4 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | ndkVersion = "20.1.5948944" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.1.0") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.75.1 29 | 30 | EXAMPLE_RELEASE_STORE_FILE=example.keystore 31 | EXAMPLE_RELEASE_KEY_ALIAS=example 32 | EXAMPLE_RELEASE_STORE_PASSWORD=qwerty 33 | EXAMPLE_RELEASE_KEY_PASSWORD=qwerty 34 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomFilter/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/CustomFilter/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/CustomFilter/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'CustomFilter' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /examples/CustomFilter/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CustomFilter", 3 | "displayName": "CustomFilter" 4 | } -------------------------------------------------------------------------------- /examples/CustomFilter/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /examples/CustomFilter/index.js: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import {AppRegistry} from 'react-native'; 4 | import App from './build/App'; 5 | import {name as appName} from './app.json'; 6 | 7 | AppRegistry.registerComponent(appName, () => App); 8 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | project.xcworkspace 19 | compile_commands.json 20 | xcodebuild.log 21 | .DS_Store 22 | Pods 23 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/CustomFilter/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/CustomFilter/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'CustomFilter' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | # Enables Flipper. 16 | # 17 | # Note that if you have use_frameworks! enabled, Flipper will not work and 18 | # you should disable the next line. 19 | use_flipper!() 20 | 21 | post_install do |installer| 22 | react_native_post_install(installer) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /examples/CustomFilter/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path') 9 | const blacklist = require('metro-config/src/defaults/exclusionList') 10 | 11 | const packagePath = path.resolve(__dirname, '../../') 12 | 13 | const extraNodeModules = { 14 | 'react': path.resolve(__dirname, 'node_modules/react'), 15 | 'react-native': path.resolve(__dirname, 'node_modules/react-native'), 16 | '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'), 17 | 'react-native-image-filter-kit': packagePath 18 | }; 19 | 20 | module.exports = { 21 | resolver: { 22 | extraNodeModules, 23 | blockList: blacklist([ 24 | /^src[/\\].*/, 25 | /^examples[/\\]\w+[/\\]src[/\\].*/ 26 | ]) 27 | }, 28 | watchFolders: [packagePath], 29 | transformer: { 30 | getTransformOptions: async () => ({ 31 | transform: { 32 | experimentalImportSupport: false, 33 | inlineRequires: false, 34 | }, 35 | }), 36 | }, 37 | } 38 | -------------------------------------------------------------------------------- /examples/CustomFilter/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { GenericImageFilter } from 'react-native-image-filter-kit' 3 | import { Image, ScrollView, Text } from 'react-native' 4 | import { Ashby, Poprocket, InstagramCSSExtensionConfig, PoprocketStandalone } from './InstagramCSS' 5 | 6 | const uri = 'https://picturepan2.github.io/instagram.css/assets/img/instagram.jpg' 7 | 8 | const style = { width: 320, height: 320, marginBottom: 25 } 9 | 10 | const textStyle = { fontSize: 20 } 11 | 12 | const image = 13 | 14 | const app = () => ( 15 | 16 | {'Ashby'} 17 | 18 | 19 | {'Poprocket'} 20 | 21 | 22 | {'PoprocketStandalone'} 23 | 24 | 25 | {'Poprocket + Ashby'} 26 | } /> 27 | 28 | {'Ashby + Poprocket'} 29 | /* in JS this can be just ImageFilter */ 30 | config={{ 31 | name: 'Poprocket', 32 | image: { 33 | name: 'Ashby', 34 | image 35 | } 36 | }} 37 | /> 38 | 39 | ) 40 | 41 | export default app 42 | -------------------------------------------------------------------------------- /examples/CustomFilter/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "baseUrl": ".", 5 | "target": "es6", 6 | "strict": true, 7 | "outDir": "../build", 8 | "jsx": "react-native", 9 | "lib": ["es6"], 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "types": [ 13 | "react", 14 | "react-native", 15 | "react-native-image-filter-kit" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | infer-out/ 3 | xcodebuild.log 4 | src/obj/ 5 | src/bin/ 6 | **/.DS_Store 7 | .gradle/ 8 | compile_commands.json 9 | rn-cli.config.js 10 | *.apk 11 | build/ 12 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/CustomNativeFilter/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM iyegoroff/ubuntu-node-android-git:3 2 | 3 | RUN mkdir /package 4 | COPY . /package 5 | WORKDIR /package/examples/CustomNativeFilter 6 | 7 | RUN npm i -g yarn@1.22.4 8 | RUN yarn 9 | RUN npm run generate:android:bundle 10 | RUN rm -rf node_modules/.bin && rm -rf ../../node_modules/.bin 11 | RUN cd android && ./gradlew assembleRelease 12 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/README.md: -------------------------------------------------------------------------------- 1 | #### Description 2 | Example shows how to [create](./local_modules/react-native-image-filter-kit-haze-removal) and use custom native filter. 3 | 4 | ### Run debug version 5 | ```bash 6 | $ yarn 7 | $ yarn run:android 8 | ``` 9 | 10 | ### Build signed release apk with Docker 11 | - Generate keystore `yarn generate:android:signing-key` 12 | - Open `examples/CustomNativeFilter/android/gradle.properties` file and replace `qwerty`s with your passwords 13 | - Run `yarn build:release:docker` - upon script completion apk will be copied to `examples/CustomNativeFilter/custom-native-filter.apk` file 14 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | .idea 4 | .gradle 5 | local.properties 6 | *.iml 7 | .DS_Store 8 | app/*.keystore 9 | !app/debug.keystore 10 | app/src/main/assets/*.bundle 11 | app/src/main/res/drawable-* 12 | gradle-yandex.properties -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/debug.keystore -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/assets/.gitkeep -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/java/com/customnativefilter/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.customnativefilter; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.ReactRootView; 6 | import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. This is used to schedule 12 | * rendering of the component. 13 | */ 14 | @Override 15 | protected String getMainComponentName() { 16 | return "CustomNativeFilter"; 17 | } 18 | 19 | @Override 20 | protected ReactActivityDelegate createReactActivityDelegate() { 21 | return new ReactActivityDelegate(this, getMainComponentName()) { 22 | @Override 23 | protected ReactRootView createRootView() { 24 | return new RNGestureHandlerEnabledRootView(MainActivity.this); 25 | } 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomNativeFilter 3 | 4 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | ndkVersion = "20.1.5948944" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.1.0") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.75.1 29 | 30 | EXAMPLE_RELEASE_STORE_FILE=example.keystore 31 | EXAMPLE_RELEASE_KEY_ALIAS=example 32 | EXAMPLE_RELEASE_STORE_PASSWORD=qwerty 33 | EXAMPLE_RELEASE_KEY_PASSWORD=qwerty 34 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/CustomNativeFilter/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'CustomNativeFilter' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CustomNativeFilter", 3 | "displayName": "CustomNativeFilter" 4 | } -------------------------------------------------------------------------------- /examples/CustomNativeFilter/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | plugins: ['react-native-reanimated/plugin'] 4 | } 5 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/index.js: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { AppRegistry } from 'react-native' 4 | import App from './build/App' 5 | import { name as appName } from './app.json' 6 | 7 | AppRegistry.registerComponent(appName, () => App) 8 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | project.xcworkspace 19 | compile_commands.json 20 | xcodebuild.log 21 | .DS_Store 22 | Pods 23 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | CustomNativeFilter 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/CustomNativeFilter/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'CustomNativeFilter' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | # Enables Flipper. 16 | # 17 | # Note that if you have use_frameworks! enabled, Flipper will not work and 18 | # you should disable the next line. 19 | use_flipper!() 20 | 21 | post_install do |installer| 22 | react_native_post_install(installer) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # OSX 3 | # 4 | .DS_Store 5 | 6 | # node.js 7 | # 8 | node_modules/ 9 | npm-debug.log 10 | yarn-error.log 11 | 12 | 13 | # Xcode 14 | # 15 | build/ 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | xcuserdata 25 | *.xccheckout 26 | *.moved-aside 27 | DerivedData 28 | *.hmap 29 | *.ipa 30 | *.xcuserstate 31 | project.xcworkspace 32 | 33 | 34 | # Android/IntelliJ 35 | # 36 | build/ 37 | .idea 38 | .gradle 39 | local.properties 40 | *.iml 41 | 42 | # BUCK 43 | buck-out/ 44 | \.buckd/ 45 | *.keystore 46 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/README.md: -------------------------------------------------------------------------------- 1 | 2 | # react-native-image-filter-kit-haze-removal 3 | 4 | Probably the best way to create your own filter(s) is to copy this folder and rename all things like 5 | `HazeRemoval`, `haze-removal`, `iyegoroff.imagefilterkit.hazeremoval`, `hazeRemoval`, 6 | `Haze Removal`, `hazeremoval`, `haze_removal`, `IFKHR` (iOS prefix) etc. 7 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | build/ 3 | .idea 4 | .gradle 5 | local.properties 6 | *.iml -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | google() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.6.0' 9 | } 10 | } 11 | 12 | apply plugin: 'com.android.library' 13 | 14 | def _ext = rootProject.ext; 15 | 16 | def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'; 17 | def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 29; 18 | def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '29.0.3'; 19 | def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21; 20 | def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 29; 21 | 22 | android { 23 | compileSdkVersion _compileSdkVersion 24 | 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | 30 | defaultConfig { 31 | minSdkVersion _minSdkVersion 32 | targetSdkVersion _targetSdkVersion 33 | versionCode 1 34 | versionName "1.0" 35 | } 36 | lintOptions { 37 | abortOnError false 38 | } 39 | } 40 | 41 | dependencies { 42 | //noinspection GradleDynamicVersion 43 | compileOnly "com.facebook.react:react-native:${_reactNativeVersion}" 44 | implementation project(':react-native-image-filter-kit') 45 | implementation fileTree(dir: "libs", include: ["*.jar"]) 46 | } 47 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':react-native-image-filter-kit' 2 | project(':react-native-image-filter-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-filter-kit/android') -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/src/main/java/iyegoroff/imagefilterkit/hazeremoval/ImageFilterKitHazeRemovalPackage.java: -------------------------------------------------------------------------------- 1 | package iyegoroff.imagefilterkit.hazeremoval; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | import com.facebook.react.ReactPackage; 7 | import com.facebook.react.bridge.NativeModule; 8 | import com.facebook.react.bridge.ReactApplicationContext; 9 | import com.facebook.react.uimanager.ViewManager; 10 | 11 | import javax.annotation.Nonnull; 12 | 13 | import iyegoroff.imagefilterkit.PostProcessorRegistry; 14 | 15 | public class ImageFilterKitHazeRemovalPackage implements ReactPackage { 16 | 17 | static { 18 | PostProcessorRegistry registry = PostProcessorRegistry.getInstance(); 19 | 20 | registry.addSingular("HazeRemoval", HazeRemovalPostProcessor::new); 21 | } 22 | 23 | @Nonnull 24 | @Override 25 | public List createNativeModules(@Nonnull ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | 29 | @Nonnull 30 | @Override 31 | public List createViewManagers(@Nonnull ReactApplicationContext reactContext) { 32 | return Collections.emptyList(); 33 | } 34 | } -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/android/src/main/rs/HazeRemoval.rs: -------------------------------------------------------------------------------- 1 | #pragma version(1) 2 | #pragma rs java_package_name(iyegoroff.imagefilterkit.hazeremoval) 3 | #pragma rs_fp_relaxed 4 | 5 | float slope; 6 | float dist; 7 | float4 color; 8 | 9 | static inline float4 premultiply(const float4 col) { 10 | return (float4){ 11 | col.r * col.a, 12 | col.g * col.a, 13 | col.b * col.a, 14 | col.a 15 | }; 16 | } 17 | 18 | static inline float4 unpremultiply(const float4 col) { 19 | return col.a > 0.0f 20 | ? (float4){ 21 | col.r / col.a, 22 | col.g / col.a, 23 | col.b / col.a, 24 | col.a 25 | } 26 | : col; 27 | } 28 | 29 | static inline float4 hazeRemoval(const float4 src, uint32_t y) { 30 | float d = y * slope + dist; 31 | 32 | return clamp(premultiply((unpremultiply(src) - d * color) / (1.0f - d)), 0.0f, 1.0f); 33 | } 34 | 35 | uchar4 RS_KERNEL filterImage(uchar4 src, uint32_t x, uint32_t y) { 36 | return rsPackColorTo8888(hazeRemoval(rsUnpackColor8888(src), y)); 37 | } 38 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/ios/IFKHRHazeRemoval.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKHRHazeRemoval : CIFilter 4 | 5 | @property (nonatomic, strong) CIImage *inputImage; 6 | @property (nonatomic, copy) CIColor *inputColor; 7 | @property (nonatomic, copy) NSNumber *inputDistance; 8 | @property (nonatomic, copy) NSNumber *inputSlope; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/ios/Resources/IFKHRHazeRemoval.cikernel: -------------------------------------------------------------------------------- 1 | kernel vec4 hazeRemovalKernel(sampler srcImage, __color color, float distance, float slope) { 2 | vec4 src = sample(srcImage, samplerCoord(srcImage)); 3 | float d = destCoord().y * slope + distance; 4 | 5 | return clamp(premultiply((unpremultiply(src) - d * color) / (1.0 - d)), 0.0, 1.0); 6 | } 7 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Example haze removal filter for iOS & Android", 3 | "keywords": [ 4 | "react-native", 5 | "image-filter" 6 | ], 7 | "license": "MIT", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "name": "react-native-image-filter-kit-haze-removal", 11 | "author": "iyegoroff ", 12 | "bugs": { 13 | "url": "https://github.com/iyegoroff/react-native-image-filter-kit/issues" 14 | }, 15 | "homepage": "https://github.com/iyegoroff/react-native-image-filter-kit#readme", 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/iyegoroff/react-native-image-filter-kit.git" 19 | }, 20 | "version": "0.0.1", 21 | "peerDependencies": { 22 | "react": "*", 23 | "react-native": "*", 24 | "@babel/runtime": "*", 25 | "react-native-image-filter-kit": "*" 26 | }, 27 | "scripts": { 28 | "build": "rm -rf dist && ../../../../node_modules/.bin/tsc -p ./src", 29 | "watch": "../../../../node_modules/.bin/tsc -p ./src -w", 30 | "build:all": "npm run build" 31 | }, 32 | "files": [ 33 | ".dockerignore", 34 | "android", 35 | "ios", 36 | "src", 37 | "dist", 38 | "*.md", 39 | "*.podspec" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/react-native-image-filter-kit-haze-removal.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = package['name'] 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.homepage = package['homepage'] 10 | s.license = package['license'] 11 | s.author = package['author'] 12 | s.platform = :ios, '9.0' 13 | s.source = { :git => 'https://github.com/iyegoroff/react-native-image-filter-kit.git', :tag => 'v#{s.version}' } 14 | s.source_files = 'ios/**/*.{h,m}' 15 | s.resource_bundles = { 'bundle' => ['ios/Resources/*.cikernel'] } 16 | s.requires_arc = true 17 | 18 | s.dependency 'React' 19 | s.dependency 'react-native-image-filter-kit' 20 | end 21 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "target": "es6", 5 | "strict": true, 6 | "outDir": "../dist", 7 | "jsx": "react-native", 8 | "lib": ["es2016"], 9 | "moduleResolution": "node", 10 | "allowSyntheticDefaultImports": true, 11 | "declaration": true, 12 | "types": ["react-native"] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path') 9 | const blacklist = require('metro-config/src/defaults/exclusionList') 10 | 11 | const packagePath = path.resolve(__dirname, '../../') 12 | const hazeRemovalPath = path.resolve( 13 | __dirname, 14 | 'local_modules/react-native-image-filter-kit-haze-removal' 15 | ) 16 | 17 | const extraNodeModules = { 18 | react: path.resolve(__dirname, 'node_modules/react'), 19 | 'react-native': path.resolve(__dirname, 'node_modules/react-native'), 20 | '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'), 21 | 'react-native-image-filter-kit': packagePath, 22 | 'react-native-image-filter-kit-haze-removal': hazeRemovalPath 23 | } 24 | 25 | module.exports = { 26 | resolver: { 27 | extraNodeModules, 28 | blockList: blacklist([/^src[/\\].*/, /^examples[/\\]\w+[/\\]src[/\\].*/]) 29 | }, 30 | watchFolders: [packagePath, hazeRemovalPath], 31 | transformer: { 32 | getTransformOptions: async () => ({ 33 | transform: { 34 | experimentalImportSupport: false, 35 | inlineRequires: false 36 | } 37 | }) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/patches/react-native-gesture-handler+1.10.3.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/react-native-gesture-handler/lib/typescript/components/touchables/GenericTouchable.d.ts b/node_modules/react-native-gesture-handler/lib/typescript/components/touchables/GenericTouchable.d.ts 2 | index 343288f..6c843e7 100644 3 | --- a/node_modules/react-native-gesture-handler/lib/typescript/components/touchables/GenericTouchable.d.ts 4 | +++ b/node_modules/react-native-gesture-handler/lib/typescript/components/touchables/GenericTouchable.d.ts 5 | @@ -1,4 +1,3 @@ 6 | -/// 7 | import { Component } from 'react'; 8 | import { StyleProp, ViewStyle, TouchableWithoutFeedbackProps } from 'react-native'; 9 | import { GestureEvent, HandlerStateChangeEvent } from '../../handlers/gestureHandlers'; 10 | -------------------------------------------------------------------------------- /examples/CustomNativeFilter/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "baseUrl": ".", 5 | "target": "es6", 6 | "strict": true, 7 | "outDir": "../build", 8 | "jsx": "react-native", 9 | "lib": ["es6"], 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "noEmitOnError": true, 13 | "types": [ 14 | "react", 15 | "react-native", 16 | "react-native-image-filter-kit" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/ImageExtraction/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /examples/ImageExtraction/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /examples/ImageExtraction/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | infer-out/ 3 | xcodebuild.log 4 | src/obj/ 5 | src/bin/ 6 | **/.DS_Store 7 | .gradle/ 8 | compile_commands.json 9 | rn-cli.config.js 10 | *.apk 11 | build/ 12 | -------------------------------------------------------------------------------- /examples/ImageExtraction/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/ImageExtraction/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM iyegoroff/ubuntu-node-android-git:3 2 | 3 | RUN mkdir /package 4 | COPY . /package 5 | WORKDIR /package/examples/ImageExtraction 6 | 7 | RUN npm i -g yarn@1.22.4 8 | RUN yarn 9 | RUN npm run generate:android:bundle 10 | RUN rm -rf node_modules/.bin && rm -rf ../../node_modules/.bin 11 | RUN cd android && ./gradlew assembleRelease 12 | -------------------------------------------------------------------------------- /examples/ImageExtraction/README.md: -------------------------------------------------------------------------------- 1 | #### Description 2 | 3 | Example shows how to extract filtered image and save it to the camera roll. 4 | 5 | ### Run debug version 6 | 7 | ```bash 8 | $ yarn 9 | $ yarn run:android 10 | ``` 11 | 12 | ### Build signed release apk with Docker 13 | 14 | - Generate keystore `yarn generate:android:signing-key` 15 | - Open `examples/ImageExtraction/android/gradle.properties` file and replace `qwerty`s with your passwords 16 | - Run `yarn build:release:docker` - upon script completion apk will be copied to `examples/ImageExtraction/image-extraction.apk` file 17 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | .idea 4 | .gradle 5 | local.properties 6 | *.iml 7 | .DS_Store 8 | app/*.keystore 9 | !app/debug.keystore 10 | app/src/main/assets/*.bundle 11 | app/src/main/res/drawable-* 12 | gradle-yandex.properties -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/debug.keystore -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/assets/.gitkeep -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/java/com/imageextraction/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.imageextraction; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "ImageExtraction"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ImageExtraction 3 | 4 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | ndkVersion = "20.1.5948944" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.1.0") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.75.1 29 | 30 | EXAMPLE_RELEASE_STORE_FILE=example.keystore 31 | EXAMPLE_RELEASE_KEY_ALIAS=example 32 | EXAMPLE_RELEASE_STORE_PASSWORD=qwerty 33 | EXAMPLE_RELEASE_KEY_PASSWORD=qwerty 34 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/examples/ImageExtraction/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/ImageExtraction/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/ImageExtraction/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ImageExtraction' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /examples/ImageExtraction/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ImageExtraction", 3 | "displayName": "ImageExtraction" 4 | } -------------------------------------------------------------------------------- /examples/ImageExtraction/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /examples/ImageExtraction/index.js: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { AppRegistry } from 'react-native' 4 | import App from './build/App' 5 | import { name as appName } from './app.json' 6 | 7 | AppRegistry.registerComponent(appName, () => App) 8 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/infer-out/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | project.xcworkspace 19 | compile_commands.json 20 | xcodebuild.log 21 | .DS_Store 22 | Pods 23 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/ImageExtraction/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/ImageExtraction/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'ImageExtraction' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | # Enables Flipper. 16 | # 17 | # Note that if you have use_frameworks! enabled, Flipper will not work and 18 | # you should disable the next line. 19 | use_flipper!() 20 | 21 | post_install do |installer| 22 | react_native_post_install(installer) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /examples/ImageExtraction/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path') 9 | const blacklist = require('metro-config/src/defaults/exclusionList') 10 | 11 | const packagePath = path.resolve(__dirname, '../../') 12 | 13 | const extraNodeModules = { 14 | react: path.resolve(__dirname, 'node_modules/react'), 15 | 'react-native': path.resolve(__dirname, 'node_modules/react-native'), 16 | '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'), 17 | 'react-native-image-filter-kit': packagePath, 18 | } 19 | 20 | module.exports = { 21 | resolver: { 22 | extraNodeModules, 23 | blockList: blacklist([/^src[/\\].*/, /^examples[/\\]\w+[/\\]src[/\\].*/]), 24 | }, 25 | watchFolders: [packagePath], 26 | transformer: { 27 | getTransformOptions: async () => ({ 28 | transform: { 29 | experimentalImportSupport: false, 30 | inlineRequires: false, 31 | }, 32 | }), 33 | }, 34 | } 35 | -------------------------------------------------------------------------------- /examples/ImageExtraction/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "baseUrl": ".", 5 | "target": "es6", 6 | "strict": true, 7 | "outDir": "../build", 8 | "jsx": "react-native", 9 | "lib": ["es6"], 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "types": [ 13 | "react", 14 | "react-native", 15 | "react-native-image-filter-kit" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /img/coordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/coordinates.png -------------------------------------------------------------------------------- /img/earlybird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/earlybird.png -------------------------------------------------------------------------------- /img/emboss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/emboss.png -------------------------------------------------------------------------------- /img/invert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/invert.png -------------------------------------------------------------------------------- /img/maven.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/maven.jpg -------------------------------------------------------------------------------- /img/maven_compat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/maven_compat.jpg -------------------------------------------------------------------------------- /img/parrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/parrot.png -------------------------------------------------------------------------------- /img/porter_duff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/porter_duff.png -------------------------------------------------------------------------------- /img/radial_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/radial_gradient.png -------------------------------------------------------------------------------- /img/soft_light_blend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyegoroff/react-native-image-filter-kit/829dcdaa386215edc719b7c622fa0f448db9c334/img/soft_light_blend.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | *.pbxuser 3 | !default.pbxuser 4 | *.mode1v3 5 | !default.mode1v3 6 | *.mode2v3 7 | !default.mode2v3 8 | *.perspectivev3 9 | !default.perspectivev3 10 | xcuserdata 11 | *.xccheckout 12 | *.moved-aside 13 | DerivedData 14 | *.hmap 15 | *.ipa 16 | *.xcuserstate 17 | project.xcworkspace -------------------------------------------------------------------------------- /ios/IFKCacheable.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #ifndef IFKCacheable_h 4 | #define IFKCacheable_h 5 | 6 | @protocol IFKCacheable 7 | 8 | - (nonnull NSString *)cacheKey; 9 | 10 | @end 11 | 12 | #endif /* IFKCacheable_h */ 13 | -------------------------------------------------------------------------------- /ios/IFKCircleShape.h: -------------------------------------------------------------------------------- 1 | #import "IFKShape.h" 2 | 3 | @interface IFKCircleShape : IFKShape 4 | 5 | @property (nonatomic, copy) NSNumber *inputRadius; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /ios/IFKCompositionPostProcessor.h: -------------------------------------------------------------------------------- 1 | #import "IFKPostProcessor.h" 2 | 3 | @interface IFKCompositionPostProcessor : IFKPostProcessor 4 | 5 | - (nonnull instancetype)initWithName:(nonnull NSString *)name 6 | inputs:(nonnull NSDictionary *)inputs 7 | canvasSize:(CGSize)canvasSize; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKConfigHelper.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKConfigHelper : NSObject 4 | 5 | + (nonnull NSString *)name:(nonnull NSDictionary *)config; 6 | + (BOOL)isCacheDisabled:(nonnull NSDictionary *)config; 7 | + (BOOL)isSingular:(nonnull NSDictionary *)config; 8 | + (BOOL)isComposition:(nonnull NSDictionary *)config; 9 | + (nonnull NSString *)mainImage:(nonnull NSDictionary *)config; 10 | + (nonnull NSDictionary *)wrappedConfigs:(nonnull NSDictionary *)config; 11 | + (NSUInteger)maxImageIndex:(nonnull NSDictionary *)config; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/IFKEllipticalGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKEllipticalGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIVector *inputCenter; 6 | @property (nonatomic, copy) NSNumber *inputRadiusX; 7 | @property (nonatomic, copy) NSNumber *inputRadiusY; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKExtractedImagesCache.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKExtractedImagesCache : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /ios/IFKExtractedImagesCache.m: -------------------------------------------------------------------------------- 1 | #import "IFKExtractedImagesCache.h" 2 | #import "NSArray+FilterMapReduce.h" 3 | #import 4 | 5 | @implementation IFKExtractedImagesCache 6 | 7 | RCT_EXPORT_MODULE() 8 | 9 | RCT_EXPORT_METHOD(clean) 10 | { 11 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 12 | NSString *directory = [NSTemporaryDirectory() stringByAppendingPathComponent:@"ReactNative"]; 13 | NSFileManager *fileManager = [NSFileManager new]; 14 | NSArray *contents = [[fileManager contentsOfDirectoryAtPath:directory 15 | error:NULL] 16 | filter:^BOOL(NSString *val, int idx) { 17 | return [val hasSuffix:@"rnifk.png"]; 18 | }]; 19 | 20 | for (NSString *path in contents) { 21 | NSString *fullPath = [directory stringByAppendingPathComponent:path]; 22 | if ([fileManager fileExistsAtPath:fullPath]) { 23 | [fileManager removeItemAtPath:fullPath error:NULL]; 24 | #if RCT_DEBUG 25 | NSLog(@"ImageFilterKit: removed tmp file %@", fullPath); 26 | #endif 27 | } 28 | } 29 | }); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ios/IFKFilterConstructor.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | // source: https://github.com/YuAo/Vivid/blob/master/Sources/YUCIFilterConstructor.h 4 | 5 | @interface IFKFilterConstructor : NSObject 6 | 7 | + (instancetype)constructor; 8 | 9 | - (instancetype)init NS_UNAVAILABLE; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /ios/IFKFilterConstructor.m: -------------------------------------------------------------------------------- 1 | #import "IFKFilterConstructor.h" 2 | 3 | // source: https://github.com/YuAo/Vivid/blob/master/Sources/YUCIFilterConstructor.m 4 | 5 | @implementation IFKFilterConstructor 6 | 7 | + (instancetype)constructor { 8 | static IFKFilterConstructor *constructor; 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | constructor = [[IFKFilterConstructor alloc] initForSharedConstructor]; 12 | }); 13 | return constructor; 14 | } 15 | 16 | - (instancetype)initForSharedConstructor { 17 | if (self = [super init]) { 18 | 19 | } 20 | return self; 21 | } 22 | 23 | - (CIFilter *)filterWithName:(NSString *)name { 24 | return [[NSClassFromString(name) alloc] init]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ios/IFKFilterableImage.h: -------------------------------------------------------------------------------- 1 | #import "RCTImageView.h" 2 | #import "IFKPostProcessor.h" 3 | 4 | @interface IFKFilterableImage : NSObject 5 | 6 | - (nonnull instancetype)initWithTarget:(nonnull RCTImageView *)target 7 | originalImage:(nonnull UIImage *)originalImage 8 | config:(nonnull NSObject *)config 9 | postProcessors:(nonnull NSArray *)postProcessors; 10 | 11 | - (nonnull RCTImageView *)target; 12 | - (nonnull UIImage *)originalImage; 13 | - (nonnull NSString *)config; 14 | - (nonnull NSArray *)postProcessors; 15 | - (BOOL)isCacheDisabled; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/IFKFilterableImage.m: -------------------------------------------------------------------------------- 1 | #import "IFKFilterableImage.h" 2 | #import "IFKConfigHelper.h" 3 | 4 | @interface IFKFilterableImage () 5 | 6 | @property (nonatomic, strong) RCTImageView *target; 7 | @property (nonatomic, strong) UIImage *originalImage; 8 | @property (nonatomic, strong) NSString *config; 9 | @property (nonatomic, strong) NSArray *postProcessors; 10 | @property (nonatomic, assign) BOOL isCacheDisabled; 11 | 12 | @end 13 | 14 | @implementation IFKFilterableImage 15 | 16 | - (nonnull instancetype)initWithTarget:(nonnull RCTImageView *)target 17 | originalImage:(nonnull UIImage *)originalImage 18 | config:(nonnull NSObject *)config 19 | postProcessors:(nonnull NSArray *)postProcessors 20 | { 21 | if ((self = [super init])) { 22 | _target = target; 23 | _postProcessors = postProcessors; 24 | _config = [NSString stringWithFormat:@"%@", config]; 25 | _originalImage = originalImage; 26 | _isCacheDisabled = [config isKindOfClass:[NSDictionary class]] 27 | && [IFKConfigHelper isCacheDisabled:(NSDictionary *)config]; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/IFKGradient.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKGradient : CIFilter 4 | 5 | + (void)initializeWithGradientClass:(Class)gradientClass displayName:(NSString *)displayName; 6 | + (NSArray *)loadKernels:(Class)gradientClass; 7 | + (void)assertMaxColors:(Class)gradientClass inputAmount:(int)inputAmount; 8 | - (int)inputAmount; 9 | 10 | @property (nonatomic, copy) CIVector *inputExtent; 11 | @property (nonatomic, copy) NSArray *inputColors; 12 | @property (nonatomic, copy) CIVector *inputStops; 13 | @property (nonatomic, copy) NSNumber *inputMixStep; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/IFKImage.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IFKCacheable.h" 3 | 4 | @interface IFKImage : NSObject 5 | 6 | - (nonnull instancetype)initWithImage:(nonnull UIImage *)image 7 | cacheKey:(nonnull NSString *)cacheKey; 8 | 9 | @property (nonatomic, strong) UIImage * _Nonnull image; 10 | @property (nonatomic, strong) NSString * _Nonnull cacheKey; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /ios/IFKImage.m: -------------------------------------------------------------------------------- 1 | #import "IFKImage.h" 2 | 3 | @implementation IFKImage 4 | 5 | - (nonnull instancetype)initWithImage:(UIImage *)image cacheKey:(NSString *)cacheKey 6 | { 7 | if ((self = [super init])) { 8 | _image = image; 9 | _cacheKey = cacheKey; 10 | } 11 | 12 | return self; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/IFKImageCache.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKImageCache : NSObject 4 | 5 | + (nonnull IFKImageCache *)instance; 6 | + (nonnull IFKImageCache *)instance:(unsigned long long)maxCacheSizeInBytes; 7 | - (nullable UIImage *)imageForKey:(nonnull NSString *)key; 8 | - (void)setImage:(nonnull UIImage *)image forKey:(nonnull NSString *)key; 9 | 10 | - (instancetype)init UNAVAILABLE_ATTRIBUTE; 11 | + (instancetype)new UNAVAILABLE_ATTRIBUTE; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/IFKImageFilter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface IFKImageFilter : RCTView 5 | 6 | @property (nonatomic, strong) NSString* config; 7 | @property (nonatomic, assign) BOOL extractImageEnabled; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKImageFilterManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKImageFilterManager : RCTViewManager 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /ios/IFKImageFilterManager.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IFKImageFilterManager.h" 3 | #import "IFKImageFilter.h" 4 | 5 | @implementation IFKImageFilterManager 6 | 7 | @synthesize bridge = _bridge; 8 | 9 | RCT_EXPORT_MODULE(); 10 | 11 | - (UIView *)view 12 | { 13 | return [[IFKImageFilter alloc] init]; 14 | } 15 | 16 | - (dispatch_queue_t)methodQueue 17 | { 18 | return dispatch_get_main_queue(); 19 | } 20 | 21 | RCT_EXPORT_VIEW_PROPERTY(config, NSString); 22 | RCT_EXPORT_VIEW_PROPERTY(extractImageEnabled, BOOL); 23 | RCT_EXPORT_VIEW_PROPERTY(onIFKFilteringStart, RCTBubblingEventBlock); 24 | RCT_EXPORT_VIEW_PROPERTY(onIFKFilteringFinish, RCTBubblingEventBlock); 25 | RCT_EXPORT_VIEW_PROPERTY(onIFKFilteringError, RCTBubblingEventBlock); 26 | RCT_EXPORT_VIEW_PROPERTY(onIFKExtractImage, RCTBubblingEventBlock); 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ios/IFKLinearGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKLinearGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIVector *inputStart; 6 | @property (nonatomic, copy) CIVector *inputEnd; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKOutputExtentHandler.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKOutputExtentHandler : NSObject 4 | 5 | + (CGRect)resizedRect:(nonnull CIFilter *)filter 6 | inputExtent:(CGRect)inputExtent 7 | destSize:(CGSize)destSize; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKOvalShape.h: -------------------------------------------------------------------------------- 1 | #import "IFKShape.h" 2 | 3 | @interface IFKOvalShape : IFKShape 4 | 5 | @property (nonatomic, copy) NSNumber *inputRadiusX; 6 | @property (nonatomic, copy) NSNumber *inputRadiusY; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKPathShape.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "IFKShape.h" 3 | 4 | @interface IFKPathShape : IFKShape 5 | 6 | @property (nonatomic, copy) UIBezierPath *inputPath; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKPathShape.m: -------------------------------------------------------------------------------- 1 | #import "IFKPathShape.h" 2 | #import "IFKFilterConstructor.h" 3 | #import "UIColor+CIColorComponents.h" 4 | 5 | @implementation IFKPathShape 6 | 7 | + (void)initialize 8 | { 9 | [CIFilter registerFilterName:NSStringFromClass([IFKPathShape class]) 10 | constructor:[IFKFilterConstructor constructor] 11 | classAttributes:@{kCIAttributeFilterDisplayName:@"Path shape", 12 | kCIAttributeFilterCategories:@[kCICategoryGenerator, 13 | kCICategoryVideo, 14 | kCICategoryStillImage]}]; 15 | } 16 | 17 | - (UIBezierPath *)inputPath 18 | { 19 | return _inputPath ?: [UIBezierPath bezierPath]; 20 | } 21 | 22 | - (CIImage *)outputImage 23 | { 24 | if (self.inputExtent == nil) { 25 | return nil; 26 | } 27 | 28 | CGRect frame = CGRectMake(0, 0, self.inputExtent.Z, self.inputExtent.W); 29 | 30 | UIBezierPath *path = [self inputPath]; 31 | 32 | [path applyTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(1.0, -1.0), 33 | CGAffineTransformMakeTranslation(frame.size.width / 2.0, 34 | frame.size.height / 2.0))]; 35 | 36 | UIGraphicsBeginImageContextWithOptions(frame.size, false, 1.0f); 37 | 38 | [[UIColor colorWithCIColorComponents:[self inputColor]] setFill]; 39 | 40 | [path fill]; 41 | 42 | UIImage *pathImage = UIGraphicsGetImageFromCurrentImageContext(); 43 | 44 | UIGraphicsEndImageContext(); 45 | 46 | return [[CIImage alloc] initWithImage:pathImage]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /ios/IFKPostProcessor.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKPostProcessor : NSObject 4 | 5 | - (nonnull instancetype)initWithName:(nonnull NSString *)name inputs:(nonnull NSDictionary *)inputs; 6 | 7 | - (nonnull UIImage *)process:(nonnull UIImage *)image canvasSize:(CGSize)canvasSize; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKQuadGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKQuadGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIColor *inputBottomLeftColor; 6 | @property (nonatomic, copy) CIColor *inputBottomRightColor; 7 | @property (nonatomic, copy) CIColor *inputTopLeftColor; 8 | @property (nonatomic, copy) CIColor *inputTopRightColor; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /ios/IFKRadialGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKRadialGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIVector *inputCenter; 6 | @property (nonatomic, copy) NSNumber *inputRadius; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKRectangularGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKRectangularGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIVector *inputCenter; 6 | @property (nonatomic, copy) NSNumber *inputHalfWidth; 7 | @property (nonatomic, copy) NSNumber *inputHalfHeight; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /ios/IFKRegularPolygonShape.h: -------------------------------------------------------------------------------- 1 | #import "IFKShape.h" 2 | 3 | @interface IFKRegularPolygonShape : IFKShape 4 | 5 | @property (nonatomic, copy) NSNumber *inputCircumradius; 6 | @property (nonatomic, copy) CIVector *inputBorderRadiuses; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKScale.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | typedef enum { 4 | STRETCH, 5 | CONTAIN, 6 | COVER 7 | } IFKScaleMode; 8 | 9 | @interface IFKScale : NSObject 10 | 11 | @end 12 | 13 | @interface IFKScaleWithMode : IFKScale 14 | 15 | @property (nonatomic, assign) IFKScaleMode mode; 16 | 17 | - (nonnull instancetype)initWithMode:(IFKScaleMode)mode; 18 | 19 | @end 20 | 21 | @interface IFKScaleWithSize : IFKScale 22 | 23 | @property (nonatomic, assign) CGPoint scale; 24 | 25 | - (nonnull instancetype)initWithX:(CGFloat)x andY:(CGFloat)y; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ios/IFKScale.m: -------------------------------------------------------------------------------- 1 | #import "IFKScale.h" 2 | #import 3 | 4 | @implementation IFKScale 5 | 6 | - (NSString *)description 7 | { 8 | if ([self isKindOfClass:[IFKScaleWithMode class]]) { 9 | return [NSString stringWithFormat:@"Scale.WithMode(%i)", ((IFKScaleWithMode *)self).mode]; 10 | } 11 | 12 | if ([self isKindOfClass:[IFKScaleWithSize class]]) { 13 | return [NSString stringWithFormat: 14 | @"Scale.WithSize(%f, %f)", 15 | ((IFKScaleWithSize *)self).scale.x, 16 | ((IFKScaleWithSize *)self).scale.y]; 17 | } 18 | 19 | RCTAssert(false, @"ImageFilterKit: unknown IFKScale subclass"); 20 | 21 | return @""; 22 | } 23 | 24 | @end 25 | 26 | @implementation IFKScaleWithMode 27 | 28 | - (nonnull instancetype)initWithMode:(IFKScaleMode)mode 29 | { 30 | if ((self = [super init])) { 31 | _mode = mode; 32 | } 33 | 34 | return self; 35 | } 36 | 37 | @end 38 | 39 | @implementation IFKScaleWithSize 40 | 41 | - (nonnull instancetype)initWithX:(CGFloat)x andY:(CGFloat)y 42 | { 43 | if ((self = [super init])) { 44 | _scale = CGPointMake(x, y); 45 | } 46 | 47 | return self; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /ios/IFKShape.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKShape : CIFilter 4 | 5 | @property (nonatomic, copy) CIVector *inputExtent; 6 | @property (nonatomic, copy) CIColor *inputColor; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/IFKShape.m: -------------------------------------------------------------------------------- 1 | #import "IFKShape.h" 2 | 3 | @implementation IFKShape 4 | 5 | - (CIColor *)inputColor 6 | { 7 | return _inputColor ?: [CIColor colorWithRed:0.0f green:0.0f blue:0.0f]; 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /ios/IFKSweepGradient.h: -------------------------------------------------------------------------------- 1 | #import "IFKGradient.h" 2 | 3 | @interface IFKSweepGradient : IFKGradient 4 | 5 | @property (nonatomic, copy) CIVector *inputCenter; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /ios/IFKTextImage.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKTextImage : CIFilter 4 | 5 | @property (nonatomic, copy) CIVector *inputExtent; 6 | @property (nonatomic, copy) NSString *inputText; 7 | @property (nonatomic, copy) NSString *inputFontName; 8 | @property (nonatomic, copy) NSNumber *inputFontSize; 9 | @property (nonatomic, copy) CIColor *inputColor; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /ios/IFKTransform.h: -------------------------------------------------------------------------------- 1 | #import "IFKScale.h" 2 | 3 | @interface IFKTransform : NSObject 4 | 5 | @property (nonatomic, assign) CGPoint anchor; 6 | @property (nonatomic, assign) CGPoint translate; 7 | @property (nonatomic, strong) IFKScale *scale; 8 | @property (nonatomic, assign) CGFloat rotate; 9 | 10 | - (nonnull instancetype)initWithAnchor:(CGPoint)anchor 11 | translate:(CGPoint)translate 12 | scale:(IFKScale *)scale 13 | rotate:(CGFloat)rotate; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/IFKTransform.m: -------------------------------------------------------------------------------- 1 | #import "IFKTransform.h" 2 | 3 | @implementation IFKTransform 4 | 5 | - (NSString *)description 6 | { 7 | return [NSString stringWithFormat: 8 | @"Transform(%f, %f, %f, %f, %@, %f)", 9 | _anchor.x, 10 | _anchor.y, 11 | _translate.x, 12 | _translate.y, 13 | _scale, 14 | _rotate]; 15 | } 16 | 17 | - (nonnull instancetype)initWithAnchor:(CGPoint)anchor 18 | translate:(CGPoint)translate 19 | scale:(IFKScale *)scale 20 | rotate:(CGFloat)rotate 21 | { 22 | if ((self = [super init])) { 23 | _anchor = anchor; 24 | _translate = translate; 25 | _scale = scale; 26 | _rotate = rotate; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ios/IFKXorCompositing.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface IFKXorCompositing : CIFilter 4 | 5 | @property (nonatomic, strong) CIImage *inputImage; 6 | @property (nonatomic, strong) CIImage *inputBackgroundImage; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/NSArray+FilterMapReduce.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSArray (FilterMapReduce) 4 | 5 | - (NSArray *)map:(id (^ __nonnull)(T val, int idx))block; 6 | - (NSArray *)filter:(BOOL (^ __nonnull)(T val, int idx))block; 7 | - (id)reduce:(id (^ __nonnull)(id acc, T val, int idx))block init:(id)initial; 8 | - (BOOL)every:(BOOL (^ __nonnull)(T val, int idx))block; 9 | - (BOOL)some:(BOOL (^ __nonnull)(T val, int idx))block; 10 | - (T)at:(int)idx; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /ios/NSArray+FilterMapReduce.m: -------------------------------------------------------------------------------- 1 | #import "NSArray+FilterMapReduce.h" 2 | 3 | @implementation NSArray (FilterMapReduce) 4 | 5 | - (NSArray *)map:(id (^ __nonnull)(id val, int idx))block 6 | { 7 | NSMutableArray *arr = [NSMutableArray array]; 8 | 9 | for (int i = 0; i < self.count; i++) { 10 | [arr addObject:block([self objectAtIndex:i], i)]; 11 | } 12 | 13 | return arr; 14 | } 15 | 16 | - (NSArray *)filter:(BOOL (^ __nonnull)(id val, int idx))block 17 | { 18 | NSMutableArray *arr = [NSMutableArray array]; 19 | 20 | for (int i = 0; i < self.count; i++) { 21 | if (block([self objectAtIndex:i], i)) { 22 | [arr addObject:[self objectAtIndex:i]]; 23 | } 24 | } 25 | 26 | return arr; 27 | } 28 | 29 | - (id)reduce:(id (^ __nonnull)(id acc, id val, int idx))block init:(id)initial 30 | { 31 | id acc = initial; 32 | 33 | for (int i = 0; i < self.count; i++) { 34 | acc = block(acc, [self objectAtIndex:i], i); 35 | } 36 | 37 | return acc; 38 | } 39 | 40 | - (BOOL)every:(BOOL (^ __nonnull)(id val, int idx))block 41 | { 42 | for (int i = 0; i < self.count; i++) { 43 | if (!block([self objectAtIndex:i], i)) { 44 | return NO; 45 | } 46 | } 47 | 48 | return YES; 49 | } 50 | 51 | - (BOOL)some:(BOOL (^ __nonnull)(id val, int idx))block 52 | { 53 | for (int i = 0; i < self.count; i++) { 54 | if (block([self objectAtIndex:i], i)) { 55 | return YES; 56 | } 57 | } 58 | 59 | return NO; 60 | } 61 | 62 | - (id)at:(int)idx 63 | { 64 | return self.count > idx ? [self objectAtIndex:idx] : nil; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /ios/RCTImageView+CacheKey.h: -------------------------------------------------------------------------------- 1 | #import "RCTImageView.h" 2 | #import "IFKCacheable.h" 3 | 4 | @interface RCTImageView (CacheKey) 5 | 6 | - (nonnull NSString *)cacheKey; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/RCTImageView+CacheKey.m: -------------------------------------------------------------------------------- 1 | #import "RCTImageView+CacheKey.h" 2 | #import 3 | #import "NSArray+FilterMapReduce.h" 4 | 5 | @implementation RCTImageView (CacheKey) 6 | 7 | - (nonnull NSString *)cacheKey 8 | { 9 | return [self.imageSources reduce:^id(NSString *key, RCTImageSource *source, int idx) { 10 | return [NSString stringWithFormat: 11 | @"%@(%@_%f_%@)", 12 | key, 13 | [NSValue valueWithCGSize:source.size], 14 | source.scale, 15 | source.request.URL.absoluteString]; 16 | 17 | } init:[NSString stringWithFormat:@"%ld", (long)self.resizeMode]]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/Resources/IFKQuadGradient.cikernel: -------------------------------------------------------------------------------- 1 | kernel vec4 generate( 2 | __color bottomLeftColor, 3 | __color bottomRightColor, 4 | __color topLeftColor, 5 | __color topRightColor, 6 | float width, 7 | float height 8 | ) { 9 | vec2 fragCoord = destCoord(); 10 | vec2 uv = vec2(min(fragCoord.x, width) / width, min(fragCoord.y, height) / height); 11 | 12 | return mix( 13 | mix(bottomLeftColor, bottomRightColor, uv.x), 14 | mix(topLeftColor, topRightColor, uv.x), 15 | uv.y 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /ios/Resources/IFKXorCompositing.cikernel: -------------------------------------------------------------------------------- 1 | kernel vec4 xorCompositing(sampler srcImage, sampler dstImage) 2 | { 3 | vec4 src = sample(srcImage, samplerCoord(srcImage)); 4 | vec4 dst = sample(dstImage, samplerCoord(dstImage)); 5 | 6 | return vec4( 7 | (1.0 - dst.a) * src.rgb + (1.0 - src.a) * dst.rgb, 8 | (1.0 - dst.a) * src.a + (1.0 - src.a) * dst.a 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /ios/UIColor+CIColorComponents.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface UIColor (CIColorComponents) 4 | 5 | + (UIColor *)colorWithCIColorComponents: (CIColor *)color; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /ios/UIColor+CIColorComponents.m: -------------------------------------------------------------------------------- 1 | #import "UIColor+CIColorComponents.h" 2 | 3 | @implementation UIColor (CIColorComponents) 4 | 5 | + (UIColor *)colorWithCIColorComponents: (CIColor *)color 6 | { 7 | return [UIColor colorWithRed:[color red] 8 | green:[color green] 9 | blue:[color blue] 10 | alpha:[color alpha]]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /react-native-image-filter-kit.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = package['name'] 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.homepage = package['homepage'] 10 | s.license = package['license'] 11 | s.author = package['author'] 12 | s.platform = :ios, '9.0' 13 | s.source = { :git => 'https://github.com/iyegoroff/react-native-image-filter-kit.git', :tag => 'v#{s.version}' } 14 | s.source_files = 'ios/**/*.{h,m}' 15 | s.resource_bundles = { 'bundle' => ['ios/Resources/*.cikernel'] } 16 | s.requires_arc = true 17 | 18 | s.dependency 'React' 19 | s.dependency 'Bolts/Tasks', '1.9.0' 20 | end 21 | -------------------------------------------------------------------------------- /src/blend-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/blend-filters/shape-transforms.d.ts: -------------------------------------------------------------------------------- 1 | import { shapeTransforms as shapeTransformsAndroid } from './shape-transforms.android' 2 | import { shapeTransforms as shapeTransformsIos } from './shape-transforms.ios' 3 | 4 | declare const shapeTransforms: typeof shapeTransformsAndroid & typeof shapeTransformsIos 5 | -------------------------------------------------------------------------------- /src/blend-filters/shapes.ts: -------------------------------------------------------------------------------- 1 | import { Composition, BlendColor } from '../common/shapes' 2 | 3 | export const shapes = { 4 | PlusBlend: Composition, 5 | 6 | DarkenBlend: Composition, 7 | 8 | LightenBlend: Composition, 9 | 10 | ModulateBlend: Composition, 11 | 12 | OverlayBlend: Composition, 13 | 14 | ScreenBlend: Composition, 15 | 16 | ColorDodgeBlend: Composition, 17 | 18 | ExclusionBlend: Composition, 19 | 20 | ColorBurnBlend: Composition, 21 | 22 | SoftLightBlend: Composition, 23 | 24 | HueBlend: Composition, 25 | 26 | ColorBlend: Composition, 27 | 28 | SaturationBlend: Composition, 29 | 30 | LuminosityBlend: Composition, 31 | 32 | DifferenceBlend: Composition, 33 | 34 | HardLightBlend: Composition, 35 | 36 | MultiplyBlend: Composition, 37 | 38 | PlusBlendColor: BlendColor, 39 | 40 | DarkenBlendColor: BlendColor, 41 | 42 | LightenBlendColor: BlendColor, 43 | 44 | ModulateBlendColor: BlendColor, 45 | 46 | OverlayBlendColor: BlendColor, 47 | 48 | ScreenBlendColor: BlendColor, 49 | 50 | ColorDodgeBlendColor: BlendColor, 51 | 52 | ExclusionBlendColor: BlendColor, 53 | 54 | ColorBurnBlendColor: BlendColor, 55 | 56 | SoftLightBlendColor: BlendColor, 57 | 58 | HueBlendColor: BlendColor, 59 | 60 | ColorBlendColor: BlendColor, 61 | 62 | SaturationBlendColor: BlendColor, 63 | 64 | LuminosityBlendColor: BlendColor, 65 | 66 | DifferenceBlendColor: BlendColor, 67 | 68 | HardLightBlendColor: BlendColor, 69 | 70 | MultiplyBlendColor: BlendColor 71 | } 72 | -------------------------------------------------------------------------------- /src/blur-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/blur-filters/shape-transforms.ts: -------------------------------------------------------------------------------- 1 | import { Platform } from 'react-native' 2 | import { FilterConfig } from '../common/configs' 3 | import { TransformMap } from '../common/shapes' 4 | import { shapes } from './shapes' 5 | 6 | type BlurConfig = { 7 | readonly radius: number 8 | } & FilterConfig 9 | 10 | export const shapeTransforms: TransformMap = { 11 | BoxBlur: Platform.select({ 12 | ios: ({ radius = 5, image, disableCache }: BlurConfig) => 13 | ({ 14 | name: 'IosCIBoxBlur', 15 | disableCache, 16 | inputRadius: radius * 2, 17 | clampToExtent: true, 18 | inputImage: { 19 | name: 'IosCIBoxBlur', 20 | disableCache, 21 | inputRadius: radius * 2, 22 | clampToExtent: true, 23 | inputImage: { 24 | name: 'IosCIBoxBlur', 25 | disableCache, 26 | inputRadius: radius * 2, 27 | clampToExtent: true, 28 | inputImage: image 29 | } 30 | } 31 | } as object), 32 | 33 | android: ({ radius = 5, ...config }: BlurConfig) => 34 | ({ 35 | ...config, 36 | name: 'AndroidIterativeBoxBlur', 37 | blurRadius: radius 38 | } as object) 39 | }), 40 | 41 | GaussianBlur: Platform.select({ 42 | ios: ({ radius = 5, image, disableCache }: BlurConfig) => 43 | ({ 44 | name: 'IosCIGaussianBlur', 45 | disableCache, 46 | inputRadius: radius, 47 | inputImage: image, 48 | clampToExtent: true 49 | } as object), 50 | 51 | android: ({ radius = 5, ...config }: BlurConfig) => 52 | ({ 53 | ...config, 54 | name: 'AndroidScriptIntrinsicBlur', 55 | radius: radius * 2 56 | } as object) 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /src/blur-filters/shapes.ts: -------------------------------------------------------------------------------- 1 | import { scalar } from '../common/inputs' 2 | import { Common } from '../common/shapes' 3 | 4 | export const shapes = { 5 | BoxBlur: { 6 | radius: scalar, 7 | ...Common 8 | }, 9 | 10 | GaussianBlur: { 11 | radius: scalar, 12 | ...Common 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/color-matrix-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/common/configs.d.ts: -------------------------------------------------------------------------------- 1 | import { Image } from 'react-native' 2 | import { Matrix } from 'rn-color-matrices' 3 | 4 | export type Config = { 5 | readonly name: string 6 | [key: string]: any 7 | } 8 | 9 | export type FilterConfig = { 10 | readonly image: Image 11 | readonly disableCache?: boolean 12 | } 13 | 14 | export type AmountFilterConfig = { 15 | readonly amount?: number 16 | } & FilterConfig 17 | 18 | export type MatrixFilterConfig = { 19 | readonly matrix: number[] 20 | } & FilterConfig 21 | 22 | export type Position = { 23 | readonly x: string | number 24 | readonly y: string | number 25 | } 26 | 27 | export type MixStep = 'CLAMP' | 'SMOOTH' 28 | -------------------------------------------------------------------------------- /src/common/extracted-images-cache.ts: -------------------------------------------------------------------------------- 1 | import { NativeModules } from 'react-native' 2 | 3 | const { IFKExtractedImagesCache } = NativeModules 4 | 5 | export const cleanExtractedImagesCache = IFKExtractedImagesCache.clean 6 | -------------------------------------------------------------------------------- /src/common/image-placeholder.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Image, ImageProps, ImageBackgroundProps, ImageBackground } from 'react-native' 3 | import { Omit } from './util' 4 | 5 | export const imagePlaceholderSource = { 6 | uri: 7 | 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAM' + 8 | 'AAWgmWQ0AAAAASUVORK5CYII=' 9 | } 10 | 11 | export const transparentPlaceholderSource = { 12 | uri: 13 | 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAY' + 14 | 'AAjCB0C8AAAAASUVORK5CYII=' 15 | } 16 | 17 | const defaultStyle = { 18 | width: '100%', 19 | height: '100%' 20 | } 21 | 22 | export const ImagePlaceholder = ({ style, ...props }: Omit) => ( 23 | 24 | ) 25 | 26 | export const ImageBackgroundPlaceholder = ({ 27 | style, 28 | ...props 29 | }: Omit) => ( 30 | 31 | ) 32 | 33 | export const ImageTransparentPlaceholder = ({ style, ...props }: Omit) => ( 34 | 35 | ) 36 | -------------------------------------------------------------------------------- /src/common/inputs.ts: -------------------------------------------------------------------------------- 1 | export const config = 'config' 2 | export const distance = 'distance' 3 | export const scalar = 'scalar' 4 | export const position = 'position' 5 | export const scalarVector = 'scalarVector' 6 | export const offset = 'offset' 7 | export const color = 'color' 8 | export const tileMode = 'tileMode' 9 | export const porterDuffMode = 'porterDuffMode' 10 | export const colorVector = 'colorVector' 11 | export const image = 'image' 12 | export const scale = 'scale' 13 | export const bool = 'bool' 14 | export const distanceVector = 'distanceVector' 15 | export const text = 'text' 16 | export const area = 'area' 17 | export const binaryData = 'binaryData' 18 | export const ISOLatin1EncodedText = 'ISOLatin1EncodedText' 19 | export const marker = 'marker' 20 | export const path = 'path' 21 | export const angle = 'angle' 22 | export const transform = 'transform' 23 | export const mixStep = 'mixStep' 24 | 25 | export type Input = 26 | | typeof config 27 | | typeof distance 28 | | typeof scalar 29 | | typeof position 30 | | typeof scalarVector 31 | | typeof offset 32 | | typeof color 33 | | typeof tileMode 34 | | typeof porterDuffMode 35 | | typeof colorVector 36 | | typeof image 37 | | typeof scale 38 | | typeof bool 39 | | typeof distanceVector 40 | | typeof text 41 | | typeof area 42 | | typeof binaryData 43 | | typeof ISOLatin1EncodedText 44 | | typeof marker 45 | | typeof path 46 | | typeof angle 47 | | typeof transform 48 | | typeof mixStep 49 | -------------------------------------------------------------------------------- /src/common/path.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | 3 | type Distance = string | number 4 | 5 | // https://developer.android.com/reference/android/graphics/Path#moveTo(float,%20float) 6 | export const moveTo = (x: Distance, y: Distance) => ({ 7 | moveTo: [`${x}`, `${y}`] 8 | }) 9 | 10 | // https://developer.android.com/reference/android/graphics/Path#lineTo(float,%20float) 11 | export const lineTo = (x: Distance, y: Distance) => ({ 12 | lineTo: [`${x}`, `${y}`] 13 | }) 14 | 15 | // https://developer.android.com/reference/android/graphics/Path#quadTo(float,%20float,%20float,%20float) 16 | export const quadTo = (x1: Distance, y1: Distance, x2: Distance, y2: Distance) => ({ 17 | quadTo: [`${x1}`, `${y1}`, `${x2}`, `${y2}`] 18 | }) 19 | 20 | // https://developer.android.com/reference/android/graphics/Path#cubicTo(float,%20float,%20float,%20float,%20float,%20float) 21 | export const cubicTo = ( 22 | x1: Distance, 23 | y1: Distance, 24 | x2: Distance, 25 | y2: Distance, 26 | x3: Distance, 27 | y3: Distance 28 | ) => ({ 29 | cubicTo: [`${x1}`, `${y1}`, `${x2}`, `${y2}`, `${x3}`, `${y3}`] 30 | }) 31 | 32 | // https://developer.android.com/reference/android/graphics/Path#close() 33 | export const closePath = () => ({ 34 | closePath: [] 35 | }) 36 | -------------------------------------------------------------------------------- /src/common/register-filter.ts: -------------------------------------------------------------------------------- 1 | import { bool, Input } from './inputs' 2 | import { ShapeRegistry } from './shape-registry' 3 | import shapesToComponents from './shapes-to-components' 4 | 5 | type Shape = { [key: string]: Input } 6 | 7 | export default (name: string, shape: Shape, transform?: (from: object) => object) => { 8 | const shapes = { 9 | [name]: { 10 | disableCache: bool, 11 | ...shape 12 | } 13 | } 14 | 15 | ShapeRegistry.addShapes(shapes) 16 | 17 | if (transform !== undefined) { 18 | ShapeRegistry.addTransforms({ [name]: transform }) 19 | } 20 | 21 | return shapesToComponents(shapes)[name] 22 | } 23 | -------------------------------------------------------------------------------- /src/common/shape-registry.ts: -------------------------------------------------------------------------------- 1 | import { Platform } from 'react-native' 2 | import invariant from 'ts-tiny-invariant' 3 | import { id } from './util' 4 | import { Input } from './inputs' 5 | 6 | export type Shape = { 7 | readonly name: string 8 | [input: string]: Input | string 9 | } 10 | 11 | export class ShapeRegistry { 12 | private static shapes: { [key: string]: Shape } = {} 13 | private static transforms: { [key: string]: Function } = {} 14 | 15 | public static addShapes = (shapes: object) => { 16 | const keys = Object.keys(ShapeRegistry.shapes) 17 | const intersection = Object.keys(shapes).filter((k) => keys.includes(k)) 18 | invariant( 19 | intersection.length === 0, 20 | `ImageFilterKit: Attempt to add already registered filter(s) - ${intersection.join()}.` 21 | ) 22 | 23 | ShapeRegistry.shapes = { 24 | ...ShapeRegistry.shapes, 25 | ...shapes 26 | } 27 | } 28 | 29 | public static addTransforms = (transforms: object) => { 30 | const keys = Object.keys(ShapeRegistry.transforms) 31 | const intersection = Object.keys(transforms).filter((k) => keys.includes(k)) 32 | invariant( 33 | intersection.length === 0, 34 | `ImageFilterKit: Attempt to add already registered transform(s) - ${intersection.join()}.` 35 | ) 36 | 37 | ShapeRegistry.transforms = { 38 | ...ShapeRegistry.transforms, 39 | ...transforms 40 | } 41 | } 42 | 43 | public static shape = (name: string) => { 44 | const shape = ShapeRegistry.shapes[name] 45 | 46 | invariant(!!shape, `ImageFilterKit: '${name}' filter doesn't exist on ${Platform.OS}.`) 47 | 48 | return shape 49 | } 50 | 51 | public static transform = (name: string) => ShapeRegistry.transforms[name] || id 52 | } 53 | -------------------------------------------------------------------------------- /src/common/shapes-to-components.ts: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { createImageFilter } from './image-filter' 3 | import { ViewProps } from 'react-native' 4 | 5 | export default (shapes: { [key: string]: object }) => 6 | Object.keys(shapes).reduce<{ [key: string]: React.SFC }>( 7 | (acc, name) => { 8 | const component = createImageFilter(name, shapes[name]) as React.SFC< 9 | ViewProps & { config: object } 10 | > & { isImageFilter: boolean } 11 | component.displayName = name 12 | component.isImageFilter = true 13 | 14 | acc[name] = component 15 | 16 | return acc 17 | }, 18 | {} 19 | ) 20 | -------------------------------------------------------------------------------- /src/common/shapes.ts: -------------------------------------------------------------------------------- 1 | import { bool, image, color, text, marker, transform } from './inputs' 2 | 3 | export type TransformMap = { [P in keyof Shapes]: unknown } 4 | 5 | export const Composition = { 6 | dstImage: image, 7 | dstTransform: transform, 8 | srcImage: image, 9 | srcTransform: transform, 10 | resizeCanvasTo: text, 11 | disableCache: bool, 12 | swapImages: bool 13 | } 14 | 15 | export const Common = { 16 | image: image, 17 | disableCache: bool 18 | } 19 | 20 | export const BlendColor = { 21 | dstImage: image, 22 | srcColor: color, 23 | disableCache: bool 24 | } 25 | 26 | export const Generator = { 27 | ...Common, 28 | isGenerator: marker 29 | } 30 | 31 | export const CommonIos = { 32 | inputImage: image, 33 | clampToExtent: bool, 34 | disableCache: bool 35 | } 36 | 37 | export const CompositionBaseIos = { 38 | ...CommonIos, 39 | resizeCanvasTo: text, 40 | inputImageTransform: transform, 41 | swapImages: bool 42 | } 43 | 44 | export const GeneratorIos = { 45 | ...CommonIos, 46 | isGenerator: marker 47 | } 48 | -------------------------------------------------------------------------------- /src/common/style.ts: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import * as ReactIs from 'react-is' 3 | import { processColor, ViewStyle, ViewProps, StyleProp } from 'react-native' 4 | import invariant from 'ts-tiny-invariant' 5 | 6 | // For some reason RNImageMatrixFilter draw method is not called when component's backgroundColor 7 | // is not set or transparent 8 | export const defaultStyle = { 9 | backgroundColor: '#fff0' 10 | } 11 | 12 | export const hiddenStyle = { 13 | position: 'absolute', 14 | opacity: 0, 15 | zIndex: Number.MIN_SAFE_INTEGER 16 | } 17 | 18 | export const checkStyle = (style: StyleProp) => { 19 | if (style) { 20 | const { backgroundColor } = defaultStyle 21 | 22 | invariant( 23 | processColor(backgroundColor) !== 0, 24 | `ImageFilterKit: Can't use '${backgroundColor}' backgroundColor,` + 25 | ` consider using '#fff0' instead.` 26 | ) 27 | } 28 | } 29 | 30 | export const hidden = (item: React.ReactElement) => { 31 | if (ReactIs.isFragment(item)) { 32 | const child = item.props.children as React.ReactElement 33 | 34 | return React.cloneElement(item, { 35 | ...item.props, 36 | children: { 37 | ...child, 38 | props: { 39 | ...child.props, 40 | style: child.props.style ? [child.props.style, hiddenStyle] : hiddenStyle 41 | } 42 | } 43 | }) 44 | } 45 | 46 | const it = item as React.ReactElement<{ style?: unknown }> 47 | 48 | return React.cloneElement(it, { 49 | ...it.props, 50 | style: it.props.style ? [it.props.style, hiddenStyle] : hiddenStyle 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /src/common/swap-composition.tsx: -------------------------------------------------------------------------------- 1 | import invariant from 'ts-tiny-invariant' 2 | import { Config } from './configs' 3 | import { ShapeRegistry } from './shape-registry' 4 | 5 | const srcImageNames = ['srcImage', 'inputImage'] 6 | const dstImageNames = [ 7 | 'dstImage', 8 | 'inputBackgroundImage', 9 | 'inputMask', 10 | 'inputGradientImage', 11 | 'inputTargetImage', 12 | 'inputDisplacementImage', 13 | 'inputTexture', 14 | 'inputShadingImage' 15 | ] 16 | 17 | export const swapComposition = (config: Config, resizeCanvasTo: string) => { 18 | const shape = ShapeRegistry.shape(config.name) 19 | const dstImage = Object.keys(shape).find((key) => dstImageNames.some((name) => name === key)) 20 | const srcImage = Object.keys(shape).find((key) => srcImageNames.some((name) => name === key)) 21 | 22 | invariant(srcImage !== undefined, `ImageFilterKit: can't find srcImage in ${config.name} shape.`) 23 | invariant(dstImage !== undefined, `ImageFilterKit: can't find dstImage in ${config.name} shape.`) 24 | 25 | if (dstImage && srcImage) { 26 | const dst = dstImage.replace('dstImage', 'dst') 27 | const src = srcImage.replace('srcImage', 'src') 28 | 29 | return { 30 | ...config, 31 | [dstImage]: config[srcImage], 32 | [srcImage]: config[dstImage], 33 | [dst + 'Transform']: config[src + 'Transform'], 34 | [src + 'Transform']: config[dst + 'Transform'], 35 | resizeCanvasTo, 36 | swapImages: true 37 | } 38 | } 39 | 40 | return config 41 | } 42 | -------------------------------------------------------------------------------- /src/common/util.ts: -------------------------------------------------------------------------------- 1 | export const id = (x: T) => x 2 | 3 | export type Omit = Pick> 4 | 5 | const unitPattern = () => /(\d+)(h|w|min|max)/ 6 | 7 | export const isUnit = (unit: string | number) => unitPattern().test(`${unit}`) 8 | 9 | export const degToRad = (deg: number) => (Math.PI * deg) / 180 10 | -------------------------------------------------------------------------------- /src/composition-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/composition-filters/shape-transforms.android.ts: -------------------------------------------------------------------------------- 1 | import { TransformMap } from '../common/shapes' 2 | import { shapes } from './shapes' 3 | 4 | const asNativeCompositionConfig = (mode: string) => (config: Object) => ({ 5 | ...config, 6 | mode, 7 | name: 'AndroidPorterDuffXfermode' 8 | }) 9 | 10 | const asRenderscriptCompositingConfig = (name: string) => (config: Object) => ({ 11 | ...config, 12 | name 13 | }) 14 | 15 | export const shapeTransforms: TransformMap = { 16 | DstATopComposition: asRenderscriptCompositingConfig('AndroidDestinationATopCompositing'), 17 | 18 | DstInComposition: asRenderscriptCompositingConfig('AndroidDestinationInCompositing'), 19 | 20 | DstOutComposition: asNativeCompositionConfig('DST_OUT'), 21 | 22 | DstOverComposition: asNativeCompositionConfig('DST_OVER'), 23 | 24 | SrcATopComposition: asNativeCompositionConfig('SRC_ATOP'), 25 | 26 | SrcInComposition: asRenderscriptCompositingConfig('AndroidSourceInCompositing'), 27 | 28 | SrcOutComposition: asRenderscriptCompositingConfig('AndroidSourceOutCompositing'), 29 | 30 | SrcOverComposition: asNativeCompositionConfig('SRC_OVER'), 31 | 32 | XorComposition: asNativeCompositionConfig('XOR') 33 | } 34 | -------------------------------------------------------------------------------- /src/composition-filters/shape-transforms.d.ts: -------------------------------------------------------------------------------- 1 | import { shapeTransforms as shapeTransformsAndroid } from './shape-transforms.android' 2 | import { shapeTransforms as shapeTransformsIos } from './shape-transforms.ios' 3 | 4 | declare const shapeTransforms: typeof shapeTransformsAndroid & typeof shapeTransformsIos 5 | -------------------------------------------------------------------------------- /src/composition-filters/shapes.ts: -------------------------------------------------------------------------------- 1 | import { Composition } from '../common/shapes' 2 | 3 | export const shapes = { 4 | // ClearComposition: Composition, 5 | 6 | // DstComposition: Composition, 7 | 8 | DstATopComposition: Composition, 9 | 10 | DstInComposition: Composition, 11 | 12 | DstOutComposition: Composition, 13 | 14 | DstOverComposition: Composition, 15 | 16 | // SrcComposition: Composition, 17 | 18 | SrcATopComposition: Composition, 19 | 20 | SrcInComposition: Composition, 21 | 22 | SrcOutComposition: Composition, 23 | 24 | SrcOverComposition: Composition, 25 | 26 | XorComposition: Composition 27 | } 28 | -------------------------------------------------------------------------------- /src/convolve-matrix-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/convolve-matrix-filters/shapes.ts: -------------------------------------------------------------------------------- 1 | import { scalar, scalarVector } from '../common/inputs' 2 | import { Common } from '../common/shapes' 3 | 4 | export const shapes = { 5 | ConvolveMatrix3x3: { 6 | matrix: scalarVector, 7 | ...Common 8 | }, 9 | 10 | ConvolveMatrix5x5: { 11 | matrix: scalarVector, 12 | ...Common 13 | }, 14 | 15 | Sharpen: { 16 | amount: scalar, 17 | ...Common 18 | }, 19 | 20 | EdgeDetection: Common, 21 | 22 | Emboss: Common, 23 | 24 | FuzzyGlass: Common 25 | } 26 | -------------------------------------------------------------------------------- /src/cssgram-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/generators/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { shapeTransforms } from './shape-transforms' 3 | import { ShapeRegistry } from '../common/shape-registry' 4 | import shapesToComponents from '../common/shapes-to-components' 5 | 6 | ShapeRegistry.addShapes(shapes) 7 | ShapeRegistry.addTransforms(shapeTransforms) 8 | 9 | export default shapesToComponents(shapes) 10 | -------------------------------------------------------------------------------- /src/generators/shape-transforms.d.ts: -------------------------------------------------------------------------------- 1 | import { shapeTransforms as shapeTransformsAndroid } from './shape-transforms.android' 2 | import { shapeTransforms as shapeTransformsIos } from './shape-transforms.ios' 3 | 4 | declare const shapeTransforms: typeof shapeTransformsAndroid & typeof shapeTransformsIos 5 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import blurFilters from './blur-filters' 2 | import generators from './generators' 3 | import colorMatrixFilters from './color-matrix-filters' 4 | import cssgramFilters from './cssgram-filters' 5 | import blendFilters from './blend-filters' 6 | import miscFilters from './misc-filters' 7 | import compositionFilters from './composition-filters' 8 | import convolveMatrixFilters from './convolve-matrix-filters' 9 | import nativePlatformFilters from './native-platform-filters' 10 | import { ImagePlaceholder, ImageBackgroundPlaceholder } from './common/image-placeholder' 11 | import registerFilter from './common/register-filter' 12 | import colorMatrices from 'rn-color-matrices' 13 | import { concatColorMatrices } from 'concat-color-matrices' 14 | import rgbaToRgb from 'rgba-to-rgb' 15 | import { cubicTo, lineTo, quadTo, moveTo, closePath } from './common/path' 16 | import { cleanExtractedImagesCache } from './common/extracted-images-cache' 17 | 18 | const exports = { 19 | ...blurFilters, 20 | ...generators, 21 | ...colorMatrixFilters, 22 | ...convolveMatrixFilters, 23 | ...nativePlatformFilters, 24 | ...cssgramFilters, 25 | ...colorMatrices, 26 | ...blendFilters, 27 | ...miscFilters, 28 | ...compositionFilters, 29 | rgbaToRgb, 30 | concatColorMatrices, 31 | ImagePlaceholder, 32 | ImageBackgroundPlaceholder, 33 | registerFilter, 34 | GenericImageFilter: nativePlatformFilters.ImageFilter, 35 | cubicTo, 36 | lineTo, 37 | quadTo, 38 | moveTo, 39 | closePath, 40 | cleanExtractedImagesCache 41 | } 42 | 43 | declare const module: { exports: typeof exports } 44 | module.exports = exports 45 | -------------------------------------------------------------------------------- /src/misc-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { ShapeRegistry } from '../common/shape-registry' 3 | import shapesToComponents from '../common/shapes-to-components' 4 | 5 | ShapeRegistry.addShapes(shapes) 6 | 7 | export default shapesToComponents(shapes) 8 | -------------------------------------------------------------------------------- /src/misc-filters/shapes.d.ts: -------------------------------------------------------------------------------- 1 | import { shapes as shapesAndroid } from './shapes.android' 2 | import { shapes as shapesIos } from './shapes.ios' 3 | 4 | declare const shapes: typeof shapesAndroid & typeof shapesIos 5 | -------------------------------------------------------------------------------- /src/native-platform-filters/index.ts: -------------------------------------------------------------------------------- 1 | import { shapes } from './shapes' 2 | import { ShapeRegistry } from '../common/shape-registry' 3 | import shapesToComponents from '../common/shapes-to-components' 4 | 5 | ShapeRegistry.addShapes(shapes) 6 | 7 | export default shapesToComponents(shapes) 8 | -------------------------------------------------------------------------------- /src/native-platform-filters/shapes.d.ts: -------------------------------------------------------------------------------- 1 | import { shapes as shapesAndroid } from './shapes.android' 2 | import { shapes as shapesIos } from './shapes.ios' 3 | 4 | declare const shapes: typeof shapesAndroid & typeof shapesIos 5 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "target": "es6", 5 | "strict": true, 6 | "outDir": "../dist", 7 | "jsx": "react-native", 8 | "lib": ["es2016"], 9 | "moduleResolution": "node", 10 | "allowSyntheticDefaultImports": true 11 | } 12 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint-config-standard", "tslint-react"], 3 | "rules": { 4 | "jsx-no-multiline-js": false, 5 | "jsx-wrap-multiline": false, 6 | "jsx-space-before-trailing-slash": true, 7 | "no-parameter-reassignment": true, 8 | "no-shadowed-variable": true, 9 | "max-line-length": [true, 100], 10 | "max-file-line-count": [true, 300], 11 | "ter-indent": [true, 2, { "SwitchCase": true }], 12 | "space-before-function-paren": [true, { 13 | "anonymous": "always", 14 | "named": "never", 15 | "asyncArrow": "always" 16 | }], 17 | "no-any": true, 18 | "ban-ts-ignore": true, 19 | "no-non-null-assertion": true, 20 | "no-null-keyword": true, 21 | "prefer-const": true, 22 | "no-import-side-effect": true 23 | } 24 | } 25 | --------------------------------------------------------------------------------