Skip to content

Library for zoom images, supported Android View, Compose and Compose Multiplatform; supported scale, pan, locate, rotation, and super-large image subsampling. 用于缩放图像的库,支持 Android View、Compose 以及 Compose Multiplatform,支持缩放、平移、定位、旋转、超大图子采样。

License

panpf/zoomimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo_image ZoomImage

Platform Platform2 API License version_icon

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

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}: Download (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

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.

About

Library for zoom images, supported Android View, Compose and Compose Multiplatform; supported scale, pan, locate, rotation, and super-large image subsampling. 用于缩放图像的库,支持 Android View、Compose 以及 Compose Multiplatform,支持缩放、平移、定位、旋转、超大图子采样。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages