# subsampling-scale-image-view
**Repository Path**: HarmonyOS-tpc/subsampling-scale-image-view
## Basic Information
- **Project Name**: subsampling-scale-image-view
- **Description**: Display images from assets, resources, the file system or bitmaps
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 9
- **Forks**: 2
- **Created**: 2021-04-01
- **Last Updated**: 2025-06-06
## Categories & Tags
**Categories**: harmony
**Tags**: None
## README
#### Migration guides
## 如何导入:
```
dependencies{
implementation 'io.openharmony.tpc.thirdlib:subsampling-scale-image-view:1.0.4'
}
```
## demo:
## Features
#### Image display
* Display images from assets, resources, the file system or bitmaps
* Automatically rotate images from the file system (e.g. the camera or gallery) according to EXIF
* Manually rotate images in 90° increments
* Display a region of the source image
* Use a preview image while large images load
* Swap images at runtime
* Use a custom bitmap decoder
*With tiling enabled:*
* Display huge images, larger than can be loaded into memory
* Show high resolution detail on zooming in
#### Gesture detection
* One finger pan
* Two finger pinch to zoom
* Quick scale (one finger zoom)
* Pan while zooming
* Seamless switch between pan and zoom
* Fling momentum after panning
* Double tap to zoom in and out
* Options to disable pan and/or zoom gestures
#### Animation
* Public methods for animating the scale and center
* Customisable duration and easing
* Optional uninterruptible animations
## Quick start
**1)** Add the view to your layout XML.
```xml
```
**2)** Now, in your abilitySlice or ability, set the image res, http url or pixelmap.
```java
SubsamplingScaleImageView subsamplingScaleImageView = (SubsamplingScaleImageView)findComponentById(ResourceTable.Id_img);
subsamplingScaleImageView.setResPixelMap(ResourceTable.Media_card);
// ... or ...
subsamplingScaleImageView.setUrlPixelMap(url);
// ... or ...
subsamplingScaleImageView.setPixelMap(pixelMap);
```
# API:
**public void setMaxRatio(float scale)**
- description: set matx ratio
**public final void setZoomEnabled(boolean zoomEnabled)**
- description: set zoom enabled
**public final void setPanEnabled(boolean panEnabled)**
- description: set pan enabled
**public final void setQuickScaleEnabled(boolean quickScaleEnabled)**
- description: set quick scale enabled
**public void setResPixelMap(int res)**
- description: set pixelmap by res ID
**public void setUrlPixelMap(String url)**
- description: set pixelmap by network url
**public void setPixelMap(PixelMap pixelMap)**
- description: set pixelmap
**public void setFilePath(String path)**
- description: set pixelmap by path
**public final void setTileBackgroundColor(int color)**
- description: set background
**public void setMemoryOptimization(boolean memoryOptimization)**
- description: set memory optimazation
# AttrSet
|name|format|description|
|:---:|:---:|:---:|
| panEnabled | boolean | set pan enabled
| zoomEnabled | boolean | set zoom enabled
| quickScaleEnabled | boolean | set quick scale enabled
| maxRatio | float | set max ratio
| loadProgress | boolean | set load progress
| tileBackgroundColor | color | set background color
| memoryOptimization | boolean | set memory optimization