@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,807 +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 "SDImageIOAnimatedCoder.h"
|
|
10
|
-
#import "NSImage+Compatibility.h"
|
|
11
|
-
#import "UIImage+Metadata.h"
|
|
12
|
-
#import "NSData+ImageContentType.h"
|
|
13
|
-
#import "SDImageCoderHelper.h"
|
|
14
|
-
#import "SDAnimatedImageRep.h"
|
|
15
|
-
#import "UIImage+ForceDecode.h"
|
|
16
|
-
#import "SDInternalMacros.h"
|
|
17
|
-
|
|
18
|
-
#import <ImageIO/ImageIO.h>
|
|
19
|
-
#import <CoreServices/CoreServices.h>
|
|
20
|
-
|
|
21
|
-
#if SD_CHECK_CGIMAGE_RETAIN_SOURCE
|
|
22
|
-
#import <dlfcn.h>
|
|
23
|
-
|
|
24
|
-
// SPI to check thread safe during Example and Test
|
|
25
|
-
static CGImageSourceRef (*SDCGImageGetImageSource)(CGImageRef);
|
|
26
|
-
#endif
|
|
27
|
-
|
|
28
|
-
// Specify File Size for lossy format encoding, like JPEG
|
|
29
|
-
static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestinationRequestedFileSize";
|
|
30
|
-
|
|
31
|
-
// This strip the un-wanted CGImageProperty, like the internal CGImageSourceRef in iOS 15+
|
|
32
|
-
// However, CGImageCreateCopy still keep those CGImageProperty, not suit for our use case
|
|
33
|
-
static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) {
|
|
34
|
-
if (!image) return nil;
|
|
35
|
-
size_t width = CGImageGetWidth(image);
|
|
36
|
-
size_t height = CGImageGetHeight(image);
|
|
37
|
-
size_t bitsPerComponent = CGImageGetBitsPerComponent(image);
|
|
38
|
-
size_t bitsPerPixel = CGImageGetBitsPerPixel(image);
|
|
39
|
-
size_t bytesPerRow = CGImageGetBytesPerRow(image);
|
|
40
|
-
CGColorSpaceRef space = CGImageGetColorSpace(image);
|
|
41
|
-
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(image);
|
|
42
|
-
CGDataProviderRef provider = CGImageGetDataProvider(image);
|
|
43
|
-
const CGFloat *decode = CGImageGetDecode(image);
|
|
44
|
-
bool shouldInterpolate = CGImageGetShouldInterpolate(image);
|
|
45
|
-
CGColorRenderingIntent intent = CGImageGetRenderingIntent(image);
|
|
46
|
-
CGImageRef newImage = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, space, bitmapInfo, provider, decode, shouldInterpolate, intent);
|
|
47
|
-
return newImage;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@interface SDImageIOCoderFrame : NSObject
|
|
51
|
-
|
|
52
|
-
@property (nonatomic, assign) NSUInteger index; // Frame index (zero based)
|
|
53
|
-
@property (nonatomic, assign) NSTimeInterval duration; // Frame duration in seconds
|
|
54
|
-
|
|
55
|
-
@end
|
|
56
|
-
|
|
57
|
-
@implementation SDImageIOCoderFrame
|
|
58
|
-
@end
|
|
59
|
-
|
|
60
|
-
@implementation SDImageIOAnimatedCoder {
|
|
61
|
-
size_t _width, _height;
|
|
62
|
-
CGImageSourceRef _imageSource;
|
|
63
|
-
BOOL _incremental;
|
|
64
|
-
SD_LOCK_DECLARE(_lock); // Lock only apply for incremental animation decoding
|
|
65
|
-
NSData *_imageData;
|
|
66
|
-
CGFloat _scale;
|
|
67
|
-
NSUInteger _loopCount;
|
|
68
|
-
NSUInteger _frameCount;
|
|
69
|
-
NSArray<SDImageIOCoderFrame *> *_frames;
|
|
70
|
-
BOOL _finished;
|
|
71
|
-
BOOL _preserveAspectRatio;
|
|
72
|
-
CGSize _thumbnailSize;
|
|
73
|
-
BOOL _lazyDecode;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- (void)dealloc
|
|
77
|
-
{
|
|
78
|
-
if (_imageSource) {
|
|
79
|
-
CFRelease(_imageSource);
|
|
80
|
-
_imageSource = NULL;
|
|
81
|
-
}
|
|
82
|
-
#if SD_UIKIT
|
|
83
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
|
84
|
-
#endif
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
- (void)didReceiveMemoryWarning:(NSNotification *)notification
|
|
88
|
-
{
|
|
89
|
-
if (_imageSource) {
|
|
90
|
-
for (size_t i = 0; i < _frameCount; i++) {
|
|
91
|
-
CGImageSourceRemoveCacheAtIndex(_imageSource, i);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
#pragma mark - Subclass Override
|
|
97
|
-
|
|
98
|
-
+ (SDImageFormat)imageFormat {
|
|
99
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
100
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
101
|
-
userInfo:nil];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
+ (NSString *)imageUTType {
|
|
105
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
106
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
107
|
-
userInfo:nil];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
+ (NSString *)dictionaryProperty {
|
|
111
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
112
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
113
|
-
userInfo:nil];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
+ (NSString *)unclampedDelayTimeProperty {
|
|
117
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
118
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
119
|
-
userInfo:nil];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
+ (NSString *)delayTimeProperty {
|
|
123
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
124
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
125
|
-
userInfo:nil];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
+ (NSString *)loopCountProperty {
|
|
129
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
130
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
131
|
-
userInfo:nil];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
+ (NSUInteger)defaultLoopCount {
|
|
135
|
-
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
|
136
|
-
reason:[NSString stringWithFormat:@"For `SDImageIOAnimatedCoder` subclass, you must override %@ method", NSStringFromSelector(_cmd)]
|
|
137
|
-
userInfo:nil];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
#pragma mark - Utils
|
|
141
|
-
|
|
142
|
-
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format {
|
|
143
|
-
static dispatch_once_t onceToken;
|
|
144
|
-
static NSSet *imageUTTypeSet;
|
|
145
|
-
dispatch_once(&onceToken, ^{
|
|
146
|
-
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers();
|
|
147
|
-
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
|
|
148
|
-
});
|
|
149
|
-
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
|
150
|
-
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
|
|
151
|
-
// Can decode from target format
|
|
152
|
-
return YES;
|
|
153
|
-
}
|
|
154
|
-
return NO;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
+ (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
|
158
|
-
static dispatch_once_t onceToken;
|
|
159
|
-
static NSSet *imageUTTypeSet;
|
|
160
|
-
dispatch_once(&onceToken, ^{
|
|
161
|
-
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageDestinationCopyTypeIdentifiers();
|
|
162
|
-
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
|
|
163
|
-
});
|
|
164
|
-
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
|
165
|
-
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
|
|
166
|
-
// Can encode to target format
|
|
167
|
-
return YES;
|
|
168
|
-
}
|
|
169
|
-
return NO;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
+ (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source {
|
|
173
|
-
NSUInteger loopCount = self.defaultLoopCount;
|
|
174
|
-
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, NULL);
|
|
175
|
-
NSDictionary *containerProperties = imageProperties[self.dictionaryProperty];
|
|
176
|
-
if (containerProperties) {
|
|
177
|
-
NSNumber *containerLoopCount = containerProperties[self.loopCountProperty];
|
|
178
|
-
if (containerLoopCount != nil) {
|
|
179
|
-
loopCount = containerLoopCount.unsignedIntegerValue;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return loopCount;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
+ (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
|
|
186
|
-
NSTimeInterval frameDuration = 0.1;
|
|
187
|
-
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, NULL);
|
|
188
|
-
if (!cfFrameProperties) {
|
|
189
|
-
return frameDuration;
|
|
190
|
-
}
|
|
191
|
-
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
|
|
192
|
-
NSDictionary *containerProperties = frameProperties[self.dictionaryProperty];
|
|
193
|
-
|
|
194
|
-
NSNumber *delayTimeUnclampedProp = containerProperties[self.unclampedDelayTimeProperty];
|
|
195
|
-
if (delayTimeUnclampedProp != nil) {
|
|
196
|
-
frameDuration = [delayTimeUnclampedProp doubleValue];
|
|
197
|
-
} else {
|
|
198
|
-
NSNumber *delayTimeProp = containerProperties[self.delayTimeProperty];
|
|
199
|
-
if (delayTimeProp != nil) {
|
|
200
|
-
frameDuration = [delayTimeProp doubleValue];
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
|
|
205
|
-
// We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
|
|
206
|
-
// a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org/b/36082>
|
|
207
|
-
// for more information.
|
|
208
|
-
|
|
209
|
-
if (frameDuration < 0.011) {
|
|
210
|
-
frameDuration = 0.1;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
CFRelease(cfFrameProperties);
|
|
214
|
-
return frameDuration;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
+ (UIImage *)createFrameAtIndex:(NSUInteger)index source:(CGImageSourceRef)source scale:(CGFloat)scale preserveAspectRatio:(BOOL)preserveAspectRatio thumbnailSize:(CGSize)thumbnailSize lazyDecode:(BOOL)lazyDecode animatedImage:(BOOL)animatedImage {
|
|
218
|
-
// `animatedImage` means called from `SDAnimatedImageProvider.animatedImageFrameAtIndex`
|
|
219
|
-
NSDictionary *options;
|
|
220
|
-
if (animatedImage) {
|
|
221
|
-
if (!lazyDecode) {
|
|
222
|
-
options = @{
|
|
223
|
-
// image decoding and caching should happen at image creation time.
|
|
224
|
-
(__bridge NSString *)kCGImageSourceShouldCacheImmediately : @(YES),
|
|
225
|
-
};
|
|
226
|
-
} else {
|
|
227
|
-
options = @{
|
|
228
|
-
// image decoding will happen at rendering time
|
|
229
|
-
(__bridge NSString *)kCGImageSourceShouldCacheImmediately : @(NO),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// Parse the image properties
|
|
234
|
-
NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, index, NULL);
|
|
235
|
-
CGFloat pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] doubleValue];
|
|
236
|
-
CGFloat pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] doubleValue];
|
|
237
|
-
CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)[properties[(__bridge NSString *)kCGImagePropertyOrientation] unsignedIntegerValue];
|
|
238
|
-
if (!exifOrientation) {
|
|
239
|
-
exifOrientation = kCGImagePropertyOrientationUp;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
NSMutableDictionary *decodingOptions;
|
|
243
|
-
if (options) {
|
|
244
|
-
decodingOptions = [NSMutableDictionary dictionaryWithDictionary:options];
|
|
245
|
-
} else {
|
|
246
|
-
decodingOptions = [NSMutableDictionary dictionary];
|
|
247
|
-
}
|
|
248
|
-
CGImageRef imageRef;
|
|
249
|
-
BOOL createFullImage = thumbnailSize.width == 0 || thumbnailSize.height == 0 || pixelWidth == 0 || pixelHeight == 0 || (pixelWidth <= thumbnailSize.width && pixelHeight <= thumbnailSize.height);
|
|
250
|
-
if (createFullImage) {
|
|
251
|
-
imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
|
|
252
|
-
} else {
|
|
253
|
-
decodingOptions[(__bridge NSString *)kCGImageSourceCreateThumbnailWithTransform] = @(preserveAspectRatio);
|
|
254
|
-
CGFloat maxPixelSize;
|
|
255
|
-
if (preserveAspectRatio) {
|
|
256
|
-
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
|
257
|
-
CGFloat thumbnailRatio = thumbnailSize.width / thumbnailSize.height;
|
|
258
|
-
if (pixelRatio > thumbnailRatio) {
|
|
259
|
-
maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.width / pixelRatio);
|
|
260
|
-
} else {
|
|
261
|
-
maxPixelSize = MAX(thumbnailSize.height, thumbnailSize.height * pixelRatio);
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.height);
|
|
265
|
-
}
|
|
266
|
-
decodingOptions[(__bridge NSString *)kCGImageSourceThumbnailMaxPixelSize] = @(maxPixelSize);
|
|
267
|
-
decodingOptions[(__bridge NSString *)kCGImageSourceCreateThumbnailFromImageAlways] = @(YES);
|
|
268
|
-
imageRef = CGImageSourceCreateThumbnailAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
|
|
269
|
-
}
|
|
270
|
-
if (!imageRef) {
|
|
271
|
-
return nil;
|
|
272
|
-
}
|
|
273
|
-
BOOL isDecoded = NO;
|
|
274
|
-
// Thumbnail image post-process
|
|
275
|
-
if (!createFullImage) {
|
|
276
|
-
if (preserveAspectRatio) {
|
|
277
|
-
// kCGImageSourceCreateThumbnailWithTransform will apply EXIF transform as well, we should not apply twice
|
|
278
|
-
exifOrientation = kCGImagePropertyOrientationUp;
|
|
279
|
-
} else {
|
|
280
|
-
// `CGImageSourceCreateThumbnailAtIndex` take only pixel dimension, if not `preserveAspectRatio`, we should manual scale to the target size
|
|
281
|
-
CGImageRef scaledImageRef = [SDImageCoderHelper CGImageCreateScaled:imageRef size:thumbnailSize];
|
|
282
|
-
if (scaledImageRef) {
|
|
283
|
-
CGImageRelease(imageRef);
|
|
284
|
-
imageRef = scaledImageRef;
|
|
285
|
-
isDecoded = YES;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
// Check whether output CGImage is decoded
|
|
290
|
-
if (!lazyDecode) {
|
|
291
|
-
if (!isDecoded) {
|
|
292
|
-
// Use CoreGraphics to trigger immediately decode
|
|
293
|
-
CGImageRef decodedImageRef = [SDImageCoderHelper CGImageCreateDecoded:imageRef];
|
|
294
|
-
if (decodedImageRef) {
|
|
295
|
-
CGImageRelease(imageRef);
|
|
296
|
-
imageRef = decodedImageRef;
|
|
297
|
-
isDecoded = YES;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
} else if (animatedImage) {
|
|
301
|
-
// iOS 15+, CGImageRef now retains CGImageSourceRef internally. To workaround its thread-safe issue, we have to strip CGImageSourceRef, using Force-Decode (or have to use SPI `CGImageSetImageSource`), See: https://github.com/SDWebImage/SDWebImage/issues/3273
|
|
302
|
-
if (@available(iOS 15, tvOS 15, *)) {
|
|
303
|
-
// User pass `lazyDecode == YES`, but we still have to strip the CGImageSourceRef
|
|
304
|
-
// CGImageRef newImageRef = CGImageCreateCopy(imageRef); // This one does not strip the CGImageProperty
|
|
305
|
-
CGImageRef newImageRef = SDCGImageCreateCopy(imageRef);
|
|
306
|
-
if (newImageRef) {
|
|
307
|
-
CGImageRelease(imageRef);
|
|
308
|
-
imageRef = newImageRef;
|
|
309
|
-
}
|
|
310
|
-
#if SD_CHECK_CGIMAGE_RETAIN_SOURCE
|
|
311
|
-
// Assert here to check CGImageRef should not retain the CGImageSourceRef and has possible thread-safe issue (this is behavior on iOS 15+)
|
|
312
|
-
// If assert hit, fire issue to https://github.com/SDWebImage/SDWebImage/issues and we update the condition for this behavior check
|
|
313
|
-
static dispatch_once_t onceToken;
|
|
314
|
-
dispatch_once(&onceToken, ^{
|
|
315
|
-
SDCGImageGetImageSource = dlsym(RTLD_DEFAULT, "CGImageGetImageSource");
|
|
316
|
-
});
|
|
317
|
-
if (SDCGImageGetImageSource) {
|
|
318
|
-
NSCAssert(!SDCGImageGetImageSource(imageRef), @"Animated Coder created CGImageRef should not retain CGImageSourceRef, which may cause thread-safe issue without lock");
|
|
319
|
-
}
|
|
320
|
-
#endif
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
#if SD_UIKIT || SD_WATCH
|
|
325
|
-
UIImageOrientation imageOrientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:exifOrientation];
|
|
326
|
-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:imageOrientation];
|
|
327
|
-
#else
|
|
328
|
-
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:exifOrientation];
|
|
329
|
-
#endif
|
|
330
|
-
CGImageRelease(imageRef);
|
|
331
|
-
image.sd_isDecoded = isDecoded;
|
|
332
|
-
|
|
333
|
-
return image;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
#pragma mark - Decode
|
|
337
|
-
- (BOOL)canDecodeFromData:(nullable NSData *)data {
|
|
338
|
-
return ([NSData sd_imageFormatForImageData:data] == self.class.imageFormat);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options {
|
|
342
|
-
if (!data) {
|
|
343
|
-
return nil;
|
|
344
|
-
}
|
|
345
|
-
CGFloat scale = 1;
|
|
346
|
-
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
|
347
|
-
if (scaleFactor != nil) {
|
|
348
|
-
scale = MAX([scaleFactor doubleValue], 1);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
CGSize thumbnailSize = CGSizeZero;
|
|
352
|
-
NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize];
|
|
353
|
-
if (thumbnailSizeValue != nil) {
|
|
354
|
-
#if SD_MAC
|
|
355
|
-
thumbnailSize = thumbnailSizeValue.sizeValue;
|
|
356
|
-
#else
|
|
357
|
-
thumbnailSize = thumbnailSizeValue.CGSizeValue;
|
|
358
|
-
#endif
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
BOOL preserveAspectRatio = YES;
|
|
362
|
-
NSNumber *preserveAspectRatioValue = options[SDImageCoderDecodePreserveAspectRatio];
|
|
363
|
-
if (preserveAspectRatioValue != nil) {
|
|
364
|
-
preserveAspectRatio = preserveAspectRatioValue.boolValue;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
BOOL lazyDecode = YES; // Defaults YES for static image coder
|
|
368
|
-
NSNumber *lazyDecodeValue = options[SDImageCoderDecodeUseLazyDecoding];
|
|
369
|
-
if (lazyDecodeValue != nil) {
|
|
370
|
-
lazyDecode = lazyDecodeValue.boolValue;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
#if SD_MAC
|
|
374
|
-
// If don't use thumbnail, prefers the built-in generation of frames (GIF/APNG)
|
|
375
|
-
// Which decode frames in time and reduce memory usage
|
|
376
|
-
if (thumbnailSize.width == 0 || thumbnailSize.height == 0) {
|
|
377
|
-
SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:data];
|
|
378
|
-
if (imageRep) {
|
|
379
|
-
NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale);
|
|
380
|
-
imageRep.size = size;
|
|
381
|
-
NSImage *animatedImage = [[NSImage alloc] initWithSize:size];
|
|
382
|
-
[animatedImage addRepresentation:imageRep];
|
|
383
|
-
animatedImage.sd_imageFormat = self.class.imageFormat;
|
|
384
|
-
return animatedImage;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
#endif
|
|
388
|
-
|
|
389
|
-
NSString *typeIdentifierHint = options[SDImageCoderDecodeTypeIdentifierHint];
|
|
390
|
-
if (!typeIdentifierHint) {
|
|
391
|
-
// Check file extension and convert to UTI, from: https://stackoverflow.com/questions/1506251/getting-an-uniform-type-identifier-for-a-given-extension
|
|
392
|
-
NSString *fileExtensionHint = options[SDImageCoderDecodeFileExtensionHint];
|
|
393
|
-
if (fileExtensionHint) {
|
|
394
|
-
typeIdentifierHint = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExtensionHint, kUTTypeImage);
|
|
395
|
-
// Ignore dynamic UTI
|
|
396
|
-
if (UTTypeIsDynamic((__bridge CFStringRef)typeIdentifierHint)) {
|
|
397
|
-
typeIdentifierHint = nil;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
} else if ([typeIdentifierHint isEqual:NSNull.null]) {
|
|
401
|
-
// Hack if user don't want to imply file extension
|
|
402
|
-
typeIdentifierHint = nil;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
NSDictionary *creatingOptions = nil;
|
|
406
|
-
if (typeIdentifierHint) {
|
|
407
|
-
creatingOptions = @{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : typeIdentifierHint};
|
|
408
|
-
}
|
|
409
|
-
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)creatingOptions);
|
|
410
|
-
if (!source) {
|
|
411
|
-
// Try again without UTType hint, the call site from user may provide the wrong UTType
|
|
412
|
-
source = CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)creatingOptions);
|
|
413
|
-
}
|
|
414
|
-
if (!source) {
|
|
415
|
-
return nil;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
size_t count = CGImageSourceGetCount(source);
|
|
419
|
-
UIImage *animatedImage;
|
|
420
|
-
|
|
421
|
-
BOOL decodeFirstFrame = [options[SDImageCoderDecodeFirstFrameOnly] boolValue];
|
|
422
|
-
if (decodeFirstFrame || count <= 1) {
|
|
423
|
-
animatedImage = [self.class createFrameAtIndex:0 source:source scale:scale preserveAspectRatio:preserveAspectRatio thumbnailSize:thumbnailSize lazyDecode:lazyDecode animatedImage:NO];
|
|
424
|
-
} else {
|
|
425
|
-
NSMutableArray<SDImageFrame *> *frames = [NSMutableArray arrayWithCapacity:count];
|
|
426
|
-
|
|
427
|
-
for (size_t i = 0; i < count; i++) {
|
|
428
|
-
UIImage *image = [self.class createFrameAtIndex:i source:source scale:scale preserveAspectRatio:preserveAspectRatio thumbnailSize:thumbnailSize lazyDecode:lazyDecode animatedImage:NO];
|
|
429
|
-
if (!image) {
|
|
430
|
-
continue;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
NSTimeInterval duration = [self.class frameDurationAtIndex:i source:source];
|
|
434
|
-
|
|
435
|
-
SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:duration];
|
|
436
|
-
[frames addObject:frame];
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
NSUInteger loopCount = [self.class imageLoopCountWithSource:source];
|
|
440
|
-
|
|
441
|
-
animatedImage = [SDImageCoderHelper animatedImageWithFrames:frames];
|
|
442
|
-
animatedImage.sd_imageLoopCount = loopCount;
|
|
443
|
-
}
|
|
444
|
-
animatedImage.sd_imageFormat = self.class.imageFormat;
|
|
445
|
-
CFRelease(source);
|
|
446
|
-
|
|
447
|
-
return animatedImage;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
#pragma mark - Progressive Decode
|
|
451
|
-
|
|
452
|
-
- (BOOL)canIncrementalDecodeFromData:(NSData *)data {
|
|
453
|
-
return ([NSData sd_imageFormatForImageData:data] == self.class.imageFormat);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
- (instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options {
|
|
457
|
-
self = [super init];
|
|
458
|
-
if (self) {
|
|
459
|
-
NSString *imageUTType = self.class.imageUTType;
|
|
460
|
-
_imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : imageUTType});
|
|
461
|
-
_incremental = YES;
|
|
462
|
-
CGFloat scale = 1;
|
|
463
|
-
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
|
464
|
-
if (scaleFactor != nil) {
|
|
465
|
-
scale = MAX([scaleFactor doubleValue], 1);
|
|
466
|
-
}
|
|
467
|
-
_scale = scale;
|
|
468
|
-
CGSize thumbnailSize = CGSizeZero;
|
|
469
|
-
NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize];
|
|
470
|
-
if (thumbnailSizeValue != nil) {
|
|
471
|
-
#if SD_MAC
|
|
472
|
-
thumbnailSize = thumbnailSizeValue.sizeValue;
|
|
473
|
-
#else
|
|
474
|
-
thumbnailSize = thumbnailSizeValue.CGSizeValue;
|
|
475
|
-
#endif
|
|
476
|
-
}
|
|
477
|
-
_thumbnailSize = thumbnailSize;
|
|
478
|
-
BOOL preserveAspectRatio = YES;
|
|
479
|
-
NSNumber *preserveAspectRatioValue = options[SDImageCoderDecodePreserveAspectRatio];
|
|
480
|
-
if (preserveAspectRatioValue != nil) {
|
|
481
|
-
preserveAspectRatio = preserveAspectRatioValue.boolValue;
|
|
482
|
-
}
|
|
483
|
-
_preserveAspectRatio = preserveAspectRatio;
|
|
484
|
-
BOOL lazyDecode = NO; // Defaults NO for animated image coder
|
|
485
|
-
NSNumber *lazyDecodeValue = options[SDImageCoderDecodeUseLazyDecoding];
|
|
486
|
-
if (lazyDecodeValue != nil) {
|
|
487
|
-
lazyDecode = lazyDecodeValue.boolValue;
|
|
488
|
-
}
|
|
489
|
-
_lazyDecode = lazyDecode;
|
|
490
|
-
SD_LOCK_INIT(_lock);
|
|
491
|
-
#if SD_UIKIT
|
|
492
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
|
493
|
-
#endif
|
|
494
|
-
}
|
|
495
|
-
return self;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
- (void)updateIncrementalData:(NSData *)data finished:(BOOL)finished {
|
|
499
|
-
NSCParameterAssert(_incremental);
|
|
500
|
-
if (_finished) {
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
_imageData = data;
|
|
504
|
-
_finished = finished;
|
|
505
|
-
|
|
506
|
-
// The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/
|
|
507
|
-
// Thanks to the author @Nyx0uf
|
|
508
|
-
|
|
509
|
-
// Update the data source, we must pass ALL the data, not just the new bytes
|
|
510
|
-
CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)data, finished);
|
|
511
|
-
|
|
512
|
-
if (_width + _height == 0) {
|
|
513
|
-
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, NULL);
|
|
514
|
-
if (properties) {
|
|
515
|
-
CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
|
|
516
|
-
if (val) CFNumberGetValue(val, kCFNumberLongType, &_height);
|
|
517
|
-
val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
|
|
518
|
-
if (val) CFNumberGetValue(val, kCFNumberLongType, &_width);
|
|
519
|
-
CFRelease(properties);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
SD_LOCK(_lock);
|
|
524
|
-
// For animated image progressive decoding because the frame count and duration may be changed.
|
|
525
|
-
[self scanAndCheckFramesValidWithImageSource:_imageSource];
|
|
526
|
-
SD_UNLOCK(_lock);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
- (UIImage *)incrementalDecodedImageWithOptions:(SDImageCoderOptions *)options {
|
|
530
|
-
NSCParameterAssert(_incremental);
|
|
531
|
-
UIImage *image;
|
|
532
|
-
|
|
533
|
-
if (_width + _height > 0) {
|
|
534
|
-
// Create the image
|
|
535
|
-
CGFloat scale = _scale;
|
|
536
|
-
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
|
537
|
-
if (scaleFactor != nil) {
|
|
538
|
-
scale = MAX([scaleFactor doubleValue], 1);
|
|
539
|
-
}
|
|
540
|
-
image = [self.class createFrameAtIndex:0 source:_imageSource scale:scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize lazyDecode:_lazyDecode animatedImage:NO];
|
|
541
|
-
if (image) {
|
|
542
|
-
image.sd_imageFormat = self.class.imageFormat;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
return image;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
#pragma mark - Encode
|
|
550
|
-
- (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
|
551
|
-
return (format == self.class.imageFormat);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options {
|
|
555
|
-
if (!image) {
|
|
556
|
-
return nil;
|
|
557
|
-
}
|
|
558
|
-
CGImageRef imageRef = image.CGImage;
|
|
559
|
-
if (!imageRef) {
|
|
560
|
-
// Earily return, supports CGImage only
|
|
561
|
-
return nil;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (format != self.class.imageFormat) {
|
|
565
|
-
return nil;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
NSMutableData *imageData = [NSMutableData data];
|
|
569
|
-
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
|
570
|
-
NSArray<SDImageFrame *> *frames = [SDImageCoderHelper framesFromAnimatedImage:image];
|
|
571
|
-
|
|
572
|
-
// Create an image destination. Animated Image does not support EXIF image orientation TODO
|
|
573
|
-
// The `CGImageDestinationCreateWithData` will log a warning when count is 0, use 1 instead.
|
|
574
|
-
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count ?: 1, NULL);
|
|
575
|
-
if (!imageDestination) {
|
|
576
|
-
// Handle failure.
|
|
577
|
-
return nil;
|
|
578
|
-
}
|
|
579
|
-
NSMutableDictionary *properties = [NSMutableDictionary dictionary];
|
|
580
|
-
#if SD_UIKIT || SD_WATCH
|
|
581
|
-
CGImagePropertyOrientation exifOrientation = [SDImageCoderHelper exifOrientationFromImageOrientation:image.imageOrientation];
|
|
582
|
-
#else
|
|
583
|
-
CGImagePropertyOrientation exifOrientation = kCGImagePropertyOrientationUp;
|
|
584
|
-
#endif
|
|
585
|
-
properties[(__bridge NSString *)kCGImagePropertyOrientation] = @(exifOrientation);
|
|
586
|
-
// Encoding Options
|
|
587
|
-
double compressionQuality = 1;
|
|
588
|
-
if (options[SDImageCoderEncodeCompressionQuality]) {
|
|
589
|
-
compressionQuality = [options[SDImageCoderEncodeCompressionQuality] doubleValue];
|
|
590
|
-
}
|
|
591
|
-
properties[(__bridge NSString *)kCGImageDestinationLossyCompressionQuality] = @(compressionQuality);
|
|
592
|
-
CGColorRef backgroundColor = [options[SDImageCoderEncodeBackgroundColor] CGColor];
|
|
593
|
-
if (backgroundColor) {
|
|
594
|
-
properties[(__bridge NSString *)kCGImageDestinationBackgroundColor] = (__bridge id)(backgroundColor);
|
|
595
|
-
}
|
|
596
|
-
CGSize maxPixelSize = CGSizeZero;
|
|
597
|
-
NSValue *maxPixelSizeValue = options[SDImageCoderEncodeMaxPixelSize];
|
|
598
|
-
if (maxPixelSizeValue != nil) {
|
|
599
|
-
#if SD_MAC
|
|
600
|
-
maxPixelSize = maxPixelSizeValue.sizeValue;
|
|
601
|
-
#else
|
|
602
|
-
maxPixelSize = maxPixelSizeValue.CGSizeValue;
|
|
603
|
-
#endif
|
|
604
|
-
}
|
|
605
|
-
CGFloat pixelWidth = (CGFloat)CGImageGetWidth(imageRef);
|
|
606
|
-
CGFloat pixelHeight = (CGFloat)CGImageGetHeight(imageRef);
|
|
607
|
-
CGFloat finalPixelSize = 0;
|
|
608
|
-
BOOL encodeFullImage = maxPixelSize.width == 0 || maxPixelSize.height == 0 || pixelWidth == 0 || pixelHeight == 0 || (pixelWidth <= maxPixelSize.width && pixelHeight <= maxPixelSize.height);
|
|
609
|
-
if (!encodeFullImage) {
|
|
610
|
-
// Thumbnail Encoding
|
|
611
|
-
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
|
612
|
-
CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height;
|
|
613
|
-
if (pixelRatio > maxPixelSizeRatio) {
|
|
614
|
-
finalPixelSize = MAX(maxPixelSize.width, maxPixelSize.width / pixelRatio);
|
|
615
|
-
} else {
|
|
616
|
-
finalPixelSize = MAX(maxPixelSize.height, maxPixelSize.height * pixelRatio);
|
|
617
|
-
}
|
|
618
|
-
properties[(__bridge NSString *)kCGImageDestinationImageMaxPixelSize] = @(finalPixelSize);
|
|
619
|
-
}
|
|
620
|
-
NSUInteger maxFileSize = [options[SDImageCoderEncodeMaxFileSize] unsignedIntegerValue];
|
|
621
|
-
if (maxFileSize > 0) {
|
|
622
|
-
properties[kSDCGImageDestinationRequestedFileSize] = @(maxFileSize);
|
|
623
|
-
// Remove the quality if we have file size limit
|
|
624
|
-
properties[(__bridge NSString *)kCGImageDestinationLossyCompressionQuality] = nil;
|
|
625
|
-
}
|
|
626
|
-
BOOL embedThumbnail = NO;
|
|
627
|
-
if (options[SDImageCoderEncodeEmbedThumbnail]) {
|
|
628
|
-
embedThumbnail = [options[SDImageCoderEncodeEmbedThumbnail] boolValue];
|
|
629
|
-
}
|
|
630
|
-
properties[(__bridge NSString *)kCGImageDestinationEmbedThumbnail] = @(embedThumbnail);
|
|
631
|
-
|
|
632
|
-
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
|
633
|
-
if (encodeFirstFrame || frames.count == 0) {
|
|
634
|
-
// for static single images
|
|
635
|
-
CGImageDestinationAddImage(imageDestination, imageRef, (__bridge CFDictionaryRef)properties);
|
|
636
|
-
} else {
|
|
637
|
-
// for animated images
|
|
638
|
-
NSUInteger loopCount = image.sd_imageLoopCount;
|
|
639
|
-
NSDictionary *containerProperties = @{
|
|
640
|
-
self.class.dictionaryProperty: @{self.class.loopCountProperty : @(loopCount)}
|
|
641
|
-
};
|
|
642
|
-
// container level properties (applies for `CGImageDestinationSetProperties`, not individual frames)
|
|
643
|
-
CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)containerProperties);
|
|
644
|
-
|
|
645
|
-
for (size_t i = 0; i < frames.count; i++) {
|
|
646
|
-
SDImageFrame *frame = frames[i];
|
|
647
|
-
NSTimeInterval frameDuration = frame.duration;
|
|
648
|
-
CGImageRef frameImageRef = frame.image.CGImage;
|
|
649
|
-
properties[self.class.dictionaryProperty] = @{self.class.delayTimeProperty : @(frameDuration)};
|
|
650
|
-
CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)properties);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
// Finalize the destination.
|
|
654
|
-
if (CGImageDestinationFinalize(imageDestination) == NO) {
|
|
655
|
-
// Handle failure.
|
|
656
|
-
imageData = nil;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
CFRelease(imageDestination);
|
|
660
|
-
|
|
661
|
-
return [imageData copy];
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
#pragma mark - SDAnimatedImageCoder
|
|
665
|
-
- (nullable instancetype)initWithAnimatedImageData:(nullable NSData *)data options:(nullable SDImageCoderOptions *)options {
|
|
666
|
-
if (!data) {
|
|
667
|
-
return nil;
|
|
668
|
-
}
|
|
669
|
-
self = [super init];
|
|
670
|
-
if (self) {
|
|
671
|
-
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
|
|
672
|
-
if (!imageSource) {
|
|
673
|
-
return nil;
|
|
674
|
-
}
|
|
675
|
-
BOOL framesValid = [self scanAndCheckFramesValidWithImageSource:imageSource];
|
|
676
|
-
if (!framesValid) {
|
|
677
|
-
CFRelease(imageSource);
|
|
678
|
-
return nil;
|
|
679
|
-
}
|
|
680
|
-
CGFloat scale = 1;
|
|
681
|
-
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
|
682
|
-
if (scaleFactor != nil) {
|
|
683
|
-
scale = MAX([scaleFactor doubleValue], 1);
|
|
684
|
-
}
|
|
685
|
-
_scale = scale;
|
|
686
|
-
CGSize thumbnailSize = CGSizeZero;
|
|
687
|
-
NSValue *thumbnailSizeValue = options[SDImageCoderDecodeThumbnailPixelSize];
|
|
688
|
-
if (thumbnailSizeValue != nil) {
|
|
689
|
-
#if SD_MAC
|
|
690
|
-
thumbnailSize = thumbnailSizeValue.sizeValue;
|
|
691
|
-
#else
|
|
692
|
-
thumbnailSize = thumbnailSizeValue.CGSizeValue;
|
|
693
|
-
#endif
|
|
694
|
-
}
|
|
695
|
-
_thumbnailSize = thumbnailSize;
|
|
696
|
-
BOOL preserveAspectRatio = YES;
|
|
697
|
-
NSNumber *preserveAspectRatioValue = options[SDImageCoderDecodePreserveAspectRatio];
|
|
698
|
-
if (preserveAspectRatioValue != nil) {
|
|
699
|
-
preserveAspectRatio = preserveAspectRatioValue.boolValue;
|
|
700
|
-
}
|
|
701
|
-
_preserveAspectRatio = preserveAspectRatio;
|
|
702
|
-
BOOL lazyDecode = NO; // Defaults NO for animated image coder
|
|
703
|
-
NSNumber *lazyDecodeValue = options[SDImageCoderDecodeUseLazyDecoding];
|
|
704
|
-
if (lazyDecodeValue != nil) {
|
|
705
|
-
lazyDecode = lazyDecodeValue.boolValue;
|
|
706
|
-
}
|
|
707
|
-
_lazyDecode = lazyDecode;
|
|
708
|
-
_imageSource = imageSource;
|
|
709
|
-
_imageData = data;
|
|
710
|
-
#if SD_UIKIT
|
|
711
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
|
712
|
-
#endif
|
|
713
|
-
}
|
|
714
|
-
return self;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
- (BOOL)scanAndCheckFramesValidWithImageSource:(CGImageSourceRef)imageSource {
|
|
718
|
-
if (!imageSource) {
|
|
719
|
-
return NO;
|
|
720
|
-
}
|
|
721
|
-
NSUInteger frameCount = CGImageSourceGetCount(imageSource);
|
|
722
|
-
NSUInteger loopCount = [self.class imageLoopCountWithSource:imageSource];
|
|
723
|
-
_loopCount = loopCount;
|
|
724
|
-
|
|
725
|
-
NSMutableArray<SDImageIOCoderFrame *> *frames = [NSMutableArray arrayWithCapacity:frameCount];
|
|
726
|
-
for (size_t i = 0; i < frameCount; i++) {
|
|
727
|
-
SDImageIOCoderFrame *frame = [[SDImageIOCoderFrame alloc] init];
|
|
728
|
-
frame.index = i;
|
|
729
|
-
frame.duration = [self.class frameDurationAtIndex:i source:imageSource];
|
|
730
|
-
[frames addObject:frame];
|
|
731
|
-
}
|
|
732
|
-
if (frames.count != frameCount) {
|
|
733
|
-
// frames not match, do not override current value
|
|
734
|
-
return NO;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
_frameCount = frameCount;
|
|
738
|
-
_frames = [frames copy];
|
|
739
|
-
|
|
740
|
-
return YES;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
- (NSData *)animatedImageData {
|
|
744
|
-
return _imageData;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
- (NSUInteger)animatedImageLoopCount {
|
|
748
|
-
return _loopCount;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
- (NSUInteger)animatedImageFrameCount {
|
|
752
|
-
return _frameCount;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
- (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index {
|
|
756
|
-
NSTimeInterval duration;
|
|
757
|
-
// Incremental Animation decoding may update frames when new bytes available
|
|
758
|
-
// Which should use lock to ensure frame count and frames match, ensure atomic logic
|
|
759
|
-
if (_incremental) {
|
|
760
|
-
SD_LOCK(_lock);
|
|
761
|
-
if (index >= _frames.count) {
|
|
762
|
-
SD_UNLOCK(_lock);
|
|
763
|
-
return 0;
|
|
764
|
-
}
|
|
765
|
-
duration = _frames[index].duration;
|
|
766
|
-
SD_UNLOCK(_lock);
|
|
767
|
-
} else {
|
|
768
|
-
if (index >= _frames.count) {
|
|
769
|
-
return 0;
|
|
770
|
-
}
|
|
771
|
-
duration = _frames[index].duration;
|
|
772
|
-
}
|
|
773
|
-
return duration;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
- (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index {
|
|
777
|
-
UIImage *image;
|
|
778
|
-
// Incremental Animation decoding may update frames when new bytes available
|
|
779
|
-
// Which should use lock to ensure frame count and frames match, ensure atomic logic
|
|
780
|
-
if (_incremental) {
|
|
781
|
-
SD_LOCK(_lock);
|
|
782
|
-
if (index >= _frames.count) {
|
|
783
|
-
SD_UNLOCK(_lock);
|
|
784
|
-
return nil;
|
|
785
|
-
}
|
|
786
|
-
image = [self safeAnimatedImageFrameAtIndex:index];
|
|
787
|
-
SD_UNLOCK(_lock);
|
|
788
|
-
} else {
|
|
789
|
-
if (index >= _frames.count) {
|
|
790
|
-
return nil;
|
|
791
|
-
}
|
|
792
|
-
image = [self safeAnimatedImageFrameAtIndex:index];
|
|
793
|
-
}
|
|
794
|
-
return image;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
- (UIImage *)safeAnimatedImageFrameAtIndex:(NSUInteger)index {
|
|
798
|
-
UIImage *image = [self.class createFrameAtIndex:index source:_imageSource scale:_scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize lazyDecode:_lazyDecode animatedImage:YES];
|
|
799
|
-
if (!image) {
|
|
800
|
-
return nil;
|
|
801
|
-
}
|
|
802
|
-
image.sd_imageFormat = self.class.imageFormat;
|
|
803
|
-
return image;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
@end
|
|
807
|
-
|