@momo-kits/native-kits 0.0.1-beta.5 → 0.89.1-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/android/.gradle/8.0/checksums/checksums.lock +0 -0
- package/android/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.0/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.0/gc.properties +0 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +12 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +50 -0
- package/android/build.gradle +35 -69
- package/android/local.properties +8 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/momoplatform/nativekits/foundations/Button.kt +16 -0
- package/android/src/main/java/com/momoplatform/nativekits/libs/Logo.kt +63 -0
- package/android/src/main/java/com/momoplatform/nativekits/libs/TrustBanner.kt +246 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/values/colors.xml +10 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/themes.xml +3 -0
- package/android/src/main/res/values-night/themes.xml +3 -0
- package/android/src/main/res/xml/backup_rules.xml +13 -0
- package/android/src/main/res/xml/data_extraction_rules.xml +19 -0
- package/build.gradle.kts +18 -0
- package/compose/build.gradle.kts +82 -0
- package/compose/src/androidMain/AndroidManifest.xml +2 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +8 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Utils.android.kt +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +288 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +126 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +299 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +246 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +281 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PromotionPopup.kt +72 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +65 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +64 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +63 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +73 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +150 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +173 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +242 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1321 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +5 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +97 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +9 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Utils.ios.kt +18 -0
- package/gradle.properties +19 -0
- package/gradlew +240 -0
- package/gradlew.bat +91 -0
- package/ios/Button/Button.swift +9 -2
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +21 -19
- package/ios/Input/Input.swift +1 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +12 -4
- package/ios/Popup/PopupDisplay.swift +72 -81
- package/ios/Popup/PopupInput.swift +96 -0
- package/ios/Popup/PopupPromotion.swift +52 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +79 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +189 -0
- package/ios/native-kits.podspec +1 -1
- package/local.properties +8 -0
- package/package.json +6 -6
- package/publish.sh +1 -10
- package/settings.gradle.kts +41 -0
- package/android/gradle.properties +0 -5
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +0 -17
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +0 -20
- package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
- package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +0 -38
- package/example/ios/Example/ComponentDetail.swift +0 -35
- package/example/ios/Example/ComponentItem.swift +0 -24
- package/example/ios/Example/ComponentModel.swift +0 -38
- package/example/ios/Example/ContentView.swift +0 -39
- package/example/ios/Example/Example.entitlements +0 -10
- package/example/ios/Example/Foundation/ButtonDemo.swift +0 -80
- package/example/ios/Example/Foundation/ImageDemo.swift +0 -43
- package/example/ios/Example/Foundation/Popup/ActionSheets.swift +0 -136
- package/example/ios/Example/Foundation/Popup/Floats.swift +0 -127
- package/example/ios/Example/Foundation/Popup/Popups.swift +0 -51
- package/example/ios/Example/Foundation/PopupDemo.swift +0 -389
- package/example/ios/Example/Foundation/TextInputDemo.swift +0 -36
- package/example/ios/Example/Foundation/TypographyDemo.swift +0 -53
- package/example/ios/Example/Foundation.swift +0 -26
- package/example/ios/Example/Info.plist +0 -18
- package/example/ios/Example/Library/CheckboxDemo.swift +0 -19
- package/example/ios/Example/Library/SwipeableDemo.swift +0 -105
- package/example/ios/Example/Library/SwitchDemo.swift +0 -19
- package/example/ios/Example/Library.swift +0 -26
- package/example/ios/Example/Main.swift +0 -27
- package/example/ios/Example/Overview.swift +0 -20
- package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
- package/example/ios/Example/Resource/foundation.json +0 -33
- package/example/ios/Example/Resource/library.json +0 -18
- package/example/ios/Example/Utils.swift +0 -30
- package/example/ios/Example/ViewModifier/DarkViewModifier.swift +0 -22
- package/example/ios/Example.xcodeproj/project.pbxproj +0 -581
- package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/example/ios/Podfile +0 -7
- package/example/ios/Podfile.lock +0 -35
- package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +0 -37
- package/example/ios/Pods/Manifest.lock +0 -35
- package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -2047
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
- package/example/ios/Pods/SDWebImage/LICENSE +0 -20
- package/example/ios/Pods/SDWebImage/README.md +0 -352
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.h +0 -340
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.m +0 -172
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.h +0 -63
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.m +0 -165
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.h +0 -67
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.m +0 -120
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.h +0 -114
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.m +0 -392
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.h +0 -112
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.m +0 -420
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.m +0 -133
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.h +0 -168
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.m +0 -79
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.h +0 -110
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.m +0 -540
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.h +0 -145
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.m +0 -326
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.h +0 -73
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.m +0 -256
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.m +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.m +0 -98
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.h +0 -450
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.m +0 -1030
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.h +0 -153
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.m +0 -68
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.h +0 -156
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.m +0 -138
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.h +0 -81
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.m +0 -556
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.h +0 -297
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.m +0 -26
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.h +0 -153
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.m +0 -822
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.h +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.m +0 -130
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.h +0 -36
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.m +0 -28
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.h +0 -22
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.m +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.h +0 -28
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.m +0 -127
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.h +0 -25
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.m +0 -101
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.h +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.m +0 -807
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.h +0 -30
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.m +0 -420
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.h +0 -146
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.m +0 -170
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.h +0 -40
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.m +0 -123
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.h +0 -241
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.m +0 -331
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.h +0 -78
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.m +0 -158
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.h +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.m +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.h +0 -36
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.m +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.h +0 -95
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.m +0 -17
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.h +0 -352
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.m +0 -149
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.h +0 -314
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.m +0 -658
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.h +0 -113
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.m +0 -60
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.h +0 -49
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.m +0 -55
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.h +0 -191
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.m +0 -722
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h +0 -69
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.m +0 -71
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h +0 -69
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.m +0 -73
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.h +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.m +0 -16
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.h +0 -115
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.m +0 -275
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.h +0 -290
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.m +0 -775
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.h +0 -27
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.m +0 -14
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.h +0 -72
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.m +0 -59
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.h +0 -143
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.m +0 -303
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.h +0 -131
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.m +0 -194
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.h +0 -387
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.m +0 -234
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.h +0 -24
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.m +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.h +0 -46
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.m +0 -60
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.h +0 -26
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.m +0 -22
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.h +0 -27
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.m +0 -47
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.h +0 -89
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.m +0 -221
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.h +0 -80
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.m +0 -47
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.h +0 -146
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.m +0 -824
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.h +0 -129
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.m +0 -76
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.h +0 -194
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.m +0 -67
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.h +0 -110
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.m +0 -446
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.h +0 -48
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.m +0 -82
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.h +0 -24
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.m +0 -42
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.h +0 -14
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.m +0 -29
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h +0 -21
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m +0 -92
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.h +0 -18
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.m +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.h +0 -29
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.m +0 -227
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.m +0 -127
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m +0 -164
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h +0 -21
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m +0 -83
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageIOAnimatedCoderInternal.h +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h +0 -122
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m +0 -13
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h +0 -20
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m +0 -79
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWebImageTransitionInternal.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h +0 -667
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.h +0 -18
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.m +0 -42
- package/example/ios/Pods/SDWebImage/WebImage/SDWebImage.h +0 -89
- package/example/ios/Pods/SDWebImageSwiftUI/LICENSE +0 -19
- package/example/ios/Pods/SDWebImageSwiftUI/README.md +0 -690
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/AnimatedImage.swift +0 -870
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Backport.swift +0 -59
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/OnChange.swift +0 -52
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Overlay.swift +0 -124
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/StateObject.swift +0 -151
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Image.swift +0 -78
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageManager.swift +0 -132
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImagePlayer.swift +0 -122
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageViewWrapper.swift +0 -133
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ActivityIndicator.swift +0 -82
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift +0 -97
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift +0 -114
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SDWebImageSwiftUI.swift +0 -64
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SwiftUICompatibility.swift +0 -92
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Transition/Transition.swift +0 -93
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/WebImage.swift +0 -509
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Module/SDWebImageSwiftUI.h +0 -15
- package/example/ios/Pods/SkeletonUI/LICENSE +0 -21
- package/example/ios/Pods/SkeletonUI/README.md +0 -137
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AngleInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AnglePresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Animation/AnimationInteractor.swift +0 -56
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift +0 -58
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearancePresenter.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift +0 -16
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Image+OptionalType.swift +0 -102
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift +0 -26
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift +0 -19
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Text+OptionalType.swift +0 -27
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift +0 -35
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift +0 -8
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift +0 -8
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +0 -52
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilineInteractor.swift +0 -41
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilinePresenter.swift +0 -9
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Protocols/OptionalType.swift +0 -4
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapeInteractor.swift +0 -33
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapePresenter.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift +0 -20
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift +0 -27
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonList.swift +0 -20
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift +0 -15
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonShape.swift +0 -64
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonView.swift +0 -25
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +0 -75
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +0 -119
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h +0 -75
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.debug.xcconfig +0 -14
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.release.xcconfig +0 -14
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-umbrella.h +0 -17
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.debug.xcconfig +0 -17
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.release.xcconfig +0 -17
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.debug.xcconfig +0 -12
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.release.xcconfig +0 -12
- package/ios/Extensions/View++.swift +0 -9
|
@@ -1,824 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of the SDWebImage package.
|
|
3
|
-
* (c) Olivier Poitrey <rs@dailymotion.com>
|
|
4
|
-
*
|
|
5
|
-
* For the full copyright and license information, please view the LICENSE
|
|
6
|
-
* file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
#import "UIImage+Transform.h"
|
|
10
|
-
#import "NSImage+Compatibility.h"
|
|
11
|
-
#import "SDImageGraphics.h"
|
|
12
|
-
#import "SDGraphicsImageRenderer.h"
|
|
13
|
-
#import "NSBezierPath+SDRoundedCorners.h"
|
|
14
|
-
#import <Accelerate/Accelerate.h>
|
|
15
|
-
#if SD_UIKIT || SD_MAC
|
|
16
|
-
#import <CoreImage/CoreImage.h>
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
static inline CGRect SDCGRectFitWithScaleMode(CGRect rect, CGSize size, SDImageScaleMode scaleMode) {
|
|
20
|
-
rect = CGRectStandardize(rect);
|
|
21
|
-
size.width = size.width < 0 ? -size.width : size.width;
|
|
22
|
-
size.height = size.height < 0 ? -size.height : size.height;
|
|
23
|
-
CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
|
|
24
|
-
switch (scaleMode) {
|
|
25
|
-
case SDImageScaleModeAspectFit:
|
|
26
|
-
case SDImageScaleModeAspectFill: {
|
|
27
|
-
if (rect.size.width < 0.01 || rect.size.height < 0.01 ||
|
|
28
|
-
size.width < 0.01 || size.height < 0.01) {
|
|
29
|
-
rect.origin = center;
|
|
30
|
-
rect.size = CGSizeZero;
|
|
31
|
-
} else {
|
|
32
|
-
CGFloat scale;
|
|
33
|
-
if (scaleMode == SDImageScaleModeAspectFit) {
|
|
34
|
-
if (size.width / size.height < rect.size.width / rect.size.height) {
|
|
35
|
-
scale = rect.size.height / size.height;
|
|
36
|
-
} else {
|
|
37
|
-
scale = rect.size.width / size.width;
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
if (size.width / size.height < rect.size.width / rect.size.height) {
|
|
41
|
-
scale = rect.size.width / size.width;
|
|
42
|
-
} else {
|
|
43
|
-
scale = rect.size.height / size.height;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
size.width *= scale;
|
|
47
|
-
size.height *= scale;
|
|
48
|
-
rect.size = size;
|
|
49
|
-
rect.origin = CGPointMake(center.x - size.width * 0.5, center.y - size.height * 0.5);
|
|
50
|
-
}
|
|
51
|
-
} break;
|
|
52
|
-
case SDImageScaleModeFill:
|
|
53
|
-
default: {
|
|
54
|
-
rect = rect;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return rect;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static inline UIColor * SDGetColorFromGrayscale(Pixel_88 pixel, CGBitmapInfo bitmapInfo) {
|
|
61
|
-
// Get alpha info, byteOrder info
|
|
62
|
-
CGImageAlphaInfo alphaInfo = bitmapInfo & kCGBitmapAlphaInfoMask;
|
|
63
|
-
CGBitmapInfo byteOrderInfo = bitmapInfo & kCGBitmapByteOrderMask;
|
|
64
|
-
CGFloat w = 0, a = 1;
|
|
65
|
-
|
|
66
|
-
BOOL byteOrderNormal = NO;
|
|
67
|
-
switch (byteOrderInfo) {
|
|
68
|
-
case kCGBitmapByteOrderDefault: {
|
|
69
|
-
byteOrderNormal = YES;
|
|
70
|
-
} break;
|
|
71
|
-
case kCGBitmapByteOrder32Little: {
|
|
72
|
-
} break;
|
|
73
|
-
case kCGBitmapByteOrder32Big: {
|
|
74
|
-
byteOrderNormal = YES;
|
|
75
|
-
} break;
|
|
76
|
-
default: break;
|
|
77
|
-
}
|
|
78
|
-
switch (alphaInfo) {
|
|
79
|
-
case kCGImageAlphaPremultipliedFirst:
|
|
80
|
-
case kCGImageAlphaFirst: {
|
|
81
|
-
if (byteOrderNormal) {
|
|
82
|
-
// AW
|
|
83
|
-
a = pixel[0] / 255.0;
|
|
84
|
-
w = pixel[1] / 255.0;
|
|
85
|
-
} else {
|
|
86
|
-
// WA
|
|
87
|
-
w = pixel[0] / 255.0;
|
|
88
|
-
a = pixel[1] / 255.0;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
break;
|
|
92
|
-
case kCGImageAlphaPremultipliedLast:
|
|
93
|
-
case kCGImageAlphaLast: {
|
|
94
|
-
if (byteOrderNormal) {
|
|
95
|
-
// WA
|
|
96
|
-
w = pixel[0] / 255.0;
|
|
97
|
-
a = pixel[1] / 255.0;
|
|
98
|
-
} else {
|
|
99
|
-
// AW
|
|
100
|
-
a = pixel[0] / 255.0;
|
|
101
|
-
w = pixel[1] / 255.0;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
case kCGImageAlphaNone: {
|
|
106
|
-
// W
|
|
107
|
-
w = pixel[0] / 255.0;
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
case kCGImageAlphaNoneSkipLast: {
|
|
111
|
-
if (byteOrderNormal) {
|
|
112
|
-
// WX
|
|
113
|
-
w = pixel[0] / 255.0;
|
|
114
|
-
} else {
|
|
115
|
-
// XW
|
|
116
|
-
a = pixel[1] / 255.0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
case kCGImageAlphaNoneSkipFirst: {
|
|
121
|
-
if (byteOrderNormal) {
|
|
122
|
-
// XW
|
|
123
|
-
a = pixel[1] / 255.0;
|
|
124
|
-
} else {
|
|
125
|
-
// WX
|
|
126
|
-
a = pixel[0] / 255.0;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
case kCGImageAlphaOnly: {
|
|
131
|
-
// A
|
|
132
|
-
a = pixel[0] / 255.0;
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
default:
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return [UIColor colorWithWhite:w alpha:a];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
static inline UIColor * SDGetColorFromRGBA(Pixel_8888 pixel, CGBitmapInfo bitmapInfo) {
|
|
143
|
-
// Get alpha info, byteOrder info
|
|
144
|
-
CGImageAlphaInfo alphaInfo = bitmapInfo & kCGBitmapAlphaInfoMask;
|
|
145
|
-
CGBitmapInfo byteOrderInfo = bitmapInfo & kCGBitmapByteOrderMask;
|
|
146
|
-
CGFloat r = 0, g = 0, b = 0, a = 1;
|
|
147
|
-
|
|
148
|
-
BOOL byteOrderNormal = NO;
|
|
149
|
-
switch (byteOrderInfo) {
|
|
150
|
-
case kCGBitmapByteOrderDefault: {
|
|
151
|
-
byteOrderNormal = YES;
|
|
152
|
-
} break;
|
|
153
|
-
case kCGBitmapByteOrder32Little: {
|
|
154
|
-
} break;
|
|
155
|
-
case kCGBitmapByteOrder32Big: {
|
|
156
|
-
byteOrderNormal = YES;
|
|
157
|
-
} break;
|
|
158
|
-
default: break;
|
|
159
|
-
}
|
|
160
|
-
switch (alphaInfo) {
|
|
161
|
-
case kCGImageAlphaPremultipliedFirst:
|
|
162
|
-
case kCGImageAlphaFirst: {
|
|
163
|
-
if (byteOrderNormal) {
|
|
164
|
-
// ARGB8888
|
|
165
|
-
a = pixel[0] / 255.0;
|
|
166
|
-
r = pixel[1] / 255.0;
|
|
167
|
-
g = pixel[2] / 255.0;
|
|
168
|
-
b = pixel[3] / 255.0;
|
|
169
|
-
} else {
|
|
170
|
-
// BGRA8888
|
|
171
|
-
b = pixel[0] / 255.0;
|
|
172
|
-
g = pixel[1] / 255.0;
|
|
173
|
-
r = pixel[2] / 255.0;
|
|
174
|
-
a = pixel[3] / 255.0;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
case kCGImageAlphaPremultipliedLast:
|
|
179
|
-
case kCGImageAlphaLast: {
|
|
180
|
-
if (byteOrderNormal) {
|
|
181
|
-
// RGBA8888
|
|
182
|
-
r = pixel[0] / 255.0;
|
|
183
|
-
g = pixel[1] / 255.0;
|
|
184
|
-
b = pixel[2] / 255.0;
|
|
185
|
-
a = pixel[3] / 255.0;
|
|
186
|
-
} else {
|
|
187
|
-
// ABGR8888
|
|
188
|
-
a = pixel[0] / 255.0;
|
|
189
|
-
b = pixel[1] / 255.0;
|
|
190
|
-
g = pixel[2] / 255.0;
|
|
191
|
-
r = pixel[3] / 255.0;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
break;
|
|
195
|
-
case kCGImageAlphaNone: {
|
|
196
|
-
if (byteOrderNormal) {
|
|
197
|
-
// RGB
|
|
198
|
-
r = pixel[0] / 255.0;
|
|
199
|
-
g = pixel[1] / 255.0;
|
|
200
|
-
b = pixel[2] / 255.0;
|
|
201
|
-
} else {
|
|
202
|
-
// BGR
|
|
203
|
-
b = pixel[0] / 255.0;
|
|
204
|
-
g = pixel[1] / 255.0;
|
|
205
|
-
r = pixel[2] / 255.0;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
break;
|
|
209
|
-
case kCGImageAlphaNoneSkipLast: {
|
|
210
|
-
if (byteOrderNormal) {
|
|
211
|
-
// RGBX
|
|
212
|
-
r = pixel[0] / 255.0;
|
|
213
|
-
g = pixel[1] / 255.0;
|
|
214
|
-
b = pixel[2] / 255.0;
|
|
215
|
-
} else {
|
|
216
|
-
// XBGR
|
|
217
|
-
b = pixel[1] / 255.0;
|
|
218
|
-
g = pixel[2] / 255.0;
|
|
219
|
-
r = pixel[3] / 255.0;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
break;
|
|
223
|
-
case kCGImageAlphaNoneSkipFirst: {
|
|
224
|
-
if (byteOrderNormal) {
|
|
225
|
-
// XRGB
|
|
226
|
-
r = pixel[1] / 255.0;
|
|
227
|
-
g = pixel[2] / 255.0;
|
|
228
|
-
b = pixel[3] / 255.0;
|
|
229
|
-
} else {
|
|
230
|
-
// BGRX
|
|
231
|
-
b = pixel[0] / 255.0;
|
|
232
|
-
g = pixel[1] / 255.0;
|
|
233
|
-
r = pixel[2] / 255.0;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
case kCGImageAlphaOnly: {
|
|
238
|
-
// A
|
|
239
|
-
a = pixel[0] / 255.0;
|
|
240
|
-
}
|
|
241
|
-
break;
|
|
242
|
-
default:
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return [UIColor colorWithRed:r green:g blue:b alpha:a];
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
#if SD_UIKIT || SD_MAC
|
|
250
|
-
// Create-Rule, caller should call CGImageRelease
|
|
251
|
-
static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull ciImage) {
|
|
252
|
-
CGImageRef imageRef = NULL;
|
|
253
|
-
if (@available(iOS 10, macOS 10.12, tvOS 10, *)) {
|
|
254
|
-
imageRef = ciImage.CGImage;
|
|
255
|
-
}
|
|
256
|
-
if (!imageRef) {
|
|
257
|
-
CIContext *context = [CIContext context];
|
|
258
|
-
imageRef = [context createCGImage:ciImage fromRect:ciImage.extent];
|
|
259
|
-
} else {
|
|
260
|
-
CGImageRetain(imageRef);
|
|
261
|
-
}
|
|
262
|
-
return imageRef;
|
|
263
|
-
}
|
|
264
|
-
#endif
|
|
265
|
-
|
|
266
|
-
@implementation UIImage (Transform)
|
|
267
|
-
|
|
268
|
-
- (void)sd_drawInRect:(CGRect)rect context:(CGContextRef)context scaleMode:(SDImageScaleMode)scaleMode clipsToBounds:(BOOL)clips {
|
|
269
|
-
CGRect drawRect = SDCGRectFitWithScaleMode(rect, self.size, scaleMode);
|
|
270
|
-
if (drawRect.size.width == 0 || drawRect.size.height == 0) return;
|
|
271
|
-
if (clips) {
|
|
272
|
-
if (context) {
|
|
273
|
-
CGContextSaveGState(context);
|
|
274
|
-
CGContextAddRect(context, rect);
|
|
275
|
-
CGContextClip(context);
|
|
276
|
-
[self drawInRect:drawRect];
|
|
277
|
-
CGContextRestoreGState(context);
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
[self drawInRect:drawRect];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
- (nullable UIImage *)sd_resizedImageWithSize:(CGSize)size scaleMode:(SDImageScaleMode)scaleMode {
|
|
285
|
-
if (size.width <= 0 || size.height <= 0) return nil;
|
|
286
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
|
287
|
-
format.scale = self.scale;
|
|
288
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
|
|
289
|
-
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
|
290
|
-
[self sd_drawInRect:CGRectMake(0, 0, size.width, size.height) context:context scaleMode:scaleMode clipsToBounds:NO];
|
|
291
|
-
}];
|
|
292
|
-
return image;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
- (nullable UIImage *)sd_croppedImageWithRect:(CGRect)rect {
|
|
296
|
-
rect.origin.x *= self.scale;
|
|
297
|
-
rect.origin.y *= self.scale;
|
|
298
|
-
rect.size.width *= self.scale;
|
|
299
|
-
rect.size.height *= self.scale;
|
|
300
|
-
if (rect.size.width <= 0 || rect.size.height <= 0) return nil;
|
|
301
|
-
|
|
302
|
-
#if SD_UIKIT || SD_MAC
|
|
303
|
-
// CIImage shortcut
|
|
304
|
-
if (self.CIImage) {
|
|
305
|
-
CGRect croppingRect = CGRectMake(rect.origin.x, self.size.height - CGRectGetMaxY(rect), rect.size.width, rect.size.height);
|
|
306
|
-
CIImage *ciImage = [self.CIImage imageByCroppingToRect:croppingRect];
|
|
307
|
-
#if SD_UIKIT
|
|
308
|
-
UIImage *image = [UIImage imageWithCIImage:ciImage scale:self.scale orientation:self.imageOrientation];
|
|
309
|
-
#else
|
|
310
|
-
UIImage *image = [[UIImage alloc] initWithCIImage:ciImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
311
|
-
#endif
|
|
312
|
-
return image;
|
|
313
|
-
}
|
|
314
|
-
#endif
|
|
315
|
-
|
|
316
|
-
CGImageRef imageRef = self.CGImage;
|
|
317
|
-
if (!imageRef) {
|
|
318
|
-
return nil;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
CGImageRef croppedImageRef = CGImageCreateWithImageInRect(imageRef, rect);
|
|
322
|
-
if (!croppedImageRef) {
|
|
323
|
-
return nil;
|
|
324
|
-
}
|
|
325
|
-
#if SD_UIKIT || SD_WATCH
|
|
326
|
-
UIImage *image = [UIImage imageWithCGImage:croppedImageRef scale:self.scale orientation:self.imageOrientation];
|
|
327
|
-
#else
|
|
328
|
-
UIImage *image = [[UIImage alloc] initWithCGImage:croppedImageRef scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
329
|
-
#endif
|
|
330
|
-
CGImageRelease(croppedImageRef);
|
|
331
|
-
return image;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
- (nullable UIImage *)sd_roundedCornerImageWithRadius:(CGFloat)cornerRadius corners:(SDRectCorner)corners borderWidth:(CGFloat)borderWidth borderColor:(nullable UIColor *)borderColor {
|
|
335
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
|
336
|
-
format.scale = self.scale;
|
|
337
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:self.size format:format];
|
|
338
|
-
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
|
339
|
-
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
|
|
340
|
-
|
|
341
|
-
CGFloat minSize = MIN(self.size.width, self.size.height);
|
|
342
|
-
if (borderWidth < minSize / 2) {
|
|
343
|
-
#if SD_UIKIT || SD_WATCH
|
|
344
|
-
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(rect, borderWidth, borderWidth) byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
|
|
345
|
-
#else
|
|
346
|
-
NSBezierPath *path = [NSBezierPath sd_bezierPathWithRoundedRect:CGRectInset(rect, borderWidth, borderWidth) byRoundingCorners:corners cornerRadius:cornerRadius];
|
|
347
|
-
#endif
|
|
348
|
-
[path closePath];
|
|
349
|
-
|
|
350
|
-
CGContextSaveGState(context);
|
|
351
|
-
[path addClip];
|
|
352
|
-
[self drawInRect:rect];
|
|
353
|
-
CGContextRestoreGState(context);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (borderColor && borderWidth < minSize / 2 && borderWidth > 0) {
|
|
357
|
-
CGFloat strokeInset = (floor(borderWidth * self.scale) + 0.5) / self.scale;
|
|
358
|
-
CGRect strokeRect = CGRectInset(rect, strokeInset, strokeInset);
|
|
359
|
-
CGFloat strokeRadius = cornerRadius > self.scale / 2 ? cornerRadius - self.scale / 2 : 0;
|
|
360
|
-
#if SD_UIKIT || SD_WATCH
|
|
361
|
-
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:strokeRect byRoundingCorners:corners cornerRadii:CGSizeMake(strokeRadius, strokeRadius)];
|
|
362
|
-
#else
|
|
363
|
-
NSBezierPath *path = [NSBezierPath sd_bezierPathWithRoundedRect:strokeRect byRoundingCorners:corners cornerRadius:strokeRadius];
|
|
364
|
-
#endif
|
|
365
|
-
[path closePath];
|
|
366
|
-
|
|
367
|
-
path.lineWidth = borderWidth;
|
|
368
|
-
[borderColor setStroke];
|
|
369
|
-
[path stroke];
|
|
370
|
-
}
|
|
371
|
-
}];
|
|
372
|
-
return image;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
- (nullable UIImage *)sd_rotatedImageWithAngle:(CGFloat)angle fitSize:(BOOL)fitSize {
|
|
376
|
-
size_t width = self.size.width;
|
|
377
|
-
size_t height = self.size.height;
|
|
378
|
-
CGRect newRect = CGRectApplyAffineTransform(CGRectMake(0, 0, width, height),
|
|
379
|
-
fitSize ? CGAffineTransformMakeRotation(angle) : CGAffineTransformIdentity);
|
|
380
|
-
|
|
381
|
-
#if SD_UIKIT || SD_MAC
|
|
382
|
-
// CIImage shortcut
|
|
383
|
-
if (self.CIImage) {
|
|
384
|
-
CIImage *ciImage = self.CIImage;
|
|
385
|
-
if (fitSize) {
|
|
386
|
-
CGAffineTransform transform = CGAffineTransformMakeRotation(angle);
|
|
387
|
-
ciImage = [ciImage imageByApplyingTransform:transform];
|
|
388
|
-
} else {
|
|
389
|
-
CIFilter *filter = [CIFilter filterWithName:@"CIStraightenFilter"];
|
|
390
|
-
[filter setValue:ciImage forKey:kCIInputImageKey];
|
|
391
|
-
[filter setValue:@(angle) forKey:kCIInputAngleKey];
|
|
392
|
-
ciImage = filter.outputImage;
|
|
393
|
-
}
|
|
394
|
-
#if SD_UIKIT || SD_WATCH
|
|
395
|
-
UIImage *image = [UIImage imageWithCIImage:ciImage scale:self.scale orientation:self.imageOrientation];
|
|
396
|
-
#else
|
|
397
|
-
UIImage *image = [[UIImage alloc] initWithCIImage:ciImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
398
|
-
#endif
|
|
399
|
-
return image;
|
|
400
|
-
}
|
|
401
|
-
#endif
|
|
402
|
-
|
|
403
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
|
404
|
-
format.scale = self.scale;
|
|
405
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:newRect.size format:format];
|
|
406
|
-
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
|
407
|
-
CGContextSetShouldAntialias(context, true);
|
|
408
|
-
CGContextSetAllowsAntialiasing(context, true);
|
|
409
|
-
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
|
|
410
|
-
CGContextTranslateCTM(context, +(newRect.size.width * 0.5), +(newRect.size.height * 0.5));
|
|
411
|
-
#if SD_UIKIT || SD_WATCH
|
|
412
|
-
// Use UIKit coordinate system counterclockwise (⟲)
|
|
413
|
-
CGContextRotateCTM(context, -angle);
|
|
414
|
-
#else
|
|
415
|
-
CGContextRotateCTM(context, angle);
|
|
416
|
-
#endif
|
|
417
|
-
|
|
418
|
-
[self drawInRect:CGRectMake(-(width * 0.5), -(height * 0.5), width, height)];
|
|
419
|
-
}];
|
|
420
|
-
return image;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
- (nullable UIImage *)sd_flippedImageWithHorizontal:(BOOL)horizontal vertical:(BOOL)vertical {
|
|
424
|
-
size_t width = self.size.width;
|
|
425
|
-
size_t height = self.size.height;
|
|
426
|
-
|
|
427
|
-
#if SD_UIKIT || SD_MAC
|
|
428
|
-
// CIImage shortcut
|
|
429
|
-
if (self.CIImage) {
|
|
430
|
-
CGAffineTransform transform = CGAffineTransformIdentity;
|
|
431
|
-
// Use UIKit coordinate system
|
|
432
|
-
if (horizontal) {
|
|
433
|
-
CGAffineTransform flipHorizontal = CGAffineTransformMake(-1, 0, 0, 1, width, 0);
|
|
434
|
-
transform = CGAffineTransformConcat(transform, flipHorizontal);
|
|
435
|
-
}
|
|
436
|
-
if (vertical) {
|
|
437
|
-
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, height);
|
|
438
|
-
transform = CGAffineTransformConcat(transform, flipVertical);
|
|
439
|
-
}
|
|
440
|
-
CIImage *ciImage = [self.CIImage imageByApplyingTransform:transform];
|
|
441
|
-
#if SD_UIKIT
|
|
442
|
-
UIImage *image = [UIImage imageWithCIImage:ciImage scale:self.scale orientation:self.imageOrientation];
|
|
443
|
-
#else
|
|
444
|
-
UIImage *image = [[UIImage alloc] initWithCIImage:ciImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
445
|
-
#endif
|
|
446
|
-
return image;
|
|
447
|
-
}
|
|
448
|
-
#endif
|
|
449
|
-
|
|
450
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
|
451
|
-
format.scale = self.scale;
|
|
452
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:self.size format:format];
|
|
453
|
-
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
|
454
|
-
// Use UIKit coordinate system
|
|
455
|
-
if (horizontal) {
|
|
456
|
-
CGAffineTransform flipHorizontal = CGAffineTransformMake(-1, 0, 0, 1, width, 0);
|
|
457
|
-
CGContextConcatCTM(context, flipHorizontal);
|
|
458
|
-
}
|
|
459
|
-
if (vertical) {
|
|
460
|
-
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, height);
|
|
461
|
-
CGContextConcatCTM(context, flipVertical);
|
|
462
|
-
}
|
|
463
|
-
[self drawInRect:CGRectMake(0, 0, width, height)];
|
|
464
|
-
}];
|
|
465
|
-
return image;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
#pragma mark - Image Blending
|
|
469
|
-
|
|
470
|
-
- (nullable UIImage *)sd_tintedImageWithColor:(nonnull UIColor *)tintColor {
|
|
471
|
-
BOOL hasTint = CGColorGetAlpha(tintColor.CGColor) > __FLT_EPSILON__;
|
|
472
|
-
if (!hasTint) {
|
|
473
|
-
return self;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
#if SD_UIKIT || SD_MAC
|
|
477
|
-
// CIImage shortcut
|
|
478
|
-
if (self.CIImage) {
|
|
479
|
-
CIImage *ciImage = self.CIImage;
|
|
480
|
-
CIImage *colorImage = [CIImage imageWithColor:[[CIColor alloc] initWithColor:tintColor]];
|
|
481
|
-
colorImage = [colorImage imageByCroppingToRect:ciImage.extent];
|
|
482
|
-
CIFilter *filter = [CIFilter filterWithName:@"CISourceAtopCompositing"];
|
|
483
|
-
[filter setValue:colorImage forKey:kCIInputImageKey];
|
|
484
|
-
[filter setValue:ciImage forKey:kCIInputBackgroundImageKey];
|
|
485
|
-
ciImage = filter.outputImage;
|
|
486
|
-
#if SD_UIKIT
|
|
487
|
-
UIImage *image = [UIImage imageWithCIImage:ciImage scale:self.scale orientation:self.imageOrientation];
|
|
488
|
-
#else
|
|
489
|
-
UIImage *image = [[UIImage alloc] initWithCIImage:ciImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
490
|
-
#endif
|
|
491
|
-
return image;
|
|
492
|
-
}
|
|
493
|
-
#endif
|
|
494
|
-
|
|
495
|
-
CGSize size = self.size;
|
|
496
|
-
CGRect rect = { CGPointZero, size };
|
|
497
|
-
CGFloat scale = self.scale;
|
|
498
|
-
|
|
499
|
-
// blend mode, see https://en.wikipedia.org/wiki/Alpha_compositing
|
|
500
|
-
CGBlendMode blendMode = kCGBlendModeSourceAtop;
|
|
501
|
-
|
|
502
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
|
503
|
-
format.scale = scale;
|
|
504
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
|
|
505
|
-
UIImage *image = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
|
506
|
-
[self drawInRect:rect];
|
|
507
|
-
CGContextSetBlendMode(context, blendMode);
|
|
508
|
-
CGContextSetFillColorWithColor(context, tintColor.CGColor);
|
|
509
|
-
CGContextFillRect(context, rect);
|
|
510
|
-
}];
|
|
511
|
-
return image;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
- (nullable UIColor *)sd_colorAtPoint:(CGPoint)point {
|
|
515
|
-
CGImageRef imageRef = NULL;
|
|
516
|
-
// CIImage compatible
|
|
517
|
-
#if SD_UIKIT || SD_MAC
|
|
518
|
-
if (self.CIImage) {
|
|
519
|
-
imageRef = SDCreateCGImageFromCIImage(self.CIImage);
|
|
520
|
-
}
|
|
521
|
-
#endif
|
|
522
|
-
if (!imageRef) {
|
|
523
|
-
imageRef = self.CGImage;
|
|
524
|
-
CGImageRetain(imageRef);
|
|
525
|
-
}
|
|
526
|
-
if (!imageRef) {
|
|
527
|
-
return nil;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// Check point
|
|
531
|
-
CGFloat width = CGImageGetWidth(imageRef);
|
|
532
|
-
CGFloat height = CGImageGetHeight(imageRef);
|
|
533
|
-
if (point.x < 0 || point.y < 0 || point.x >= width || point.y >= height) {
|
|
534
|
-
CGImageRelease(imageRef);
|
|
535
|
-
return nil;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// Get pixels
|
|
539
|
-
CGDataProviderRef provider = CGImageGetDataProvider(imageRef);
|
|
540
|
-
if (!provider) {
|
|
541
|
-
CGImageRelease(imageRef);
|
|
542
|
-
return nil;
|
|
543
|
-
}
|
|
544
|
-
CFDataRef data = CGDataProviderCopyData(provider);
|
|
545
|
-
if (!data) {
|
|
546
|
-
CGImageRelease(imageRef);
|
|
547
|
-
return nil;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
// Get pixel at point
|
|
551
|
-
size_t bytesPerRow = CGImageGetBytesPerRow(imageRef);
|
|
552
|
-
size_t components = CGImageGetBitsPerPixel(imageRef) / CGImageGetBitsPerComponent(imageRef);
|
|
553
|
-
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
|
|
554
|
-
|
|
555
|
-
CFRange range = CFRangeMake(bytesPerRow * point.y + components * point.x, components);
|
|
556
|
-
if (CFDataGetLength(data) < range.location + range.length) {
|
|
557
|
-
CFRelease(data);
|
|
558
|
-
CGImageRelease(imageRef);
|
|
559
|
-
return nil;
|
|
560
|
-
}
|
|
561
|
-
// greyscale
|
|
562
|
-
if (components == 2) {
|
|
563
|
-
Pixel_88 pixel = {0};
|
|
564
|
-
CFDataGetBytes(data, range, pixel);
|
|
565
|
-
CFRelease(data);
|
|
566
|
-
CGImageRelease(imageRef);
|
|
567
|
-
// Convert to color
|
|
568
|
-
return SDGetColorFromGrayscale(pixel, bitmapInfo);
|
|
569
|
-
} else if (components == 3 || components == 4) {
|
|
570
|
-
// RGB/RGBA
|
|
571
|
-
Pixel_8888 pixel = {0};
|
|
572
|
-
CFDataGetBytes(data, range, pixel);
|
|
573
|
-
CFRelease(data);
|
|
574
|
-
CGImageRelease(imageRef);
|
|
575
|
-
// Convert to color
|
|
576
|
-
return SDGetColorFromRGBA(pixel, bitmapInfo);
|
|
577
|
-
} else {
|
|
578
|
-
NSLog(@"Unsupported components: %zu", components);
|
|
579
|
-
CFRelease(data);
|
|
580
|
-
CGImageRelease(imageRef);
|
|
581
|
-
return nil;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
- (nullable NSArray<UIColor *> *)sd_colorsWithRect:(CGRect)rect {
|
|
586
|
-
CGImageRef imageRef = NULL;
|
|
587
|
-
// CIImage compatible
|
|
588
|
-
#if SD_UIKIT || SD_MAC
|
|
589
|
-
if (self.CIImage) {
|
|
590
|
-
imageRef = SDCreateCGImageFromCIImage(self.CIImage);
|
|
591
|
-
}
|
|
592
|
-
#endif
|
|
593
|
-
if (!imageRef) {
|
|
594
|
-
imageRef = self.CGImage;
|
|
595
|
-
CGImageRetain(imageRef);
|
|
596
|
-
}
|
|
597
|
-
if (!imageRef) {
|
|
598
|
-
return nil;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// Check rect
|
|
602
|
-
CGFloat width = CGImageGetWidth(imageRef);
|
|
603
|
-
CGFloat height = CGImageGetHeight(imageRef);
|
|
604
|
-
if (CGRectGetWidth(rect) <= 0 || CGRectGetHeight(rect) <= 0 || CGRectGetMinX(rect) < 0 || CGRectGetMinY(rect) < 0 || CGRectGetMaxX(rect) > width || CGRectGetMaxY(rect) > height) {
|
|
605
|
-
CGImageRelease(imageRef);
|
|
606
|
-
return nil;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// Get pixels
|
|
610
|
-
CGDataProviderRef provider = CGImageGetDataProvider(imageRef);
|
|
611
|
-
if (!provider) {
|
|
612
|
-
CGImageRelease(imageRef);
|
|
613
|
-
return nil;
|
|
614
|
-
}
|
|
615
|
-
CFDataRef data = CGDataProviderCopyData(provider);
|
|
616
|
-
if (!data) {
|
|
617
|
-
CGImageRelease(imageRef);
|
|
618
|
-
return nil;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// Get pixels with rect
|
|
622
|
-
size_t bytesPerRow = CGImageGetBytesPerRow(imageRef);
|
|
623
|
-
size_t components = CGImageGetBitsPerPixel(imageRef) / CGImageGetBitsPerComponent(imageRef);
|
|
624
|
-
|
|
625
|
-
size_t start = bytesPerRow * CGRectGetMinY(rect) + components * CGRectGetMinX(rect);
|
|
626
|
-
size_t end = bytesPerRow * (CGRectGetMaxY(rect) - 1) + components * CGRectGetMaxX(rect);
|
|
627
|
-
if (CFDataGetLength(data) < (CFIndex)end) {
|
|
628
|
-
CFRelease(data);
|
|
629
|
-
CGImageRelease(imageRef);
|
|
630
|
-
return nil;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
const UInt8 *pixels = CFDataGetBytePtr(data);
|
|
634
|
-
size_t row = CGRectGetMinY(rect);
|
|
635
|
-
size_t col = CGRectGetMaxX(rect);
|
|
636
|
-
|
|
637
|
-
// Convert to color
|
|
638
|
-
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
|
|
639
|
-
NSMutableArray<UIColor *> *colors = [NSMutableArray arrayWithCapacity:CGRectGetWidth(rect) * CGRectGetHeight(rect)];
|
|
640
|
-
for (size_t index = start; index < end; index += components) {
|
|
641
|
-
if (index >= row * bytesPerRow + col * components) {
|
|
642
|
-
// Index beyond the end of current row, go next row
|
|
643
|
-
row++;
|
|
644
|
-
index = row * bytesPerRow + CGRectGetMinX(rect) * components;
|
|
645
|
-
index -= components;
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
UIColor *color;
|
|
649
|
-
if (components == 2) {
|
|
650
|
-
Pixel_88 pixel = {pixels[index], pixel[index+1]};
|
|
651
|
-
color = SDGetColorFromGrayscale(pixel, bitmapInfo);
|
|
652
|
-
} else {
|
|
653
|
-
if (components == 3) {
|
|
654
|
-
Pixel_8888 pixel = {pixels[index], pixels[index+1], pixels[index+2], 0};
|
|
655
|
-
color = SDGetColorFromRGBA(pixel, bitmapInfo);
|
|
656
|
-
} else if (components == 4) {
|
|
657
|
-
Pixel_8888 pixel = {pixels[index], pixels[index+1], pixels[index+2], pixels[index+3]};
|
|
658
|
-
color = SDGetColorFromRGBA(pixel, bitmapInfo);
|
|
659
|
-
} else {
|
|
660
|
-
NSLog(@"Unsupported components: %zu", components);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
if (color) {
|
|
664
|
-
[colors addObject:color];
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
CFRelease(data);
|
|
668
|
-
CGImageRelease(imageRef);
|
|
669
|
-
|
|
670
|
-
return [colors copy];
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
#pragma mark - Image Effect
|
|
674
|
-
|
|
675
|
-
// We use vImage to do box convolve for performance and support for watchOS. However, you can just use `CIFilter.CIGaussianBlur`. For other blur effect, use any filter in `CICategoryBlur`
|
|
676
|
-
- (nullable UIImage *)sd_blurredImageWithRadius:(CGFloat)blurRadius {
|
|
677
|
-
if (self.size.width < 1 || self.size.height < 1) {
|
|
678
|
-
return nil;
|
|
679
|
-
}
|
|
680
|
-
BOOL hasBlur = blurRadius > __FLT_EPSILON__;
|
|
681
|
-
if (!hasBlur) {
|
|
682
|
-
return self;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
CGFloat scale = self.scale;
|
|
686
|
-
CGFloat inputRadius = blurRadius * scale;
|
|
687
|
-
#if SD_UIKIT || SD_MAC
|
|
688
|
-
if (self.CIImage) {
|
|
689
|
-
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
|
|
690
|
-
[filter setValue:self.CIImage forKey:kCIInputImageKey];
|
|
691
|
-
[filter setValue:@(inputRadius) forKey:kCIInputRadiusKey];
|
|
692
|
-
CIImage *ciImage = filter.outputImage;
|
|
693
|
-
ciImage = [ciImage imageByCroppingToRect:CGRectMake(0, 0, self.size.width, self.size.height)];
|
|
694
|
-
#if SD_UIKIT
|
|
695
|
-
UIImage *image = [UIImage imageWithCIImage:ciImage scale:self.scale orientation:self.imageOrientation];
|
|
696
|
-
#else
|
|
697
|
-
UIImage *image = [[UIImage alloc] initWithCIImage:ciImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
698
|
-
#endif
|
|
699
|
-
return image;
|
|
700
|
-
}
|
|
701
|
-
#endif
|
|
702
|
-
|
|
703
|
-
CGImageRef imageRef = self.CGImage;
|
|
704
|
-
|
|
705
|
-
//convert to BGRA if it isn't
|
|
706
|
-
if (CGImageGetBitsPerPixel(imageRef) != 32 ||
|
|
707
|
-
CGImageGetBitsPerComponent(imageRef) != 8 ||
|
|
708
|
-
!((CGImageGetBitmapInfo(imageRef) & kCGBitmapAlphaInfoMask))) {
|
|
709
|
-
SDGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
|
|
710
|
-
[self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)];
|
|
711
|
-
imageRef = SDGraphicsGetImageFromCurrentImageContext().CGImage;
|
|
712
|
-
SDGraphicsEndImageContext();
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
vImage_Buffer effect = {}, scratch = {};
|
|
716
|
-
vImage_Buffer *input = NULL, *output = NULL;
|
|
717
|
-
|
|
718
|
-
vImage_CGImageFormat format = {
|
|
719
|
-
.bitsPerComponent = 8,
|
|
720
|
-
.bitsPerPixel = 32,
|
|
721
|
-
.colorSpace = NULL,
|
|
722
|
-
.bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, //requests a BGRA buffer.
|
|
723
|
-
.version = 0,
|
|
724
|
-
.decode = NULL,
|
|
725
|
-
.renderingIntent = CGImageGetRenderingIntent(imageRef)
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
vImage_Error err;
|
|
729
|
-
err = vImageBuffer_InitWithCGImage(&effect, &format, NULL, imageRef, kvImageNoFlags);
|
|
730
|
-
if (err != kvImageNoError) {
|
|
731
|
-
NSLog(@"UIImage+Transform error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", err, self);
|
|
732
|
-
return nil;
|
|
733
|
-
}
|
|
734
|
-
err = vImageBuffer_Init(&scratch, effect.height, effect.width, format.bitsPerPixel, kvImageNoFlags);
|
|
735
|
-
if (err != kvImageNoError) {
|
|
736
|
-
NSLog(@"UIImage+Transform error: vImageBuffer_Init returned error code %zi for inputImage: %@", err, self);
|
|
737
|
-
return nil;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
input = &effect;
|
|
741
|
-
output = &scratch;
|
|
742
|
-
|
|
743
|
-
if (hasBlur) {
|
|
744
|
-
// A description of how to compute the box kernel width from the Gaussian
|
|
745
|
-
// radius (aka standard deviation) appears in the SVG spec:
|
|
746
|
-
// http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
|
|
747
|
-
//
|
|
748
|
-
// For larger values of 's' (s >= 2.0), an approximation can be used: Three
|
|
749
|
-
// successive box-blurs build a piece-wise quadratic convolution kernel, which
|
|
750
|
-
// approximates the Gaussian kernel to within roughly 3%.
|
|
751
|
-
//
|
|
752
|
-
// let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
|
|
753
|
-
//
|
|
754
|
-
// ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
|
|
755
|
-
//
|
|
756
|
-
if (inputRadius - 2.0 < __FLT_EPSILON__) inputRadius = 2.0;
|
|
757
|
-
uint32_t radius = floor(inputRadius * 3.0 * sqrt(2 * M_PI) / 4 + 0.5);
|
|
758
|
-
radius |= 1; // force radius to be odd so that the three box-blur methodology works.
|
|
759
|
-
int iterations;
|
|
760
|
-
if (blurRadius * scale < 0.5) iterations = 1;
|
|
761
|
-
else if (blurRadius * scale < 1.5) iterations = 2;
|
|
762
|
-
else iterations = 3;
|
|
763
|
-
NSInteger tempSize = vImageBoxConvolve_ARGB8888(input, output, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize | kvImageEdgeExtend);
|
|
764
|
-
void *temp = malloc(tempSize);
|
|
765
|
-
for (int i = 0; i < iterations; i++) {
|
|
766
|
-
vImageBoxConvolve_ARGB8888(input, output, temp, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
|
|
767
|
-
vImage_Buffer *tmp = input;
|
|
768
|
-
input = output;
|
|
769
|
-
output = tmp;
|
|
770
|
-
}
|
|
771
|
-
free(temp);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
CGImageRef effectCGImage = NULL;
|
|
775
|
-
effectCGImage = vImageCreateCGImageFromBuffer(input, &format, NULL, NULL, kvImageNoAllocate, NULL);
|
|
776
|
-
if (effectCGImage == NULL) {
|
|
777
|
-
effectCGImage = vImageCreateCGImageFromBuffer(input, &format, NULL, NULL, kvImageNoFlags, NULL);
|
|
778
|
-
free(input->data);
|
|
779
|
-
}
|
|
780
|
-
free(output->data);
|
|
781
|
-
#if SD_UIKIT || SD_WATCH
|
|
782
|
-
UIImage *outputImage = [UIImage imageWithCGImage:effectCGImage scale:self.scale orientation:self.imageOrientation];
|
|
783
|
-
#else
|
|
784
|
-
UIImage *outputImage = [[UIImage alloc] initWithCGImage:effectCGImage scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
785
|
-
#endif
|
|
786
|
-
CGImageRelease(effectCGImage);
|
|
787
|
-
|
|
788
|
-
return outputImage;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
#if SD_UIKIT || SD_MAC
|
|
792
|
-
- (nullable UIImage *)sd_filteredImageWithFilter:(nonnull CIFilter *)filter {
|
|
793
|
-
CIImage *inputImage;
|
|
794
|
-
if (self.CIImage) {
|
|
795
|
-
inputImage = self.CIImage;
|
|
796
|
-
} else {
|
|
797
|
-
CGImageRef imageRef = self.CGImage;
|
|
798
|
-
if (!imageRef) {
|
|
799
|
-
return nil;
|
|
800
|
-
}
|
|
801
|
-
inputImage = [CIImage imageWithCGImage:imageRef];
|
|
802
|
-
}
|
|
803
|
-
if (!inputImage) return nil;
|
|
804
|
-
|
|
805
|
-
CIContext *context = [CIContext context];
|
|
806
|
-
[filter setValue:inputImage forKey:kCIInputImageKey];
|
|
807
|
-
CIImage *outputImage = filter.outputImage;
|
|
808
|
-
if (!outputImage) return nil;
|
|
809
|
-
|
|
810
|
-
CGImageRef imageRef = [context createCGImage:outputImage fromRect:outputImage.extent];
|
|
811
|
-
if (!imageRef) return nil;
|
|
812
|
-
|
|
813
|
-
#if SD_UIKIT
|
|
814
|
-
UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation];
|
|
815
|
-
#else
|
|
816
|
-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:self.scale orientation:kCGImagePropertyOrientationUp];
|
|
817
|
-
#endif
|
|
818
|
-
CGImageRelease(imageRef);
|
|
819
|
-
|
|
820
|
-
return image;
|
|
821
|
-
}
|
|
822
|
-
#endif
|
|
823
|
-
|
|
824
|
-
@end
|