react-native-ensys-camera-x 1.0.7
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/CustomCamera.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +833 -0
- package/android/build.gradle +135 -0
- package/android/consumer-rules.pro +47 -0
- package/android/src/main/AndroidManifest.xml +72 -0
- package/android/src/main/java/android/print/PdfPrint.java +51 -0
- package/android/src/main/java/com/customcamera/AnimatedImageViewManager.kt +199 -0
- package/android/src/main/java/com/customcamera/AudioPlayerView.kt +322 -0
- package/android/src/main/java/com/customcamera/AudioRecorder.kt +506 -0
- package/android/src/main/java/com/customcamera/BarcodeScannerActivity.kt +361 -0
- package/android/src/main/java/com/customcamera/BlurBackgroundView.kt +199 -0
- package/android/src/main/java/com/customcamera/CacheCleanupManager.kt +386 -0
- package/android/src/main/java/com/customcamera/CameraAspectRatioMode.kt +77 -0
- package/android/src/main/java/com/customcamera/CameraAsset.kt +211 -0
- package/android/src/main/java/com/customcamera/CameraTheme.kt +479 -0
- package/android/src/main/java/com/customcamera/CompressionCacheStore.kt +504 -0
- package/android/src/main/java/com/customcamera/CompressionFileNameUtils.kt +7 -0
- package/android/src/main/java/com/customcamera/CompressionProfile.kt +195 -0
- package/android/src/main/java/com/customcamera/CustomCameraActivity.kt +7291 -0
- package/android/src/main/java/com/customcamera/CustomCameraFileProvider.kt +9 -0
- package/android/src/main/java/com/customcamera/CustomCameraModule.kt +2479 -0
- package/android/src/main/java/com/customcamera/CustomCameraPackage.kt +53 -0
- package/android/src/main/java/com/customcamera/DisplayUtils.kt +9 -0
- package/android/src/main/java/com/customcamera/DocumentPreviewView.kt +846 -0
- package/android/src/main/java/com/customcamera/DrawingView.kt +214 -0
- package/android/src/main/java/com/customcamera/EmojiPickerData.kt +228 -0
- package/android/src/main/java/com/customcamera/FilterStripAdapter.kt +158 -0
- package/android/src/main/java/com/customcamera/GifSupport.kt +215 -0
- package/android/src/main/java/com/customcamera/GlobalAudioPlayer.kt +320 -0
- package/android/src/main/java/com/customcamera/ImageExporter.kt +1394 -0
- package/android/src/main/java/com/customcamera/ImageFormatSupport.kt +163 -0
- package/android/src/main/java/com/customcamera/Localization.kt +206 -0
- package/android/src/main/java/com/customcamera/MediaAdapters.kt +758 -0
- package/android/src/main/java/com/customcamera/MediaCacheManager.kt +782 -0
- package/android/src/main/java/com/customcamera/MediaExportFormats.kt +201 -0
- package/android/src/main/java/com/customcamera/MediaFileIo.kt +310 -0
- package/android/src/main/java/com/customcamera/MediaMetadataStore.kt +494 -0
- package/android/src/main/java/com/customcamera/MediaPreviewEditor.kt +14865 -0
- package/android/src/main/java/com/customcamera/MediaPublisher.kt +423 -0
- package/android/src/main/java/com/customcamera/MediaStorageWorkflow.kt +722 -0
- package/android/src/main/java/com/customcamera/MediaStoreRepository.kt +378 -0
- package/android/src/main/java/com/customcamera/MediaThumbnailView.kt +286 -0
- package/android/src/main/java/com/customcamera/MediaUtils.kt +37 -0
- package/android/src/main/java/com/customcamera/NativeVideoViewManager.kt +845 -0
- package/android/src/main/java/com/customcamera/OfficeDocumentConverter.kt +2791 -0
- package/android/src/main/java/com/customcamera/PendingCaptureCrops.kt +88 -0
- package/android/src/main/java/com/customcamera/PowerPointPreview.kt +4077 -0
- package/android/src/main/java/com/customcamera/RecentPickerStore.kt +74 -0
- package/android/src/main/java/com/customcamera/SecureFileEraser.kt +411 -0
- package/android/src/main/java/com/customcamera/SecureKeyModule.kt +88 -0
- package/android/src/main/java/com/customcamera/SecureMediaDeleter.kt +493 -0
- package/android/src/main/java/com/customcamera/StickerPickerData.kt +107 -0
- package/android/src/main/java/com/customcamera/SvgDrawable.kt +175 -0
- package/android/src/main/java/com/customcamera/SvgIconViewManager.kt +77 -0
- package/android/src/main/java/com/customcamera/TextEntryController.kt +553 -0
- package/android/src/main/java/com/customcamera/ThumbnailLoader.kt +455 -0
- package/android/src/main/java/com/customcamera/UploadService.kt +909 -0
- package/android/src/main/java/com/customcamera/VideoEditUtils.kt +210 -0
- package/android/src/main/java/com/customcamera/VideoRotationTranscoder.kt +1992 -0
- package/android/src/main/java/com/customcamera/gif/AnimatedGifEncoder.kt +473 -0
- package/android/src/main/java/com/customcamera/gif/GifDecoder.kt +690 -0
- package/android/src/main/java/com/customcamera/gif/GifFramesDrawable.kt +160 -0
- package/android/src/main/java/com/customcamera/gif/GifHttp.kt +112 -0
- package/android/src/main/java/com/customcamera/gif/GifImageLoader.kt +186 -0
- package/android/src/main/java/com/customcamera/gif/GifModels.kt +74 -0
- package/android/src/main/java/com/customcamera/gif/GifProvider.kt +49 -0
- package/android/src/main/java/com/customcamera/gif/GifProviders.kt +27 -0
- package/android/src/main/java/com/customcamera/gif/GifRepository.kt +124 -0
- package/android/src/main/java/com/customcamera/gif/GifSafety.kt +33 -0
- package/android/src/main/java/com/customcamera/gif/GiphyGifProvider.kt +146 -0
- package/android/src/main/java/com/customcamera/gif/LZWEncoder.kt +258 -0
- package/android/src/main/java/com/customcamera/gif/NeuQuant.kt +435 -0
- package/android/src/main/java/com/customcamera/gif/TenorGifProvider.kt +147 -0
- package/android/src/main/res/drawable/bg_brush_selected.xml +5 -0
- package/android/src/main/res/drawable/bg_color_swatch.xml +5 -0
- package/android/src/main/res/drawable/bg_editor_toolbar.xml +6 -0
- package/android/src/main/res/drawable/bg_icon_circle.xml +5 -0
- package/android/src/main/res/drawable/bg_icon_circle_light.xml +5 -0
- package/android/src/main/res/drawable/bg_mode_tab_active.xml +6 -0
- package/android/src/main/res/drawable/bg_pill.xml +6 -0
- package/android/src/main/res/drawable/bg_recording_dot.xml +6 -0
- package/android/src/main/res/drawable/bg_selection_badge.xml +8 -0
- package/android/src/main/res/drawable/bg_send_button.xml +5 -0
- package/android/src/main/res/drawable/bg_shutter_inner.xml +5 -0
- package/android/src/main/res/drawable/bg_shutter_recording.xml +6 -0
- package/android/src/main/res/drawable/bg_shutter_ring.xml +8 -0
- package/android/src/main/res/drawable/bg_shutter_video_idle.xml +5 -0
- package/android/src/main/res/drawable/bg_thumbnail.xml +9 -0
- package/android/src/main/res/drawable/ic_aspect_ratio.xml +17 -0
- package/android/src/main/res/drawable/ic_audio.xml +10 -0
- package/android/src/main/res/drawable/ic_back.xml +10 -0
- package/android/src/main/res/drawable/ic_brush_medium.xml +12 -0
- package/android/src/main/res/drawable/ic_brush_thick.xml +12 -0
- package/android/src/main/res/drawable/ic_brush_thin.xml +12 -0
- package/android/src/main/res/drawable/ic_check.xml +17 -0
- package/android/src/main/res/drawable/ic_chevron_down.xml +10 -0
- package/android/src/main/res/drawable/ic_chevron_up.xml +13 -0
- package/android/src/main/res/drawable/ic_clear_drawing.xml +10 -0
- package/android/src/main/res/drawable/ic_close.xml +10 -0
- package/android/src/main/res/drawable/ic_cover.xml +9 -0
- package/android/src/main/res/drawable/ic_crop.xml +10 -0
- package/android/src/main/res/drawable/ic_delete.xml +9 -0
- package/android/src/main/res/drawable/ic_document.xml +10 -0
- package/android/src/main/res/drawable/ic_done.xml +10 -0
- package/android/src/main/res/drawable/ic_download.xml +10 -0
- package/android/src/main/res/drawable/ic_emoji.xml +10 -0
- package/android/src/main/res/drawable/ic_filter.xml +10 -0
- package/android/src/main/res/drawable/ic_flash_auto.xml +7 -0
- package/android/src/main/res/drawable/ic_flash_off.xml +23 -0
- package/android/src/main/res/drawable/ic_flash_on.xml +16 -0
- package/android/src/main/res/drawable/ic_flip.xml +15 -0
- package/android/src/main/res/drawable/ic_gallery.xml +10 -0
- package/android/src/main/res/drawable/ic_gif.xml +24 -0
- package/android/src/main/res/drawable/ic_lock.xml +19 -0
- package/android/src/main/res/drawable/ic_lock_open.xml +22 -0
- package/android/src/main/res/drawable/ic_marker.xml +10 -0
- package/android/src/main/res/drawable/ic_more_vert.xml +18 -0
- package/android/src/main/res/drawable/ic_overlay_close.xml +19 -0
- package/android/src/main/res/drawable/ic_overlay_resize.xml +18 -0
- package/android/src/main/res/drawable/ic_pause.xml +10 -0
- package/android/src/main/res/drawable/ic_photo_mode.xml +10 -0
- package/android/src/main/res/drawable/ic_play.xml +10 -0
- package/android/src/main/res/drawable/ic_redo.xml +10 -0
- package/android/src/main/res/drawable/ic_rotate.xml +9 -0
- package/android/src/main/res/drawable/ic_send.xml +10 -0
- package/android/src/main/res/drawable/ic_share.xml +10 -0
- package/android/src/main/res/drawable/ic_stat_upload.xml +10 -0
- package/android/src/main/res/drawable/ic_sticker.xml +24 -0
- package/android/src/main/res/drawable/ic_text.xml +10 -0
- package/android/src/main/res/drawable/ic_text_align_center.xml +11 -0
- package/android/src/main/res/drawable/ic_text_align_left.xml +11 -0
- package/android/src/main/res/drawable/ic_text_align_right.xml +11 -0
- package/android/src/main/res/drawable/ic_text_bg.xml +11 -0
- package/android/src/main/res/drawable/ic_trim.xml +23 -0
- package/android/src/main/res/drawable/ic_undo.xml +10 -0
- package/android/src/main/res/drawable/ic_video_mode.xml +10 -0
- package/android/src/main/res/drawable/ic_video_note.xml +13 -0
- package/android/src/main/res/drawable/ic_volume_off.xml +9 -0
- package/android/src/main/res/drawable/ic_volume_on.xml +9 -0
- package/android/src/main/res/drawable/sticker_heart.xml +9 -0
- package/android/src/main/res/drawable/sticker_smile.xml +9 -0
- package/android/src/main/res/drawable/sticker_star.xml +9 -0
- package/android/src/main/res/drawable/sticker_thumbsup.xml +9 -0
- package/android/src/main/res/values/colors.xml +34 -0
- package/android/src/main/res/values/ids.xml +15 -0
- package/android/src/main/res/values/strings.xml +15 -0
- package/android/src/main/res/values/styles.xml +20 -0
- package/android/src/main/res/xml/file_paths.xml +34 -0
- package/ios/CustomCamera.h +5 -0
- package/ios/CustomCamera.mm +214 -0
- package/lib/module/AudioPlayerContext.js +233 -0
- package/lib/module/AudioPlayerContext.js.map +1 -0
- package/lib/module/CameraPreview.js +304 -0
- package/lib/module/CameraPreview.js.map +1 -0
- package/lib/module/NativeAnimatedImageView.js +41 -0
- package/lib/module/NativeAnimatedImageView.js.map +1 -0
- package/lib/module/NativeAudioPlayerView.js +33 -0
- package/lib/module/NativeAudioPlayerView.js.map +1 -0
- package/lib/module/NativeBlurView.js +35 -0
- package/lib/module/NativeBlurView.js.map +1 -0
- package/lib/module/NativeCustomCamera.js +128 -0
- package/lib/module/NativeCustomCamera.js.map +1 -0
- package/lib/module/NativeCustomCamera.web.js +143 -0
- package/lib/module/NativeCustomCamera.web.js.map +1 -0
- package/lib/module/NativeCustomVideoView.js +5 -0
- package/lib/module/NativeCustomVideoView.js.map +1 -0
- package/lib/module/NativeDocumentPreviewView.js +156 -0
- package/lib/module/NativeDocumentPreviewView.js.map +1 -0
- package/lib/module/NativeMediaThumbnailView.js +110 -0
- package/lib/module/NativeMediaThumbnailView.js.map +1 -0
- package/lib/module/NativeSvgIcon.js +32 -0
- package/lib/module/NativeSvgIcon.js.map +1 -0
- package/lib/module/ResponsivePreviewContainer.js +171 -0
- package/lib/module/ResponsivePreviewContainer.js.map +1 -0
- package/lib/module/accessibility.js +61 -0
- package/lib/module/accessibility.js.map +1 -0
- package/lib/module/config.js +352 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/cpuOptimization.js +296 -0
- package/lib/module/cpuOptimization.js.map +1 -0
- package/lib/module/db/DatabaseManager.js +191 -0
- package/lib/module/db/DatabaseManager.js.map +1 -0
- package/lib/module/db/MediaMapper.js +284 -0
- package/lib/module/db/MediaMapper.js.map +1 -0
- package/lib/module/db/MediaRepository.js +242 -0
- package/lib/module/db/MediaRepository.js.map +1 -0
- package/lib/module/db/index.js +41 -0
- package/lib/module/db/index.js.map +1 -0
- package/lib/module/db/migrations.js +180 -0
- package/lib/module/db/migrations.js.map +1 -0
- package/lib/module/db/react-native-sqlcipher.d.js +2 -0
- package/lib/module/db/react-native-sqlcipher.d.js.map +1 -0
- package/lib/module/db/secureKey.js +87 -0
- package/lib/module/db/secureKey.js.map +1 -0
- package/lib/module/db/types.js +57 -0
- package/lib/module/db/types.js.map +1 -0
- package/lib/module/db/useMediaDatabase.js +123 -0
- package/lib/module/db/useMediaDatabase.js.map +1 -0
- package/lib/module/defaultIcons.js +2259 -0
- package/lib/module/defaultIcons.js.map +1 -0
- package/lib/module/deviceCapabilities.js +408 -0
- package/lib/module/deviceCapabilities.js.map +1 -0
- package/lib/module/errors.js +267 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/iconConfig.js +796 -0
- package/lib/module/iconConfig.js.map +1 -0
- package/lib/module/icons.js +514 -0
- package/lib/module/icons.js.map +1 -0
- package/lib/module/index.js +251 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/jest-globals.d.js +2 -0
- package/lib/module/jest-globals.d.js.map +1 -0
- package/lib/module/library/MediaLibrary.js +107 -0
- package/lib/module/library/MediaLibrary.js.map +1 -0
- package/lib/module/library/MediaLibraryScreen.js +2597 -0
- package/lib/module/library/MediaLibraryScreen.js.map +1 -0
- package/lib/module/library/components/AudioPreview.js +74 -0
- package/lib/module/library/components/AudioPreview.js.map +1 -0
- package/lib/module/library/components/DocumentPreview.js +331 -0
- package/lib/module/library/components/DocumentPreview.js.map +1 -0
- package/lib/module/library/components/ExpandableFab.js +343 -0
- package/lib/module/library/components/ExpandableFab.js.map +1 -0
- package/lib/module/library/components/FileTiles.js +251 -0
- package/lib/module/library/components/FileTiles.js.map +1 -0
- package/lib/module/library/components/ImagePreview.js +70 -0
- package/lib/module/library/components/ImagePreview.js.map +1 -0
- package/lib/module/library/components/MediaMetadataHeader.js +175 -0
- package/lib/module/library/components/MediaMetadataHeader.js.map +1 -0
- package/lib/module/library/components/RecordAudioScreen.js +816 -0
- package/lib/module/library/components/RecordAudioScreen.js.map +1 -0
- package/lib/module/library/components/VideoPreview.js +453 -0
- package/lib/module/library/components/VideoPreview.js.map +1 -0
- package/lib/module/library/components/ViewerCounter.js +55 -0
- package/lib/module/library/components/ViewerCounter.js.map +1 -0
- package/lib/module/library/compressionEstimate.js +507 -0
- package/lib/module/library/compressionEstimate.js.map +1 -0
- package/lib/module/library/fileMetadata.js +196 -0
- package/lib/module/library/fileMetadata.js.map +1 -0
- package/lib/module/library/index.js +42 -0
- package/lib/module/library/index.js.map +1 -0
- package/lib/module/library/libraryIconRegistry.js +69 -0
- package/lib/module/library/libraryIconRegistry.js.map +1 -0
- package/lib/module/library/libraryIcons.js +858 -0
- package/lib/module/library/libraryIcons.js.map +1 -0
- package/lib/module/library/localizedFormat.js +181 -0
- package/lib/module/library/localizedFormat.js.map +1 -0
- package/lib/module/library/palette.js +225 -0
- package/lib/module/library/palette.js.map +1 -0
- package/lib/module/library/responsive.js +53 -0
- package/lib/module/library/responsive.js.map +1 -0
- package/lib/module/locales.js +416 -0
- package/lib/module/locales.js.map +1 -0
- package/lib/module/localization.js +1064 -0
- package/lib/module/localization.js.map +1 -0
- package/lib/module/logger.js +20 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/lowMemoryCache.js +206 -0
- package/lib/module/lowMemoryCache.js.map +1 -0
- package/lib/module/mediaHistory.js +33 -0
- package/lib/module/mediaHistory.js.map +1 -0
- package/lib/module/mediaStorageService.js +402 -0
- package/lib/module/mediaStorageService.js.map +1 -0
- package/lib/module/memory.js +79 -0
- package/lib/module/memory.js.map +1 -0
- package/lib/module/nativeActions.js +307 -0
- package/lib/module/nativeActions.js.map +1 -0
- package/lib/module/nativeComponentSupport.js +61 -0
- package/lib/module/nativeComponentSupport.js.map +1 -0
- package/lib/module/networkPerformance.js +24 -0
- package/lib/module/networkPerformance.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/performance.js +104 -0
- package/lib/module/performance.js.map +1 -0
- package/lib/module/performanceMonitor.js +155 -0
- package/lib/module/performanceMonitor.js.map +1 -0
- package/lib/module/permissions.js +370 -0
- package/lib/module/permissions.js.map +1 -0
- package/lib/module/rendering.js +40 -0
- package/lib/module/rendering.js.map +1 -0
- package/lib/module/security.js +18 -0
- package/lib/module/security.js.map +1 -0
- package/lib/module/state.js +266 -0
- package/lib/module/state.js.map +1 -0
- package/lib/module/storage.js +400 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/theme.js +390 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +115 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/validation.js +288 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AudioPlayerContext.d.ts +27 -0
- package/lib/typescript/src/AudioPlayerContext.d.ts.map +1 -0
- package/lib/typescript/src/CameraPreview.d.ts +13 -0
- package/lib/typescript/src/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/src/NativeAnimatedImageView.d.ts +33 -0
- package/lib/typescript/src/NativeAnimatedImageView.d.ts.map +1 -0
- package/lib/typescript/src/NativeAudioPlayerView.d.ts +12 -0
- package/lib/typescript/src/NativeAudioPlayerView.d.ts.map +1 -0
- package/lib/typescript/src/NativeBlurView.d.ts +12 -0
- package/lib/typescript/src/NativeBlurView.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomCamera.d.ts +167 -0
- package/lib/typescript/src/NativeCustomCamera.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomCamera.web.d.ts +47 -0
- package/lib/typescript/src/NativeCustomCamera.web.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomVideoView.d.ts +30 -0
- package/lib/typescript/src/NativeCustomVideoView.d.ts.map +1 -0
- package/lib/typescript/src/NativeDocumentPreviewView.d.ts +48 -0
- package/lib/typescript/src/NativeDocumentPreviewView.d.ts.map +1 -0
- package/lib/typescript/src/NativeMediaThumbnailView.d.ts +54 -0
- package/lib/typescript/src/NativeMediaThumbnailView.d.ts.map +1 -0
- package/lib/typescript/src/NativeSvgIcon.d.ts +25 -0
- package/lib/typescript/src/NativeSvgIcon.d.ts.map +1 -0
- package/lib/typescript/src/ResponsivePreviewContainer.d.ts +92 -0
- package/lib/typescript/src/ResponsivePreviewContainer.d.ts.map +1 -0
- package/lib/typescript/src/accessibility.d.ts +20 -0
- package/lib/typescript/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/config.d.ts +145 -0
- package/lib/typescript/src/config.d.ts.map +1 -0
- package/lib/typescript/src/cpuOptimization.d.ts +63 -0
- package/lib/typescript/src/cpuOptimization.d.ts.map +1 -0
- package/lib/typescript/src/db/DatabaseManager.d.ts +48 -0
- package/lib/typescript/src/db/DatabaseManager.d.ts.map +1 -0
- package/lib/typescript/src/db/MediaMapper.d.ts +77 -0
- package/lib/typescript/src/db/MediaMapper.d.ts.map +1 -0
- package/lib/typescript/src/db/MediaRepository.d.ts +66 -0
- package/lib/typescript/src/db/MediaRepository.d.ts.map +1 -0
- package/lib/typescript/src/db/index.d.ts +23 -0
- package/lib/typescript/src/db/index.d.ts.map +1 -0
- package/lib/typescript/src/db/migrations.d.ts +31 -0
- package/lib/typescript/src/db/migrations.d.ts.map +1 -0
- package/lib/typescript/src/db/secureKey.d.ts +10 -0
- package/lib/typescript/src/db/secureKey.d.ts.map +1 -0
- package/lib/typescript/src/db/types.d.ts +115 -0
- package/lib/typescript/src/db/types.d.ts.map +1 -0
- package/lib/typescript/src/db/useMediaDatabase.d.ts +41 -0
- package/lib/typescript/src/db/useMediaDatabase.d.ts.map +1 -0
- package/lib/typescript/src/defaultIcons.d.ts +139 -0
- package/lib/typescript/src/defaultIcons.d.ts.map +1 -0
- package/lib/typescript/src/deviceCapabilities.d.ts +92 -0
- package/lib/typescript/src/deviceCapabilities.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +95 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/iconConfig.d.ts +176 -0
- package/lib/typescript/src/iconConfig.d.ts.map +1 -0
- package/lib/typescript/src/icons.d.ts +217 -0
- package/lib/typescript/src/icons.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +104 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/library/MediaLibrary.d.ts +57 -0
- package/lib/typescript/src/library/MediaLibrary.d.ts.map +1 -0
- package/lib/typescript/src/library/MediaLibraryScreen.d.ts +51 -0
- package/lib/typescript/src/library/MediaLibraryScreen.d.ts.map +1 -0
- package/lib/typescript/src/library/components/AudioPreview.d.ts +6 -0
- package/lib/typescript/src/library/components/AudioPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/DocumentPreview.d.ts +10 -0
- package/lib/typescript/src/library/components/DocumentPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ExpandableFab.d.ts +39 -0
- package/lib/typescript/src/library/components/ExpandableFab.d.ts.map +1 -0
- package/lib/typescript/src/library/components/FileTiles.d.ts +8 -0
- package/lib/typescript/src/library/components/FileTiles.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ImagePreview.d.ts +5 -0
- package/lib/typescript/src/library/components/ImagePreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts +16 -0
- package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts.map +1 -0
- package/lib/typescript/src/library/components/RecordAudioScreen.d.ts +8 -0
- package/lib/typescript/src/library/components/RecordAudioScreen.d.ts.map +1 -0
- package/lib/typescript/src/library/components/VideoPreview.d.ts +20 -0
- package/lib/typescript/src/library/components/VideoPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ViewerCounter.d.ts +13 -0
- package/lib/typescript/src/library/components/ViewerCounter.d.ts.map +1 -0
- package/lib/typescript/src/library/compressionEstimate.d.ts +313 -0
- package/lib/typescript/src/library/compressionEstimate.d.ts.map +1 -0
- package/lib/typescript/src/library/fileMetadata.d.ts +33 -0
- package/lib/typescript/src/library/fileMetadata.d.ts.map +1 -0
- package/lib/typescript/src/library/index.d.ts +40 -0
- package/lib/typescript/src/library/index.d.ts.map +1 -0
- package/lib/typescript/src/library/libraryIconRegistry.d.ts +35 -0
- package/lib/typescript/src/library/libraryIconRegistry.d.ts.map +1 -0
- package/lib/typescript/src/library/libraryIcons.d.ts +85 -0
- package/lib/typescript/src/library/libraryIcons.d.ts.map +1 -0
- package/lib/typescript/src/library/localizedFormat.d.ts +49 -0
- package/lib/typescript/src/library/localizedFormat.d.ts.map +1 -0
- package/lib/typescript/src/library/palette.d.ts +104 -0
- package/lib/typescript/src/library/palette.d.ts.map +1 -0
- package/lib/typescript/src/library/responsive.d.ts +15 -0
- package/lib/typescript/src/library/responsive.d.ts.map +1 -0
- package/lib/typescript/src/locales.d.ts +103 -0
- package/lib/typescript/src/locales.d.ts.map +1 -0
- package/lib/typescript/src/localization.d.ts +1051 -0
- package/lib/typescript/src/localization.d.ts.map +1 -0
- package/lib/typescript/src/logger.d.ts +4 -0
- package/lib/typescript/src/logger.d.ts.map +1 -0
- package/lib/typescript/src/lowMemoryCache.d.ts +64 -0
- package/lib/typescript/src/lowMemoryCache.d.ts.map +1 -0
- package/lib/typescript/src/mediaHistory.d.ts +3 -0
- package/lib/typescript/src/mediaHistory.d.ts.map +1 -0
- package/lib/typescript/src/mediaStorageService.d.ts +155 -0
- package/lib/typescript/src/mediaStorageService.d.ts.map +1 -0
- package/lib/typescript/src/memory.d.ts +21 -0
- package/lib/typescript/src/memory.d.ts.map +1 -0
- package/lib/typescript/src/nativeActions.d.ts +174 -0
- package/lib/typescript/src/nativeActions.d.ts.map +1 -0
- package/lib/typescript/src/nativeComponentSupport.d.ts +30 -0
- package/lib/typescript/src/nativeComponentSupport.d.ts.map +1 -0
- package/lib/typescript/src/networkPerformance.d.ts +12 -0
- package/lib/typescript/src/networkPerformance.d.ts.map +1 -0
- package/lib/typescript/src/performance.d.ts +32 -0
- package/lib/typescript/src/performance.d.ts.map +1 -0
- package/lib/typescript/src/performanceMonitor.d.ts +45 -0
- package/lib/typescript/src/performanceMonitor.d.ts.map +1 -0
- package/lib/typescript/src/permissions.d.ts +132 -0
- package/lib/typescript/src/permissions.d.ts.map +1 -0
- package/lib/typescript/src/rendering.d.ts +9 -0
- package/lib/typescript/src/rendering.d.ts.map +1 -0
- package/lib/typescript/src/security.d.ts +6 -0
- package/lib/typescript/src/security.d.ts.map +1 -0
- package/lib/typescript/src/state.d.ts +102 -0
- package/lib/typescript/src/state.d.ts.map +1 -0
- package/lib/typescript/src/storage.d.ts +117 -0
- package/lib/typescript/src/storage.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +15 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +802 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +50 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/validation.d.ts +52 -0
- package/lib/typescript/src/validation.d.ts.map +1 -0
- package/package.json +204 -0
- package/react-native.config.js +17 -0
- package/src/AudioPlayerContext.tsx +220 -0
- package/src/CameraPreview.tsx +352 -0
- package/src/NativeAnimatedImageView.tsx +71 -0
- package/src/NativeAudioPlayerView.tsx +39 -0
- package/src/NativeBlurView.tsx +40 -0
- package/src/NativeCustomCamera.ts +305 -0
- package/src/NativeCustomCamera.web.ts +192 -0
- package/src/NativeCustomVideoView.ts +30 -0
- package/src/NativeDocumentPreviewView.tsx +196 -0
- package/src/NativeMediaThumbnailView.tsx +167 -0
- package/src/NativeSvgIcon.tsx +46 -0
- package/src/ResponsivePreviewContainer.tsx +227 -0
- package/src/accessibility.ts +80 -0
- package/src/config.ts +406 -0
- package/src/cpuOptimization.ts +365 -0
- package/src/db/DatabaseManager.ts +212 -0
- package/src/db/MediaMapper.ts +377 -0
- package/src/db/MediaRepository.ts +313 -0
- package/src/db/index.ts +73 -0
- package/src/db/migrations.ts +222 -0
- package/src/db/react-native-sqlcipher.d.ts +76 -0
- package/src/db/secureKey.ts +100 -0
- package/src/db/types.ts +123 -0
- package/src/db/useMediaDatabase.ts +191 -0
- package/src/defaultIcons.tsx +2390 -0
- package/src/deviceCapabilities.ts +438 -0
- package/src/errors.ts +350 -0
- package/src/iconConfig.tsx +962 -0
- package/src/icons.tsx +788 -0
- package/src/index.tsx +763 -0
- package/src/jest-globals.d.ts +9 -0
- package/src/library/MediaLibrary.tsx +141 -0
- package/src/library/MediaLibraryScreen.tsx +3003 -0
- package/src/library/components/AudioPreview.tsx +73 -0
- package/src/library/components/DocumentPreview.tsx +361 -0
- package/src/library/components/ExpandableFab.tsx +342 -0
- package/src/library/components/FileTiles.tsx +252 -0
- package/src/library/components/ImagePreview.tsx +72 -0
- package/src/library/components/MediaMetadataHeader.tsx +208 -0
- package/src/library/components/RecordAudioScreen.tsx +845 -0
- package/src/library/components/VideoPreview.tsx +478 -0
- package/src/library/components/ViewerCounter.tsx +71 -0
- package/src/library/compressionEstimate.ts +662 -0
- package/src/library/fileMetadata.ts +212 -0
- package/src/library/index.ts +66 -0
- package/src/library/libraryIconRegistry.tsx +86 -0
- package/src/library/libraryIcons.tsx +928 -0
- package/src/library/localizedFormat.ts +207 -0
- package/src/library/palette.ts +281 -0
- package/src/library/responsive.ts +49 -0
- package/src/locales.ts +381 -0
- package/src/localization.ts +1947 -0
- package/src/logger.ts +20 -0
- package/src/lowMemoryCache.ts +218 -0
- package/src/mediaHistory.ts +42 -0
- package/src/mediaStorageService.ts +546 -0
- package/src/memory.ts +102 -0
- package/src/nativeActions.ts +422 -0
- package/src/nativeComponentSupport.ts +60 -0
- package/src/networkPerformance.ts +30 -0
- package/src/performance.ts +137 -0
- package/src/performanceMonitor.ts +219 -0
- package/src/permissions.ts +403 -0
- package/src/rendering.ts +47 -0
- package/src/security.ts +19 -0
- package/src/state.ts +333 -0
- package/src/storage.ts +453 -0
- package/src/theme.tsx +467 -0
- package/src/types.ts +946 -0
- package/src/utils.ts +177 -0
- package/src/validation.ts +372 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
package com.customcamera.gif
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import android.graphics.Canvas
|
|
5
|
+
import java.io.BufferedOutputStream
|
|
6
|
+
import java.io.FileOutputStream
|
|
7
|
+
import java.io.IOException
|
|
8
|
+
import java.io.OutputStream
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Encodes one or more [Bitmap] frames into an animated GIF89a.
|
|
12
|
+
*
|
|
13
|
+
* Faithful Kotlin/Android port of Kevin Weiner's public-domain AnimatedGifEncoder (v1.03,
|
|
14
|
+
* November 2003), which uses [NeuQuant] for 256-colour quantization and [LZWEncoder] for the
|
|
15
|
+
* GIF-variant LZW pixel compression. It emits a GIF89a with a Netscape 2.0 looping application
|
|
16
|
+
* extension when the repeat count is >= 0, a per-frame 256-colour palette, optional transparency,
|
|
17
|
+
* and per-frame disposal codes.
|
|
18
|
+
*
|
|
19
|
+
* Typical use:
|
|
20
|
+
* ```
|
|
21
|
+
* val e = AnimatedGifEncoder()
|
|
22
|
+
* e.start(outputStream)
|
|
23
|
+
* e.setRepeat(0) // loop forever
|
|
24
|
+
* e.setDelay(100) // 100 ms between frames
|
|
25
|
+
* e.addFrame(bitmap1)
|
|
26
|
+
* e.addFrame(bitmap2)
|
|
27
|
+
* e.finish()
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* This is a syntax-only translation to idiomatic Kotlin; the emitted bytes are intended to be
|
|
31
|
+
* equivalent to the canonical Java implementation. The only Android-specific part is
|
|
32
|
+
* [getImagePixels], which reads pixels from a [Bitmap] instead of an AWT BufferedImage.
|
|
33
|
+
*/
|
|
34
|
+
class AnimatedGifEncoder {
|
|
35
|
+
|
|
36
|
+
private var width = 0 // image size
|
|
37
|
+
private var height = 0
|
|
38
|
+
private var transparent = -1 // transparent color if given
|
|
39
|
+
private var transIndex = 0 // transparent index in color table
|
|
40
|
+
private var repeat = -1 // -1 = no repeat, 0 = forever
|
|
41
|
+
private var delay = 0 // frame delay (hundredths)
|
|
42
|
+
private var started = false // ready to output frames
|
|
43
|
+
private var out: OutputStream? = null
|
|
44
|
+
private var image: Bitmap? = null // current frame
|
|
45
|
+
private var pixels: ByteArray? = null // BGR byte array from frame
|
|
46
|
+
private var indexedPixels: ByteArray? = null // converted frame indexed to palette
|
|
47
|
+
private var colorDepth = 0 // number of bit planes
|
|
48
|
+
private var colorTab: ByteArray? = null // RGB palette
|
|
49
|
+
private val usedEntry = BooleanArray(256) // active palette entries
|
|
50
|
+
private var palSize = 7 // color table size (bits - 1)
|
|
51
|
+
private var dispose = -1 // disposal code (-1 = use default)
|
|
52
|
+
private var closeStream = false // close stream when finished
|
|
53
|
+
private var firstFrame = true
|
|
54
|
+
private var sizeSet = false // if false, get size from first frame
|
|
55
|
+
private var sample = 10 // default sample interval for quantizer
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sets the delay between frames (applies to the last frame added and subsequent frames).
|
|
59
|
+
* @param ms delay in milliseconds
|
|
60
|
+
*/
|
|
61
|
+
fun setDelay(ms: Int) {
|
|
62
|
+
delay = Math.round(ms / 10.0f)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Sets the GIF frame disposal code for the last added frame and any subsequent frames.
|
|
67
|
+
*/
|
|
68
|
+
fun setDispose(code: Int) {
|
|
69
|
+
if (code >= 0) {
|
|
70
|
+
dispose = code
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Sets the number of times the frame set should be played. 0 means loop forever. Must be called
|
|
76
|
+
* before the first frame is added.
|
|
77
|
+
*/
|
|
78
|
+
fun setRepeat(iter: Int) {
|
|
79
|
+
if (iter >= 0) {
|
|
80
|
+
repeat = iter
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Sets the transparent colour (an RRGGBB value) for the last added frame and subsequent frames.
|
|
86
|
+
*/
|
|
87
|
+
fun setTransparent(c: Int) {
|
|
88
|
+
transparent = c
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Adds the next GIF frame. The frame is preprocessed immediately (quantized and indexed) and the
|
|
93
|
+
* corresponding GIF blocks are written. On the first frame the logical screen descriptor, global
|
|
94
|
+
* palette and (if looping) the Netscape extension are written first. Returns true on success.
|
|
95
|
+
*/
|
|
96
|
+
fun addFrame(im: Bitmap?): Boolean {
|
|
97
|
+
if (im == null || !started) {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
var ok = true
|
|
101
|
+
try {
|
|
102
|
+
if (!sizeSet) {
|
|
103
|
+
// use first frame's size
|
|
104
|
+
setSize(im.width, im.height)
|
|
105
|
+
}
|
|
106
|
+
image = im
|
|
107
|
+
getImagePixels() // convert to correct format if necessary
|
|
108
|
+
analyzePixels() // build color table & map pixels
|
|
109
|
+
if (firstFrame) {
|
|
110
|
+
writeLSD() // logical screen descriptor
|
|
111
|
+
writePalette() // global color table
|
|
112
|
+
if (repeat >= 0) {
|
|
113
|
+
// use NS app extension to indicate reps
|
|
114
|
+
writeNetscapeExt()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
writeGraphicCtrlExt() // write graphic control extension
|
|
118
|
+
writeImageDesc() // image descriptor
|
|
119
|
+
if (!firstFrame) {
|
|
120
|
+
writePalette() // local color table
|
|
121
|
+
}
|
|
122
|
+
writePixels() // encode and write pixel data
|
|
123
|
+
firstFrame = false
|
|
124
|
+
} catch (e: IOException) {
|
|
125
|
+
ok = false
|
|
126
|
+
}
|
|
127
|
+
return ok
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Flushes any pending data and writes the GIF trailer. Closes the stream only when it was opened
|
|
132
|
+
* by [start] with a file name. Resets internal state so the encoder can be reused. Returns false
|
|
133
|
+
* if the encoder was never started.
|
|
134
|
+
*/
|
|
135
|
+
fun finish(): Boolean {
|
|
136
|
+
if (!started) return false
|
|
137
|
+
var ok = true
|
|
138
|
+
started = false
|
|
139
|
+
try {
|
|
140
|
+
out!!.write(0x3b) // gif trailer
|
|
141
|
+
out!!.flush()
|
|
142
|
+
if (closeStream) {
|
|
143
|
+
out!!.close()
|
|
144
|
+
}
|
|
145
|
+
} catch (e: IOException) {
|
|
146
|
+
ok = false
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// reset for subsequent use
|
|
150
|
+
transIndex = 0
|
|
151
|
+
out = null
|
|
152
|
+
image = null
|
|
153
|
+
pixels = null
|
|
154
|
+
indexedPixels = null
|
|
155
|
+
colorTab = null
|
|
156
|
+
closeStream = false
|
|
157
|
+
firstFrame = true
|
|
158
|
+
|
|
159
|
+
return ok
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sets the frame rate in frames per second. Equivalent to a delay of 1000/fps milliseconds.
|
|
164
|
+
*/
|
|
165
|
+
fun setFrameRate(fps: Float) {
|
|
166
|
+
if (fps != 0f) {
|
|
167
|
+
delay = Math.round(100f / fps)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Sets the quantization quality (1 = best/slowest). Values below 1 are clamped to 1. Higher
|
|
173
|
+
* values sample fewer pixels, trading quality for speed. Takes effect on the next added frame.
|
|
174
|
+
*/
|
|
175
|
+
fun setQuality(quality: Int) {
|
|
176
|
+
var q = quality
|
|
177
|
+
if (q < 1) q = 1
|
|
178
|
+
sample = q
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Sets the fixed GIF frame size. Ignored once the first frame has been written; if never called,
|
|
183
|
+
* the size of the first frame is used.
|
|
184
|
+
*/
|
|
185
|
+
fun setSize(w: Int, h: Int) {
|
|
186
|
+
if (started && !firstFrame) return
|
|
187
|
+
width = w
|
|
188
|
+
height = h
|
|
189
|
+
if (width < 1) width = 320
|
|
190
|
+
if (height < 1) height = 240
|
|
191
|
+
sizeSet = true
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Initiates GIF creation on the given output stream. The caller retains ownership of the stream
|
|
196
|
+
* (it is not closed by [finish]). Returns true on success.
|
|
197
|
+
*/
|
|
198
|
+
fun start(os: OutputStream?): Boolean {
|
|
199
|
+
if (os == null) return false
|
|
200
|
+
var ok = true
|
|
201
|
+
closeStream = false
|
|
202
|
+
out = os
|
|
203
|
+
try {
|
|
204
|
+
writeString("GIF89a") // header
|
|
205
|
+
} catch (e: IOException) {
|
|
206
|
+
ok = false
|
|
207
|
+
}
|
|
208
|
+
started = ok
|
|
209
|
+
return started
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Initiates writing of a GIF file with the specified name. The stream is created and owned by the
|
|
214
|
+
* encoder and will be closed by [finish]. Returns true on success.
|
|
215
|
+
*/
|
|
216
|
+
fun start(file: String): Boolean {
|
|
217
|
+
var ok = true
|
|
218
|
+
try {
|
|
219
|
+
out = BufferedOutputStream(FileOutputStream(file))
|
|
220
|
+
ok = start(out)
|
|
221
|
+
closeStream = true
|
|
222
|
+
} catch (e: IOException) {
|
|
223
|
+
ok = false
|
|
224
|
+
}
|
|
225
|
+
started = ok
|
|
226
|
+
return started
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Analyzes the current frame's colours with [NeuQuant] and creates the palette plus the indexed
|
|
231
|
+
* pixel data. The NeuQuant palette is produced in BGR order and swapped to RGB here.
|
|
232
|
+
*/
|
|
233
|
+
private fun analyzePixels() {
|
|
234
|
+
val pix = pixels!!
|
|
235
|
+
val len = pix.size
|
|
236
|
+
val nPix = len / 3
|
|
237
|
+
val indexed = ByteArray(nPix)
|
|
238
|
+
val nq = NeuQuant(pix, len, sample)
|
|
239
|
+
// initialize quantizer, create reduced palette
|
|
240
|
+
val tab = nq.process()
|
|
241
|
+
// convert map from BGR to RGB
|
|
242
|
+
var i = 0
|
|
243
|
+
while (i < tab.size) {
|
|
244
|
+
val temp = tab[i]
|
|
245
|
+
tab[i] = tab[i + 2]
|
|
246
|
+
tab[i + 2] = temp
|
|
247
|
+
usedEntry[i / 3] = false
|
|
248
|
+
i += 3
|
|
249
|
+
}
|
|
250
|
+
// map image pixels to new palette
|
|
251
|
+
var k = 0
|
|
252
|
+
for (j in 0 until nPix) {
|
|
253
|
+
val index = nq.map(
|
|
254
|
+
pix[k++].toInt() and 0xff,
|
|
255
|
+
pix[k++].toInt() and 0xff,
|
|
256
|
+
pix[k++].toInt() and 0xff
|
|
257
|
+
)
|
|
258
|
+
usedEntry[index] = true
|
|
259
|
+
indexed[j] = index.toByte()
|
|
260
|
+
}
|
|
261
|
+
colorTab = tab
|
|
262
|
+
indexedPixels = indexed
|
|
263
|
+
pixels = null
|
|
264
|
+
colorDepth = 8
|
|
265
|
+
palSize = 7
|
|
266
|
+
// get closest match to transparent color if specified
|
|
267
|
+
if (transparent != -1) {
|
|
268
|
+
transIndex = findClosest(transparent)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Returns the index of the palette colour closest to [c] (an RRGGBB value), considering only
|
|
274
|
+
* palette entries actually used by the current frame. Returns -1 if there is no palette yet.
|
|
275
|
+
*/
|
|
276
|
+
private fun findClosest(c: Int): Int {
|
|
277
|
+
val tab = colorTab ?: return -1
|
|
278
|
+
val r = (c shr 16) and 0xff
|
|
279
|
+
val g = (c shr 8) and 0xff
|
|
280
|
+
val b = (c shr 0) and 0xff
|
|
281
|
+
var minpos = 0
|
|
282
|
+
var dmin = 256 * 256 * 256
|
|
283
|
+
val len = tab.size
|
|
284
|
+
var i = 0
|
|
285
|
+
while (i < len) {
|
|
286
|
+
val dr = r - (tab[i++].toInt() and 0xff)
|
|
287
|
+
val dg = g - (tab[i++].toInt() and 0xff)
|
|
288
|
+
val db = b - (tab[i].toInt() and 0xff)
|
|
289
|
+
val d = dr * dr + dg * dg + db * db
|
|
290
|
+
val index = i / 3
|
|
291
|
+
if (usedEntry[index] && d < dmin) {
|
|
292
|
+
dmin = d
|
|
293
|
+
minpos = index
|
|
294
|
+
}
|
|
295
|
+
i++
|
|
296
|
+
}
|
|
297
|
+
return minpos
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Extracts the current frame's pixels into [pixels] in BGR order (blue first), matching the
|
|
302
|
+
* channel order [NeuQuant] expects. The bitmap is redrawn onto a correctly sized ARGB_8888
|
|
303
|
+
* canvas first when its dimensions differ from the target GIF size.
|
|
304
|
+
*/
|
|
305
|
+
private fun getImagePixels() {
|
|
306
|
+
val src = image!!
|
|
307
|
+
var bmp = src
|
|
308
|
+
val w = src.width
|
|
309
|
+
val h = src.height
|
|
310
|
+
if (w != width || h != height) {
|
|
311
|
+
// create a new image with the right size
|
|
312
|
+
val temp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
|
313
|
+
val canvas = Canvas(temp)
|
|
314
|
+
canvas.drawBitmap(src, 0f, 0f, null)
|
|
315
|
+
bmp = temp
|
|
316
|
+
image = temp
|
|
317
|
+
}
|
|
318
|
+
val count = width * height
|
|
319
|
+
val intPixels = IntArray(count)
|
|
320
|
+
bmp.getPixels(intPixels, 0, width, 0, 0, width, height)
|
|
321
|
+
val bgr = ByteArray(count * 3)
|
|
322
|
+
for (i in 0 until count) {
|
|
323
|
+
val pixel = intPixels[i]
|
|
324
|
+
bgr[i * 3 + 0] = (pixel and 0xff).toByte() // blue
|
|
325
|
+
bgr[i * 3 + 1] = ((pixel shr 8) and 0xff).toByte() // green
|
|
326
|
+
bgr[i * 3 + 2] = ((pixel shr 16) and 0xff).toByte() // red
|
|
327
|
+
}
|
|
328
|
+
pixels = bgr
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Writes the Graphic Control Extension: frame delay, disposal method and transparency flag.
|
|
333
|
+
*/
|
|
334
|
+
@Throws(IOException::class)
|
|
335
|
+
private fun writeGraphicCtrlExt() {
|
|
336
|
+
val o = out!!
|
|
337
|
+
o.write(0x21) // extension introducer
|
|
338
|
+
o.write(0xf9) // GCE label
|
|
339
|
+
o.write(4) // data block size
|
|
340
|
+
val transp: Int
|
|
341
|
+
var disp: Int
|
|
342
|
+
if (transparent == -1) {
|
|
343
|
+
transp = 0
|
|
344
|
+
disp = 0 // dispose = no action
|
|
345
|
+
} else {
|
|
346
|
+
transp = 1
|
|
347
|
+
disp = 2 // force clear if using transparent color
|
|
348
|
+
}
|
|
349
|
+
if (dispose >= 0) {
|
|
350
|
+
disp = dispose and 7 // user override
|
|
351
|
+
}
|
|
352
|
+
disp = disp shl 2
|
|
353
|
+
|
|
354
|
+
// packed fields
|
|
355
|
+
o.write(
|
|
356
|
+
0 or // 1:3 reserved
|
|
357
|
+
disp or // 4:6 disposal
|
|
358
|
+
0 or // 7 user input - 0 = none
|
|
359
|
+
transp // 8 transparency flag
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
writeShort(delay) // delay x 1/100 sec
|
|
363
|
+
o.write(transIndex) // transparent color index
|
|
364
|
+
o.write(0) // block terminator
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Writes the Image Descriptor. The first frame relies on the global colour table; later frames
|
|
369
|
+
* flag a local colour table.
|
|
370
|
+
*/
|
|
371
|
+
@Throws(IOException::class)
|
|
372
|
+
private fun writeImageDesc() {
|
|
373
|
+
val o = out!!
|
|
374
|
+
o.write(0x2c) // image separator
|
|
375
|
+
writeShort(0) // image position x,y = 0,0
|
|
376
|
+
writeShort(0)
|
|
377
|
+
writeShort(width) // image size
|
|
378
|
+
writeShort(height)
|
|
379
|
+
// packed fields
|
|
380
|
+
if (firstFrame) {
|
|
381
|
+
// no LCT - GCT is used for first (or only) frame
|
|
382
|
+
o.write(0)
|
|
383
|
+
} else {
|
|
384
|
+
// specify normal LCT
|
|
385
|
+
o.write(
|
|
386
|
+
0x80 or // 1 local color table 1=yes
|
|
387
|
+
0 or // 2 interlace - 0=no
|
|
388
|
+
0 or // 3 sorted - 0=no
|
|
389
|
+
0 or // 4-5 reserved
|
|
390
|
+
palSize // 6-8 size of color table
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Writes the Logical Screen Descriptor (canvas size and global colour table flags).
|
|
397
|
+
*/
|
|
398
|
+
@Throws(IOException::class)
|
|
399
|
+
private fun writeLSD() {
|
|
400
|
+
val o = out!!
|
|
401
|
+
// logical screen size
|
|
402
|
+
writeShort(width)
|
|
403
|
+
writeShort(height)
|
|
404
|
+
// packed fields
|
|
405
|
+
o.write(
|
|
406
|
+
0x80 or // 1 : global color table flag = 1 (gct used)
|
|
407
|
+
0x70 or // 2-4 : color resolution = 7
|
|
408
|
+
0x00 or // 5 : gct sort flag = 0
|
|
409
|
+
palSize // 6-8 : gct size
|
|
410
|
+
)
|
|
411
|
+
o.write(0) // background color index
|
|
412
|
+
o.write(0) // pixel aspect ratio - assume 1:1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Writes the Netscape 2.0 application extension that defines the loop/repeat count.
|
|
417
|
+
*/
|
|
418
|
+
@Throws(IOException::class)
|
|
419
|
+
private fun writeNetscapeExt() {
|
|
420
|
+
val o = out!!
|
|
421
|
+
o.write(0x21) // extension introducer
|
|
422
|
+
o.write(0xff) // app extension label
|
|
423
|
+
o.write(11) // block size
|
|
424
|
+
writeString("NETSCAPE" + "2.0") // app id + auth code
|
|
425
|
+
o.write(3) // sub-block size
|
|
426
|
+
o.write(1) // loop sub-block id
|
|
427
|
+
writeShort(repeat) // loop count (extra iterations, 0 = repeat forever)
|
|
428
|
+
o.write(0) // block terminator
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Writes the colour table, padded with zeros to a full 256 entries (768 bytes).
|
|
433
|
+
*/
|
|
434
|
+
@Throws(IOException::class)
|
|
435
|
+
private fun writePalette() {
|
|
436
|
+
val o = out!!
|
|
437
|
+
val tab = colorTab!!
|
|
438
|
+
o.write(tab, 0, tab.size)
|
|
439
|
+
val n = 3 * 256 - tab.size
|
|
440
|
+
for (i in 0 until n) {
|
|
441
|
+
o.write(0)
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Encodes and writes the indexed pixel data via [LZWEncoder].
|
|
447
|
+
*/
|
|
448
|
+
@Throws(IOException::class)
|
|
449
|
+
private fun writePixels() {
|
|
450
|
+
val encoder = LZWEncoder(width, height, indexedPixels!!, colorDepth)
|
|
451
|
+
encoder.encode(out!!)
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Writes a 16-bit value to the output stream, least-significant byte first.
|
|
455
|
+
*/
|
|
456
|
+
@Throws(IOException::class)
|
|
457
|
+
private fun writeShort(value: Int) {
|
|
458
|
+
val o = out!!
|
|
459
|
+
o.write(value and 0xff)
|
|
460
|
+
o.write((value shr 8) and 0xff)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Writes each character of [s] to the output stream as a single (low) byte.
|
|
465
|
+
*/
|
|
466
|
+
@Throws(IOException::class)
|
|
467
|
+
private fun writeString(s: String) {
|
|
468
|
+
val o = out!!
|
|
469
|
+
for (i in 0 until s.length) {
|
|
470
|
+
o.write(s[i].code)
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|