Thanks to visit codestin.com
Credit goes to gitcode.com

circle-image-view-cj:基于 Cangjie 的图片处理库项目

自定义圆形imageview,主要实现圆形图片展示

分支4Tags2

circleImageView4cj

简介

circleImageView4cj 是一款图像处理库,能够将图片裁剪为圆形或为其添加边框效果。

功能亮点

  • 提供基于中心裁剪的图片缩放模式
  • 支持自定义圆形边框样式

项目结构

├─ AppScope
├─ doc        # API文档和使用手册存放目录                   
├─ entry      # 示例代码文件夹                  
├─ circleimageview    # circleimageview 库文件夹                   
│  └─ src
│      └─ main
│          ├─ cangjie
│          │  └─ src                                     
│          │      └─ circle_image_view.cj      # 自定义图片裁剪
│          └─ resources
├─ hvigor  # 构建工具目录
└─ README.md  # circleImageView4cj 介绍及使用说明   

Interface Description

For details on main classes and function interfaces, refer to API.

Usage Instructions

  1. Import via Module

    1. Clone or download the project.
    2. Copy the circleImageView4cj module to your application project directory.
    3. Modify the oh-package.json5 file in your application's entry directory by adding the following under the dependencies field:
    {  
       "name": "entry",  
       "version": "1.0.0",  
       "description": "Please describe the basic information.",  
       "main": "",  
       "author": "",  
       "license": "",  
      "dependencies": {  
          "circleimageview": "file:../circleimageview"  
      }  
    }  
    
    1. In the cjpm.toml file located in your application's entry/src/main/cangjie directory, add the following under the [dependencies] section:
      [dependencies]  
          circleimageview = {path = "../circleimageview", version = "1.0.0"}  
      
    2. Import the circleimageview project in your code:
      import circleimageview.*  
      
  2. Import as a Third-Party Dependency

    1. Add circleImageView4cj as a git submodule in your target project:
    > cd $PROJECT_ROOT  
    > mkdir third-party  
    > cd third-party  
    > git submodule add "https://gitcode.com/Cangjie-TPC/circleImageView4cj.git"  
    
    1. Modify the cjpm.toml file in your application's entry/src/main/cangjie directory to include the dependency:
    [dependencies]  
        circleimageview = {path = "../third-party/circleImageView4cj", version = "1.0.0"}  
    
    1. Use the circleimageview component in your project:
      import circleimageview.*  
      

Feature Examples

For examples, see entry.

import ohos.base.*
import ohos.component.*
import ohos.state_manage.*
import ohos.state_macro_manage.*
import circleimageview.*

@Entry
@Component
class EntryView {
    @State
    var data: CircleImageModel = CircleImageModel()

    protected override func aboutToAppear() {
        this.data = this.data.setImageURI(@r(app.media.hugh)).setDiameter(200.0).setBorderWidth(5.0).setBorderColor(
            Color.WHITE).setScaleType(ImageFit.Fill).setDisableCircularTransformation(false)
    }
    func build() {
        Column() {
            List(space: 0, initialIndex: 0) {
                ListItem() {
                    Column(5) {
                        CircleImageView(model: data)
                    }.align(Alignment.Center).width(200).height(200)
                }.height(50.percent).width(100.percent)

                ListItem() {
                    Column(5) {
                        CircleImageView(model: data)
                    }.align(Alignment.Center)
                }.height(50.percent).backgroundColor(0x000000).width(100.percent)
            }.width(100.percent).margin(top: 5)
        }
    }
}

Constraints and Limitations

Verified on the following versions:

DevEco Studio 5.1.0.828SP1
Cangjie Support Plugin 5.1.0.828

Open Source License

This project is licensed under the Apache License 2.0. Feel free to enjoy and contribute to open source.

How to Contribute

We welcome your Pull Requests, Issue submissions, and any form of contribution.

项目介绍

自定义圆形imageview,主要实现圆形图片展示

定制我的领域