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.
example.mp4
Complete
. Support basic functions such as double-click zoom, gesture zoom, single-finger drag, and inertial swipeLocate
. Support for locate anywhere in the image and keeping it in the center of the screenRotate
. Supports 0°, 90°, 180°, 270°, 360° rotation of picturesSubsampling
. Support for subsampling of very large images to avoid OOM, tile support animation, and sharpness gradientsDynamic scale factor
. Automatically calculates the most appropriate double-click scaling factor based on image size and container sizeScaling damping
. When manually scaled beyond the maximum or minimum zoom factor, there is a damped rubber band effectOne-finger scale
. Double-tap and hold the screen and slide up or down to zoom the imageScroll bar
. Supports displaying horizontal and vertical scroll bars to clarify the current scroll positionRead 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 inExif
. Support reading Exif Orientation information and automatically rotating imagesImage Loader
. Provide support for image loaders such as sketch, coil, glide, picasso, etc., and can also customize support for more image loadersCompose Multiplatform
. Support for Compose Multiplatform, which can be used on Android, macOS, Windows, Linux and other platforms
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 | ✅ | ❌ | ✅ | ✅ |
Platform/Function | Zoom | Subsampling | Integrated Image Loader |
---|---|---|---|
Android | ✅ | ✅ | ✅ |
Desktop | ✅ | ✅ | ❌ |
iOS | 🚧 | 🚧 | 🚧 |
Web | 🚧 | 🚧 | 🚧 |
Published to mavenCentral
${LAST_VERSION}
: (Not included 'v')
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)
// Providing the basic ZoomImage component, additional work is required to support network images and subsampling
implementation("io.github.panpf.zoomimage:zoomimage-compose:${LAST_VERSION}")
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}")
ZoomImage's own obfuscation is already included in aar, but you may also need to add obfuscation configuration for other libraries that depend indirectly
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(),
)
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,
)
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")
- 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
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
Please review the CHANGELOG file
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
Apache 2.0. See the LICENSE file for details.