zoomimage
zoomimage copied to clipboard
ZoomImage is an gesture zoom viewing of images library specially designed for Compose Multiplatform and Android View. Supported scale, pan, locate, rotation, and super-large image subsampling.
ZoomImage
Translations: 简体中文
Library for zoom images, supported Android View, Compose and Compose Multiplatform; supported double-click zoom, One or two fingers gesture zoom, single-finger drag, inertial sliding, positioning, rotation, super-large image subsampling and other functions.
https://github.com/panpf/zoomimage/assets/3250512/f067bed9-24e4-4ab8-a839-0731e155f4ef
Features
-
Complete
. Support basic functions such as double-click zoom, gesture zoom, single-finger drag, and inertial swipe -
Locate
. Support for locate anywhere in the image and keeping it in the center of the screen -
Rotate
. Supports 0°, 90°, 180°, 270°, 360° rotation of pictures -
Subsampling
. Support for subsampling of very large images to avoid OOM, tile support animation, and sharpness gradients -
Dynamic scale factor
. Automatically calculates the most appropriate double-click scaling factor based on image size and container size -
Scaling damping
. When manually scaled beyond the maximum or minimum zoom factor, there is a damped rubber band effect -
One-finger scale
. Double-tap and hold the screen and slide up or down to zoom the image -
Scroll bar
. Supports displaying horizontal and vertical scroll bars to clarify the current scroll position -
Read Mode
. When a long image is displayed in reading mode, the initial state automatically fills the screen, and the user can immediately start reading the image content, eliminating the need for the user to double-click to zoom in -
Exif
. Support reading Exif Orientation information and automatically rotating images -
Image Loader
. Provide support for image loaders such as sketch, coil, glide, picasso, etc., and can also customize support for more image loaders -
Compose Multiplatform
. Support for Compose Multiplatform, which can be used on Android, macOS, Windows, Linux and other platforms
Comparison of similar libraries
Function/Library | ZoomImage | Telephoto | PhotoView | Subsampling ScaleImageView |
---|---|---|---|---|
Compose | ✅ | ✅ | ❌ | ❌ |
Compose Multiplatform | ✅ | ✅ | ❌ | ❌ |
View | ✅ | ❌ | ✅ | ✅ |
Rotate | ✅ | ❌ | ✅ | ❌ |
Locate | ✅ | ❌ | ❌ | ✅ |
Scroll Bar | ✅ | ❌ | ❌ | ❌ |
Read Mode | ✅ | ❌ | ❌ | ❌ |
Subsampling | ✅ | ✅ | ❌ | ✅ |
Subsampling animation | ✅ | ❌ | ❌ | ❌ |
One-finger scale | ✅ | ✅ | ✅ | ✅ |
Dynamic scale factor | ✅ | ❌ | ❌ | ❌ |
Image Loader | ✅ | ✅ | ❌ | ❌ |
Rich interfaces | ✅ | ❌ | ✅ | ✅ |
Multiplatform support
Platform/Function | Zoom | Subsampling | Integrated Image Loader |
---|---|---|---|
Android | ✅ | ✅ | ✅ |
Desktop | ✅ | ✅ | ❌ |
iOS | 🚧 | 🚧 | 🚧 |
Web | 🚧 | 🚧 | 🚧 |
Import
Published to mavenCentral
${LAST_VERSION}
: (Not included 'v')
compose android
Choose according to the image loader you use
// The SketchZoomAsyncImage component is provided with the Coil Image Loader, easy to use (recommended)
implementation("io.github.panpf.zoomimage:zoomimage-compose-sketch:${LAST_VERSION}")
// The CoilZoomAsyncImage component is provided with the Coil Image Loader, easy to use
implementation("io.github.panpf.zoomimage:zoomimage-compose-coil:${LAST_VERSION}")
// The GlideZoomAsyncImage component is provided with the Coil Image Loader, easy to use
implementation("io.github.panpf.zoomimage:zoomimage-compose-glide:${LAST_VERSION}")
Why is there no picasso version of the compose ZoomImage component? Picasso has officially stated that it will not provide compose Support (Reference)
compose multiplatform
// Providing the basic ZoomImage component, additional work is required to support network images and subsampling
implementation("io.github.panpf.zoomimage:zoomimage-compose:${LAST_VERSION}")
view
Choose according to the image loader you use
// The SketchZoomImageView component is provided with the Sketch Image Loader, easy to use (recommended)
implementation("io.github.panpf.zoomimage:zoomimage-view-sketch:${LAST_VERSION}")
// The SketchZoomImageView component is provided with the Coil Image Loader, easy to use
implementation("io.github.panpf.zoomimage:zoomimage-view-coil:${LAST_VERSION}")
// The SketchZoomImageView component is provided with the Glide Image Loader, easy to use
implementation("io.github.panpf.zoomimage:zoomimage-view-glide:${LAST_VERSION}")
// The SketchZoomImageView component is provided with the Picasso Image Loader, easy to use
implementation("io.github.panpf.zoomimage:zoomimage-view-picasso:${LAST_VERSION}")
// Providing the basic ZoomImageView component, additional work is required to support network images and subsampling
implementation("io.github.panpf.zoomimage:zoomimage-view:${LAST_VERSION}")
R8 / Proguard
ZoomImage's own obfuscation is already included in aar, but you may also need to add obfuscation configuration for other libraries that depend indirectly
Quickly Started
compose android
The following is SketchZoomAsyncImage
For example, see the documentation for other components and detailed
usage Get Started
SketchZoomAsyncImage(
imageUri = "http://sample.com/sample.jpg",
contentDescription = "view image",
modifier = Modifier.fillMaxSize(),
)
compose multiplatform
val state: ZoomState by rememberZoomState()
LaunchedEffect(Unit) {
state.subsampling.setImageSource(ImageSource.fromResource("huge_image.jpeg"))
}
ZoomImage(
painter = painterResource("huge_image_thumbnail.jpeg"),
contentDescription = "view image",
modifier = Modifier.fillMaxSize(),
state = state,
)
view
The following is SketchZoomImageView
For example, see the documentation for other components and detailed
usage Get Started
val sketchZoomImageView = SketchZoomImageView(context)
sketchZoomImageView.displayImage("http://sample.com/sample.jpg")
Document
- Get Started
- Scale: scale, double-click scale, duration setting
- Offset: Move to the specified position
- Locate: Locate anywhere in the image and keeping it in the center of the screen
- Rotate: Rotate the image
- Read Mode: Long images initially fill the screen for easy reading
- Click: Receive click events
- Subsampling: Subsampling the display of huge image to avoid OOM
- Scroll Bar: Displays horizontal and vertical scroll bars to clarify the current scroll position
- Log: Modify log level and output pipeline
- Compose Multiplatform: Use on desktop platform
Samples
You can find the sample code in the sample-android and sample-desktop module, or you can download the APK、MSI、DMG、DEB package experience from the release page
Changelog
Please review the CHANGELOG file
My Projects
The following are my other open source projects. If you are interested, you can learn about them:
- sketch:A powerful and comprehensive image loader on Android, based entirely on coroutines, with support for GIFs, video thumbnails, and Compose
- assembly-adapter:A library on Android that provides multi-type Item implementations for various adapters. Incidentally, it also provides the most powerful divider for RecyclerView.
- sticky-item-decoration:RecyclerView sticky item implementation
License
Apache 2.0. See the LICENSE file for details.