├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── demo.jpg │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── rv_bitmap_item.xml │ │ │ │ └── activity_main.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── zhuolong │ │ │ └── bitmaphelperproject │ │ │ ├── BitmapRvAdapter.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── zhuolong │ │ │ └── bitmaphelperproject │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── zhuolong │ │ └── bitmaphelperproject │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── bitmaphelper ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── zhuolong │ │ │ └── bitmaphelper │ │ │ ├── BitmapHelperFactory.java │ │ │ ├── util │ │ │ ├── ScreenUtils.java │ │ │ └── BitmapUtils.java │ │ │ ├── shape │ │ │ ├── path │ │ │ │ ├── BitmapPathShapeable.java │ │ │ │ ├── BitmapPathShapeHelper.java │ │ │ │ └── BitmapPathShape.java │ │ │ ├── circle │ │ │ │ ├── BitmapCircleShapeable.java │ │ │ │ ├── BitmapCircleShapeHelper.java │ │ │ │ └── BitmapCircleShape.java │ │ │ ├── square │ │ │ │ ├── BitmapSquareShapeable.java │ │ │ │ ├── BitmapSquareShapeHelper.java │ │ │ │ └── BitmapSquareShape.java │ │ │ ├── arc │ │ │ │ ├── BitmapArcShapeable.java │ │ │ │ ├── BitmapArcShapeHelper.java │ │ │ │ └── BitmapArcShape.java │ │ │ ├── oval │ │ │ │ ├── BitmapOvalShapeable.java │ │ │ │ ├── BitmapOvalShapeHelper.java │ │ │ │ └── BitmapOvalShape.java │ │ │ ├── rect │ │ │ │ ├── BitmapRectShapeable.java │ │ │ │ ├── BitmapRectShapeHelper.java │ │ │ │ └── BitmapRectShape.java │ │ │ ├── BitmapShapeOption.java │ │ │ └── roundRect │ │ │ │ ├── BitmapRoundRectShapeable.java │ │ │ │ ├── BitmapRoundRectShapeHelper.java │ │ │ │ └── BitmapRoundRectShape.java │ │ │ └── helper │ │ │ └── BitmapShapeHelper.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── zhuolong │ │ │ └── bitmaphelper │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── zhuolong │ │ └── bitmaphelper │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── caches │ └── build_file_checksums.ser ├── vcs.xml ├── runConfigurations.xml ├── gradle.xml ├── misc.xml └── codeStyles │ └── Project.xml ├── images ├── Screenshot_20181006-101504.jpg └── Screenshot_20181006-145916.jpg ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /bitmaphelper/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':bitmaphelper' 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/drawable/demo.jpg -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BitmapHelperProject 3 | 4 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BitmapHelper 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /images/Screenshot_20181006-101504.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/images/Screenshot_20181006-101504.jpg -------------------------------------------------------------------------------- /images/Screenshot_20181006-145916.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/images/Screenshot_20181006-145916.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MingYueChunQiu/BitmapHelper/HEAD/bitmaphelper/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 03 21:13:04 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/rv_bitmap_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /bitmaphelper/src/test/java/com/zhuolong/bitmaphelper/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/test/java/com/zhuolong/bitmaphelperproject/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelperproject; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /bitmaphelper/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/BitmapHelperFactory.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.zhuolong.bitmaphelper.helper.BitmapShapeHelper; 6 | 7 | /** 8 | *
 9 |  *     author : 明月春秋
10 |  *     e-mail : xiyujieit@163.com
11 |  *     time   : 2018/10/5
12 |  *     desc   : 图片辅助处理工厂类
13 |  *     version: 1.0
14 |  * 
15 | */ 16 | public class BitmapHelperFactory { 17 | 18 | @NonNull 19 | public static BitmapShapeHelper newBitmapShapeHelper() { 20 | return new BitmapShapeHelper(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /bitmaphelper/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /bitmaphelper/src/androidTest/java/com/zhuolong/bitmaphelper/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.zhuolong.bitmaphelper", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zhuolong/bitmaphelperproject/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelperproject; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.zhuolong.bitmaphelperproject", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/util/ScreenUtils.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.util; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.res.Resources; 6 | import android.util.TypedValue; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.view.inputmethod.InputMethodManager; 10 | import android.widget.TextView; 11 | 12 | /** 13 | *
14 |  *     author : xyj
15 |  *     e-mail : yujie.xi@ehailuo.com
16 |  *     time   : 2018/03/27
17 |  *     desc   : 屏幕相关的工具类
18 |  *     version: 1.0
19 |  * 
20 | */ 21 | 22 | public class ScreenUtils { 23 | 24 | /** 25 | * 将dp转换为px 26 | * 27 | * @param resources 28 | * @param dpVal dp值 29 | * @return 返回px值 30 | */ 31 | public static float getPxFromDp(Resources resources, float dpVal) { 32 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, resources.getDisplayMetrics()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bitmaphelper/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 16 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 35 | } 36 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.zhuolong.bitmaphelperproject" 7 | minSdkVersion 16 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:28.0.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation project(':bitmaphelper') 29 | implementation 'com.android.support:recyclerview-v7:28.0.0' 30 | } 31 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/path/BitmapPathShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.path; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Path; 5 | import android.graphics.Rect; 6 | 7 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 8 | 9 | /** 10 | *
11 |  *     author : 明月春秋
12 |  *     e-mail : xiyujieit@163.com
13 |  *     time   : 2018/10/4
14 |  *     desc   : 任意路径图片裁剪实现接口
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public interface BitmapPathShapeable { 19 | 20 | /** 21 | * 裁剪任意路径图片,以源图片中心点为裁剪图片中点 22 | * 23 | * @param srcBp 源图片 24 | * @param path 裁剪的任意路径 25 | * @param isOffset 是否让path偏移,保证在包裹path的显示矩形里 26 | * @param option 额外选项 27 | * @return 返回裁剪好的图片 28 | */ 29 | Bitmap clipPathShapeInCenter(Bitmap srcBp, Path path, boolean isOffset, BitmapShapeOption option); 30 | 31 | /** 32 | * 裁剪任意路径图片 33 | * 34 | * @param srcBp 源图片 35 | * @param path 裁剪的任意路径 36 | * @param rect 裁剪图形所在矩形 37 | * @param isOffset 是否让path偏移,保证在包裹path的显示矩形里 38 | * @param option 额外选项 39 | * @return 返回裁剪好的图片 40 | */ 41 | Bitmap clipPathShape(Bitmap srcBp, Path path, Rect rect, boolean isOffset, BitmapShapeOption option); 42 | } 43 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/circle/BitmapCircleShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.circle; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/3
13 |  *     desc   : 圆形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapCircleShapeable { 18 | 19 | /** 20 | * 裁剪圆形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param option 额外选项 24 | * @return 返回裁剪好的图片 25 | */ 26 | Bitmap clipCircleShapeInCenter(Bitmap srcBp, BitmapShapeOption option); 27 | 28 | /** 29 | * 按比例裁剪圆形图片,以源图片中心点为裁剪图片中点 30 | * 31 | * @param srcBp 源图片 32 | * @param scale 裁剪比例 33 | * @param option 额外选项 34 | * @return 返回按比例裁剪好的图片 35 | */ 36 | Bitmap clipCircleShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option); 37 | 38 | /** 39 | * 按比例裁剪圆形图片 40 | * 41 | * @param srcBp 源图片 42 | * @param rect 裁剪图形所在矩形 43 | * @param option 额外选项 44 | * @return 返回按比例裁剪好的图片 45 | */ 46 | Bitmap clipCircleShape(Bitmap srcBp, Rect rect, BitmapShapeOption option); 47 | } 48 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/square/BitmapSquareShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.square; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/3
13 |  *     desc   : 方形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapSquareShapeable { 18 | 19 | /** 20 | * 裁剪正方形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param option 额外选项 24 | * @return 返回裁剪好的图片 25 | */ 26 | Bitmap clipSquareShapeInCenter(Bitmap srcBp, BitmapShapeOption option); 27 | 28 | /** 29 | * 按比例裁剪正方形图片,以源图片中心点为裁剪图片中点 30 | * 31 | * @param srcBp 源图片 32 | * @param scale 裁剪比例 33 | * @param option 额外选项 34 | * @return 返回按比例裁剪好的图片 35 | */ 36 | Bitmap clipSquareShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option); 37 | 38 | /** 39 | * 按比例裁剪正方形图片 40 | * 41 | * @param srcBp 源图片 42 | * @param rect 裁剪图形所在矩形 43 | * @param option 额外选项 44 | * @return 返回裁剪好的图片 45 | */ 46 | Bitmap clipSquareShape(Bitmap srcBp, Rect rect, BitmapShapeOption option); 47 | } 48 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/arc/BitmapArcShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.arc; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/4
13 |  *     desc   : 弧形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapArcShapeable { 18 | 19 | /** 20 | * 裁剪弧形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param startAngle 起始角度 24 | * @param sweepAngle 跨越角度 25 | * @param option 额外选项 26 | * @return 返回裁剪好的图片 27 | */ 28 | Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, BitmapShapeOption option); 29 | 30 | /** 31 | * 按比例裁剪弧形图片,以源图片中心点为裁剪图片中点 32 | * 33 | * @param srcBp 源图片 34 | * @param startAngle 起始角度 35 | * @param sweepAngle 跨越角度 36 | * @param scale 裁剪比例 37 | * @param option 额外选项 38 | * @return 返回按比例裁剪好的图片 39 | */ 40 | Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, float scale, BitmapShapeOption option); 41 | 42 | /** 43 | * 裁剪弧形图片 44 | * 45 | * @param srcBp 源图片 46 | * @param startAngle 起始角度 47 | * @param sweepAngle 跨越角度 48 | * @param rect 裁剪图形所在矩形 49 | * @param option 额外选项 50 | * @return 返回裁剪好的图片 51 | */ 52 | Bitmap clipArcShape(Bitmap srcBp, float startAngle, float sweepAngle, Rect rect, BitmapShapeOption option); 53 | } 54 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/oval/BitmapOvalShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.oval; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/4
13 |  *     desc   : 椭圆形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapOvalShapeable { 18 | 19 | /** 20 | * 裁剪椭圆形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param option 额外选项 24 | * @return 返回裁剪好的图片 25 | */ 26 | Bitmap clipOvalShapeInCenter(Bitmap srcBp, BitmapShapeOption option); 27 | 28 | /** 29 | * 按比例裁剪椭圆形图片,以源图片中心点为裁剪图片中点 30 | * 31 | * @param srcBp 源图片 32 | * @param scale 裁剪比例 33 | * @param option 额外选项 34 | * @return 返回按比例裁剪好的图片 35 | */ 36 | Bitmap clipOvalShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option); 37 | 38 | /** 39 | * 按比例裁剪椭圆形图片 40 | * 41 | * @param srcBp 源图片 42 | * @param rect 裁剪矩形 43 | * @param option 额外选项 44 | * @return 返回按比例裁剪好的图片 45 | */ 46 | Bitmap clipOvalShape(Bitmap srcBp, Rect rect, BitmapShapeOption option); 47 | 48 | /** 49 | * 按比例裁剪椭圆形图片 50 | * 51 | * @param srcBp 源图片 52 | * @param left 裁剪矩形左边距离 53 | * @param top 裁剪矩形上边距离 54 | * @param right 裁剪矩形长度 55 | * @param bottom 裁剪矩形高度 56 | * @param option 额外选项 57 | * @return 返回按比例裁剪好的图片 58 | */ 59 | Bitmap clipOvalShape(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option); 60 | } 61 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/path/BitmapPathShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.path; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Path; 5 | import android.graphics.Rect; 6 | 7 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 8 | 9 | /** 10 | *
11 |  *     author : 明月春秋
12 |  *     e-mail : xiyujieit@163.com
13 |  *     time   : 2018/11/3
14 |  *     desc   : 供外界调用的抽象类
15 |  *              实现BitmapPathShapeable
16 |  *     version: 1.0
17 |  * 
18 | */ 19 | public class BitmapPathShapeHelper implements BitmapPathShapeable { 20 | 21 | private BitmapPathShapeable mShapeable; 22 | 23 | public BitmapPathShapeHelper() { 24 | this(new BitmapPathShape()); 25 | } 26 | 27 | public BitmapPathShapeHelper(BitmapPathShapeable shapeable) { 28 | if (shapeable == null) { 29 | throw new IllegalArgumentException("shapeable can not be null!"); 30 | } 31 | mShapeable = shapeable; 32 | } 33 | 34 | @Override 35 | public Bitmap clipPathShapeInCenter(Bitmap srcBp, Path path, boolean isOffset, BitmapShapeOption option) { 36 | return mShapeable.clipPathShapeInCenter(srcBp, path, isOffset, option); 37 | } 38 | 39 | @Override 40 | public Bitmap clipPathShape(Bitmap srcBp, Path path, Rect rect, boolean isOffset, BitmapShapeOption option) { 41 | return mShapeable.clipPathShape(srcBp, path, rect, isOffset, option); 42 | } 43 | 44 | public BitmapPathShapeable getShapeable() { 45 | return mShapeable; 46 | } 47 | 48 | public void setShapeable(BitmapPathShapeable shapeable) { 49 | if (shapeable == null) { 50 | return; 51 | } 52 | mShapeable = shapeable; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhuolong/bitmaphelperproject/BitmapRvAdapter.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelperproject; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.support.annotation.NonNull; 6 | import android.support.v7.widget.AppCompatImageView; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *
16 |  *     author : 明月春秋
17 |  *     e-mail : xiyujieit@163.com
18 |  *     time   : 2018/10/5
19 |  *     desc   :
20 |  *     version: 1.0
21 |  * 
22 | */ 23 | public class BitmapRvAdapter extends RecyclerView.Adapter { 24 | 25 | private Context mContext; 26 | private List mList; 27 | 28 | public BitmapRvAdapter(Context context, List list) { 29 | mContext = context; 30 | mList = list; 31 | } 32 | 33 | @NonNull 34 | @Override 35 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { 36 | View view = LayoutInflater.from(mContext).inflate(R.layout.rv_bitmap_item, viewGroup, false); 37 | return new MyViewHolder(view); 38 | } 39 | 40 | @Override 41 | public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) { 42 | AppCompatImageView acivBitmap = myViewHolder.itemView.findViewById(R.id.iv_bitmap); 43 | acivBitmap.setImageBitmap(mList.get(i)); 44 | } 45 | 46 | @Override 47 | public int getItemCount() { 48 | return mList == null ? 0 : mList.size(); 49 | } 50 | 51 | public class MyViewHolder extends RecyclerView.ViewHolder { 52 | 53 | public MyViewHolder(@NonNull View itemView) { 54 | super(itemView); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/rect/BitmapRectShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.rect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/4
13 |  *     desc   : 矩形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapRectShapeable { 18 | 19 | /** 20 | * 裁剪矩形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param rect 裁剪的矩形 24 | * @param option 额外选项 25 | * @return 返回裁剪好的图片 26 | */ 27 | Bitmap clipRectShapeInCenter(Bitmap srcBp, Rect rect, BitmapShapeOption option); 28 | 29 | /** 30 | * 裁剪矩形图片,以源图片中心点为裁剪图片中点 31 | * 32 | * @param srcBp 源图片 33 | * @param left 裁剪矩形左边距离 34 | * @param top 裁剪矩形上边距离 35 | * @param right 裁剪矩形长度 36 | * @param bottom 裁剪矩形高度 37 | * @param option 额外选项 38 | * @return 返回裁剪好的图片 39 | */ 40 | Bitmap clipRectShapeInCenter(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option); 41 | 42 | /** 43 | * 按比例裁剪矩形图片 44 | * 45 | * @param srcBp 源图片 46 | * @param rect 裁剪矩形 47 | * @param option 额外选项 48 | * @return 返回按比例裁剪好的图片 49 | */ 50 | Bitmap clipRectShape(Bitmap srcBp, Rect rect, BitmapShapeOption option); 51 | 52 | /** 53 | * 按比例裁剪矩形图片 54 | * 55 | * @param srcBp 源图片 56 | * @param left 裁剪矩形左边距离 57 | * @param top 裁剪矩形上边距离 58 | * @param right 裁剪矩形长度 59 | * @param bottom 裁剪矩形高度 60 | * @param option 额外选项 61 | * @return 返回裁剪好的图片 62 | */ 63 | Bitmap clipRectShape(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option); 64 | } 65 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/circle/BitmapCircleShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.circle; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapCircleShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapCircleShapeHelper implements BitmapCircleShapeable { 19 | 20 | private BitmapCircleShapeable mShapeable; 21 | 22 | public BitmapCircleShapeHelper() { 23 | this(new BitmapCircleShape()); 24 | } 25 | 26 | public BitmapCircleShapeHelper(BitmapCircleShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipCircleShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 35 | return mShapeable.clipCircleShapeInCenter(srcBp, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipCircleShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 40 | return mShapeable.clipCircleShapeInCenter(srcBp, scale, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipCircleShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 45 | return mShapeable.clipCircleShape(srcBp, rect, option); 46 | } 47 | 48 | public BitmapCircleShapeable getShapeable() { 49 | return mShapeable; 50 | } 51 | 52 | public void setShapeable(BitmapCircleShapeable shapeable) { 53 | if (shapeable == null) { 54 | return; 55 | } 56 | mShapeable = shapeable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/square/BitmapSquareShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.square; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapSquareShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapSquareShapeHelper implements BitmapSquareShapeable { 19 | 20 | private BitmapSquareShapeable mShapeable; 21 | 22 | public BitmapSquareShapeHelper() { 23 | this(new BitmapSquareShape()); 24 | } 25 | 26 | public BitmapSquareShapeHelper(BitmapSquareShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipSquareShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 35 | return mShapeable.clipSquareShapeInCenter(srcBp, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipSquareShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 40 | return mShapeable.clipSquareShapeInCenter(srcBp, scale, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipSquareShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 45 | return mShapeable.clipSquareShape(srcBp, rect, option); 46 | } 47 | 48 | public BitmapSquareShapeable getShapeable() { 49 | return mShapeable; 50 | } 51 | 52 | public void setShapeable(BitmapSquareShapeable shapeable) { 53 | if (shapeable == null) { 54 | return; 55 | } 56 | mShapeable = shapeable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/arc/BitmapArcShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.arc; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapArcShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapArcShapeHelper implements BitmapArcShapeable { 19 | 20 | private BitmapArcShapeable mShapeable; 21 | 22 | public BitmapArcShapeHelper() { 23 | this(new BitmapArcShape()); 24 | } 25 | 26 | public BitmapArcShapeHelper(BitmapArcShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, BitmapShapeOption option) { 35 | return mShapeable.clipArcShapeInCenter(srcBp, startAngle, sweepAngle, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, float scale, BitmapShapeOption option) { 40 | return mShapeable.clipArcShapeInCenter(srcBp, startAngle, sweepAngle, scale, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipArcShape(Bitmap srcBp, float startAngle, float sweepAngle, Rect rect, BitmapShapeOption option) { 45 | return mShapeable.clipArcShape(srcBp, startAngle, sweepAngle, rect, option); 46 | } 47 | 48 | public BitmapArcShapeable getShapeable() { 49 | return mShapeable; 50 | } 51 | 52 | public void setShapeable(BitmapArcShapeable shapeable) { 53 | if (shapeable == null) { 54 | return; 55 | } 56 | mShapeable = shapeable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/oval/BitmapOvalShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.oval; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapOvalShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapOvalShapeHelper implements BitmapOvalShapeable { 19 | 20 | private BitmapOvalShapeable mShapeable; 21 | 22 | public BitmapOvalShapeHelper() { 23 | this(new BitmapOvalShape()); 24 | } 25 | 26 | public BitmapOvalShapeHelper(BitmapOvalShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipOvalShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 35 | return mShapeable.clipOvalShapeInCenter(srcBp, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipOvalShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 40 | return mShapeable.clipOvalShapeInCenter(srcBp, scale, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipOvalShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 45 | return mShapeable.clipOvalShape(srcBp, rect, option); 46 | } 47 | 48 | @Override 49 | public Bitmap clipOvalShape(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option) { 50 | return mShapeable.clipOvalShape(srcBp, left, top, right, bottom, option); 51 | } 52 | 53 | public BitmapOvalShapeable getShapeable() { 54 | return mShapeable; 55 | } 56 | 57 | public void setShapeable(BitmapOvalShapeable shapeable) { 58 | if (shapeable == null) { 59 | return; 60 | } 61 | mShapeable = shapeable; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/rect/BitmapRectShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.rect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapRectShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapRectShapeHelper implements BitmapRectShapeable { 19 | 20 | private BitmapRectShapeable mShapeable; 21 | 22 | public BitmapRectShapeHelper() { 23 | this(new BitmapRectShape()); 24 | } 25 | 26 | public BitmapRectShapeHelper(BitmapRectShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipRectShapeInCenter(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 35 | return mShapeable.clipRectShapeInCenter(srcBp, rect, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipRectShapeInCenter(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option) { 40 | return mShapeable.clipRectShapeInCenter(srcBp, left, top, right, bottom, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipRectShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 45 | return mShapeable.clipRectShape(srcBp, rect, option); 46 | } 47 | 48 | @Override 49 | public Bitmap clipRectShape(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option) { 50 | return mShapeable.clipRectShape(srcBp, left, top, right, bottom, option); 51 | } 52 | 53 | public BitmapRectShapeable getShapeable() { 54 | return mShapeable; 55 | } 56 | 57 | public void setShapeable(BitmapRectShapeable shapeable) { 58 | if (shapeable == null) { 59 | return; 60 | } 61 | mShapeable = shapeable; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/BitmapShapeOption.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape; 2 | 3 | /** 4 | *
 5 |  *     author : 明月春秋
 6 |  *     e-mail : xiyujieit@163.com
 7 |  *     time   : 2018/10/5
 8 |  *     desc   : 画笔形状额外选项类
 9 |  *     version: 1.0
10 |  * 
11 | */ 12 | public class BitmapShapeOption { 13 | 14 | private int strokeWidth;//画笔线宽 15 | private int strokeColor;//画笔线颜色 16 | private boolean hasInverseEvenOdd;//是否反转判断图片内外的奇偶规则 17 | 18 | public int getStrokeWidth() { 19 | return strokeWidth; 20 | } 21 | 22 | public void setStrokeWidth(int strokeWidth) { 23 | this.strokeWidth = strokeWidth; 24 | } 25 | 26 | public int getStrokeColor() { 27 | return strokeColor; 28 | } 29 | 30 | public void setStrokeColor(int strokeColor) { 31 | this.strokeColor = strokeColor; 32 | } 33 | 34 | public boolean isHasInverseEvenOdd() { 35 | return hasInverseEvenOdd; 36 | } 37 | 38 | public void setHasInverseEvenOdd(boolean hasInverseEvenOdd) { 39 | this.hasInverseEvenOdd = hasInverseEvenOdd; 40 | } 41 | 42 | public static class Builder { 43 | private BitmapShapeOption mOption; 44 | 45 | public Builder() { 46 | mOption = new BitmapShapeOption(); 47 | } 48 | 49 | public BitmapShapeOption build() { 50 | return mOption; 51 | } 52 | 53 | public int getStrokeWidth() { 54 | return mOption.strokeWidth; 55 | } 56 | 57 | public Builder setStrokeWidth(int strokeWidth) { 58 | mOption.strokeWidth = strokeWidth; 59 | return this; 60 | } 61 | 62 | public int getStrokeColor() { 63 | return mOption.strokeColor; 64 | } 65 | 66 | public Builder setStrokeColor(int strokeColor) { 67 | mOption.strokeColor = strokeColor; 68 | return this; 69 | } 70 | 71 | public boolean isHasInverseEvenOdd() { 72 | return mOption.hasInverseEvenOdd; 73 | } 74 | 75 | public Builder setHasInverseEvenOdd(boolean hasInverseEvenOdd) { 76 | mOption.hasInverseEvenOdd = hasInverseEvenOdd; 77 | return this; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/util/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.util; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.Path; 6 | import android.graphics.RectF; 7 | import android.support.annotation.NonNull; 8 | 9 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 10 | 11 | /** 12 | *
13 |  *     author : 明月春秋
14 |  *     e-mail : xiyujieit@163.com
15 |  *     time   : 2018/10/4
16 |  *     desc   : 图片处理工具类
17 |  *     version: 1.0
18 |  * 
19 | */ 20 | public class BitmapUtils { 21 | 22 | /** 23 | * 获取进行过值判断生成的RectF 24 | * 25 | * @param left 矩形左边距离 26 | * @param top 矩形上边距离 27 | * @param right 矩形长度 28 | * @param bottom 矩形高度 29 | * @return 返回RectF 30 | */ 31 | @NonNull 32 | public static RectF getRectF(float left, float top, float right, float bottom) { 33 | if (left < 0) { 34 | left = 0; 35 | } 36 | if (top < 0) { 37 | top = 0; 38 | } 39 | if (right < left) { 40 | right = left; 41 | } 42 | if (bottom < top) { 43 | bottom = top; 44 | } 45 | return new RectF(left, top, right, bottom); 46 | } 47 | 48 | /** 49 | * 根据形状选项,进行额外绘制 50 | * 51 | * @param canvas 画布 52 | * @param paint 画笔 53 | * @param path 绘制路径 54 | * @param option 形状选项 55 | */ 56 | public static void drawShapeOption(Canvas canvas, Paint paint, Path path, BitmapShapeOption option) { 57 | if (canvas == null || paint == null || path == null || option == null) { 58 | return; 59 | } 60 | paint.setStyle(Paint.Style.STROKE); 61 | paint.setStrokeWidth(option.getStrokeWidth()); 62 | paint.setColor(option.getStrokeColor()); 63 | canvas.drawPath(path, paint); 64 | } 65 | 66 | /** 67 | * 裁剪路径图形 68 | * 69 | * @param canvas 画布 70 | * @param path 裁剪路径 71 | * @param option 额外选项 72 | */ 73 | public static void clipPath(Canvas canvas, Path path, BitmapShapeOption option) { 74 | if (canvas == null || path == null) { 75 | return; 76 | } 77 | if (option != null && option.isHasInverseEvenOdd()) { 78 | path.setFillType(Path.FillType.INVERSE_EVEN_ODD); 79 | } 80 | canvas.clipPath(path); 81 | path.setFillType(Path.FillType.EVEN_ODD); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/roundRect/BitmapRoundRectShapeable.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.roundRect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/10/4
13 |  *     desc   : 圆角矩形图片裁剪实现接口
14 |  *     version: 1.0
15 |  * 
16 | */ 17 | public interface BitmapRoundRectShapeable { 18 | 19 | /** 20 | * 裁剪圆角矩形图片,以源图片中心点为裁剪图片中点 21 | * 22 | * @param srcBp 源图片 23 | * @param radius 裁剪的圆角半径(四个角半径一致) 24 | * @param option 额外选项 25 | * @return 返回裁剪好的图片 26 | */ 27 | Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, BitmapShapeOption option); 28 | 29 | /** 30 | * 裁剪圆角矩形图片,以源图片中心点为裁剪图片中点 31 | * 32 | * @param srcBp 源图片 33 | * @param radius 裁剪的圆角半径数组(上左;上右;下右;下左) 34 | * @param option 额外选项 35 | * @return 返回裁剪好的图片 36 | */ 37 | Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, BitmapShapeOption option); 38 | 39 | /** 40 | * 按比例裁圆角矩形图片,以源图片中心点为裁剪图片中点 41 | * 42 | * @param srcBp 源图片 43 | * @param radius 裁剪的圆角半径(四个角半径一致) 44 | * @param scale 裁剪比例 45 | * @param option 额外选项 46 | * @return 返回裁剪好的图片 47 | */ 48 | Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, float scale, BitmapShapeOption option); 49 | 50 | /** 51 | * 按比例裁圆角矩形图片,以源图片中心点为裁剪图片中点 52 | * 53 | * @param srcBp 源图片 54 | * @param radius 裁剪的圆角半径数组(上左;上右;下右;下左) 55 | * @param scale 裁剪比例 56 | * @param option 额外选项 57 | * @return 返回裁剪好的图片 58 | */ 59 | Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, float scale, BitmapShapeOption option); 60 | 61 | /** 62 | * 按比例裁圆角矩形图片 63 | * 64 | * @param srcBp 源图片 65 | * @param radius 裁剪的圆角半径(四个角半径一致) 66 | * @param rect 裁剪图形所在矩形 67 | * @param option 额外选项 68 | * @return 返回裁剪好的图片 69 | */ 70 | Bitmap clipRoundRectShape(Bitmap srcBp, float radius, Rect rect, BitmapShapeOption option); 71 | 72 | /** 73 | * 按比例裁圆角矩形图片 74 | * 75 | * @param srcBp 源图片 76 | * @param radius 裁剪的圆角半径数组(上左;上右;下右;下左) 77 | * @param rect 裁剪图形所在矩形 78 | * @param option 额外选项 79 | * @return 返回裁剪好的图片 80 | */ 81 | Bitmap clipRoundRectShape(Bitmap srcBp, float[] radius, Rect rect, BitmapShapeOption option); 82 | } 83 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/roundRect/BitmapRoundRectShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.roundRect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Rect; 5 | 6 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 7 | 8 | /** 9 | *
10 |  *     author : 明月春秋
11 |  *     e-mail : xiyujieit@163.com
12 |  *     time   : 2018/11/3
13 |  *     desc   : 供外界调用的抽象类
14 |  *              实现BitmapRoundRectShapeable
15 |  *     version: 1.0
16 |  * 
17 | */ 18 | public class BitmapRoundRectShapeHelper implements BitmapRoundRectShapeable { 19 | 20 | private BitmapRoundRectShapeable mShapeable; 21 | 22 | public BitmapRoundRectShapeHelper() { 23 | this(new BitmapRoundRectShape()); 24 | } 25 | 26 | public BitmapRoundRectShapeHelper(BitmapRoundRectShapeable shapeable) { 27 | if (shapeable == null) { 28 | throw new IllegalArgumentException("shapeable can not be null!"); 29 | } 30 | mShapeable = shapeable; 31 | } 32 | 33 | @Override 34 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, BitmapShapeOption option) { 35 | return mShapeable.clipRoundRectShapeInCenter(srcBp, radius, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, BitmapShapeOption option) { 40 | return mShapeable.clipRoundRectShapeInCenter(srcBp, radius, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, float scale, BitmapShapeOption option) { 45 | return mShapeable.clipRoundRectShapeInCenter(srcBp, radius, scale, option); 46 | } 47 | 48 | @Override 49 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, float scale, BitmapShapeOption option) { 50 | return mShapeable.clipRoundRectShapeInCenter(srcBp, radius, scale, option); 51 | } 52 | 53 | @Override 54 | public Bitmap clipRoundRectShape(Bitmap srcBp, float radius, Rect rect, BitmapShapeOption option) { 55 | return mShapeable.clipRoundRectShape(srcBp, radius, rect, option); 56 | } 57 | 58 | @Override 59 | public Bitmap clipRoundRectShape(Bitmap srcBp, float[] radius, Rect rect, BitmapShapeOption option) { 60 | return mShapeable.clipRoundRectShape(srcBp, radius, rect, option); 61 | } 62 | 63 | public BitmapRoundRectShapeable getShapeable() { 64 | return mShapeable; 65 | } 66 | 67 | public void setShapeable(BitmapRoundRectShapeable shapeable) { 68 | if (shapeable == null) { 69 | return; 70 | } 71 | mShapeable = shapeable; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/square/BitmapSquareShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.square; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | 10 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 11 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 12 | 13 | /** 14 | *
15 |  *     author : 明月春秋
16 |  *     e-mail : xiyujieit@163.com
17 |  *     time   : 2018/8/19
18 |  *     desc   : 方形图片裁剪实现类
19 |  *              实现BitmapSquareable
20 |  *     version: 1.0
21 |  * 
22 | */ 23 | class BitmapSquareShape implements BitmapSquareShapeable { 24 | 25 | @Override 26 | public Bitmap clipSquareShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 27 | return clipSquareShapeInCenter(srcBp, 1.0f, option); 28 | } 29 | 30 | @Override 31 | public Bitmap clipSquareShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 32 | return clipSquareShape(srcBp, scale, null, option); 33 | } 34 | 35 | @Override 36 | public Bitmap clipSquareShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 37 | return clipSquareShape(srcBp, 1, rect, option); 38 | } 39 | 40 | /** 41 | * 裁剪方形图片 42 | * 43 | * @param srcBp 源图片 44 | * @param scale 裁剪比例 45 | * @param rect 裁剪图形所在矩形 46 | * @return 返回裁剪好的图片 47 | */ 48 | private Bitmap clipSquareShape(Bitmap srcBp, float scale, Rect rect, BitmapShapeOption option) { 49 | if (srcBp == null) { 50 | return null; 51 | } 52 | int width = srcBp.getWidth(); 53 | int height = srcBp.getHeight(); 54 | if (scale <= 0 || scale > 1) { 55 | scale = 1; 56 | } 57 | int wideLength = (int) (width * scale); 58 | int highLength = (int) (height * scale); 59 | if (rect != null) { 60 | wideLength = rect.width(); 61 | highLength = rect.height(); 62 | } 63 | int border = (wideLength < highLength ? wideLength : highLength) / 2; 64 | Bitmap destBp = Bitmap.createBitmap(border * 2, border * 2, Bitmap.Config.ARGB_8888); 65 | Canvas canvas = new Canvas(destBp); 66 | Rect srcRect = rect; 67 | if (rect == null) { 68 | srcRect = new Rect(); 69 | int left = (width - border * 2) / 2; 70 | int top = (height - border * 2) / 2; 71 | srcRect.set(left, top, left + border * 2, top + border * 2); 72 | } 73 | Rect destRect = new Rect(); 74 | destRect.set(0, 0, border * 2, border * 2); 75 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 76 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 77 | Path path = new Path(); 78 | path.addRect(new RectF(destRect), Path.Direction.CW); 79 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 80 | return destBp; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/circle/BitmapCircleShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.circle; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | 9 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 10 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 11 | 12 | /** 13 | *
14 |  *     author : 明月春秋
15 |  *     e-mail : xiyujieit@163.com
16 |  *     time   : 2018/8/19
17 |  *     desc   : 圆形图片裁剪实现类
18 |  *              实现BitmapRoundable
19 |  *     version: 1.0
20 |  * 
21 | */ 22 | class BitmapCircleShape implements BitmapCircleShapeable { 23 | 24 | @Override 25 | public Bitmap clipCircleShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 26 | return clipCircleShapeInCenter(srcBp, 1.0f, option); 27 | } 28 | 29 | @Override 30 | public Bitmap clipCircleShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 31 | return clipCircleShape(srcBp, scale, null, option); 32 | } 33 | 34 | @Override 35 | public Bitmap clipCircleShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 36 | return clipCircleShape(srcBp, 1, rect, option); 37 | } 38 | 39 | /** 40 | * 裁剪圆形图片 41 | * 42 | * @param srcBp 源图片 43 | * @param scale 裁剪比例 44 | * @param rect 裁剪图形所在矩形 45 | * @return 返回裁剪好的图片 46 | */ 47 | private Bitmap clipCircleShape(Bitmap srcBp, float scale, Rect rect, BitmapShapeOption option) { 48 | if (srcBp == null) { 49 | return null; 50 | } 51 | int width = srcBp.getWidth(); 52 | int height = srcBp.getHeight(); 53 | if (scale <= 0 || scale > 1) { 54 | scale = 1; 55 | } 56 | int wideLength = (int) (width * scale); 57 | int highLength = (int) (height * scale); 58 | if (rect != null) { 59 | wideLength = rect.width(); 60 | highLength = rect.height(); 61 | } 62 | int radius = (wideLength < highLength ? wideLength : highLength) / 2; 63 | Bitmap destBp = Bitmap.createBitmap(radius * 2, radius * 2, Bitmap.Config.ARGB_8888); 64 | Canvas canvas = new Canvas(destBp); 65 | Rect srcRect = rect; 66 | if (rect == null) { 67 | srcRect = new Rect(); 68 | int left = (width - radius * 2) / 2; 69 | int top = (height - radius * 2) / 2; 70 | srcRect.set(left, top, left + radius * 2, top + radius * 2); 71 | } 72 | Rect destRect = new Rect(); 73 | destRect.set(0, 0, radius * 2, radius * 2); 74 | Path path = new Path(); 75 | path.addCircle(radius, radius, radius, Path.Direction.CW); 76 | BitmapUtils.clipPath(canvas, path, option); 77 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 78 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 79 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 80 | return destBp; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/zhuolong/bitmaphelperproject/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelperproject; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.graphics.Color; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.support.v7.widget.GridLayoutManager; 11 | import android.support.v7.widget.RecyclerView; 12 | 13 | import com.zhuolong.bitmaphelper.BitmapHelperFactory; 14 | import com.zhuolong.bitmaphelper.helper.BitmapShapeHelper; 15 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 16 | import com.zhuolong.bitmaphelper.util.ScreenUtils; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class MainActivity extends AppCompatActivity { 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_main); 27 | RecyclerView rvBitmaps = findViewById(R.id.rv_bitmaps); 28 | rvBitmaps.setLayoutManager(new GridLayoutManager(this, 2)); 29 | BitmapShapeHelper helper = BitmapHelperFactory.newBitmapShapeHelper(); 30 | List list = new ArrayList<>(); 31 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.demo); 32 | list.add(bitmap); 33 | BitmapShapeOption option = new BitmapShapeOption.Builder() 34 | .setStrokeWidth((int) ScreenUtils.getPxFromDp(getResources(), 2)) 35 | .setStrokeColor(Color.BLUE).build(); 36 | option.setHasInverseEvenOdd(true); 37 | list.add(helper.getBitmapCircleShapeHelper().clipCircleShapeInCenter(bitmap, 0.5f, option)); 38 | list.add(helper.getBitmapSquareShapeHelper().clipSquareShapeInCenter(bitmap, 0.5f, null)); 39 | option.setStrokeWidth((int) ScreenUtils.getPxFromDp(getResources(), 4)); 40 | option.setStrokeColor(Color.RED); 41 | list.add(helper.getBitmapOvalShapeHelper().clipOvalShapeInCenter(bitmap, 0.4f, option)); 42 | Rect rect = new Rect(200, 200, 800, 600); 43 | list.add(helper.getBitmapArcShapeHelper().clipArcShape(bitmap, 30, -180, rect, option)); 44 | option.setStrokeColor(Color.GREEN); 45 | list.add(helper.getBitmapRectShapeHelper().clipRectShapeInCenter(bitmap, rect, option)); 46 | option.setStrokeColor(Color.GRAY); 47 | list.add(helper.getBitmapRoundRectShapeHelper().clipRoundRectShapeInCenter(bitmap, 48 | new float[]{200, 200, 0, 0, 200, 200, 0, 0}, 0.7f, option)); 49 | Path path = new Path(); 50 | path.moveTo(200, 0); 51 | path.lineTo(700, 300); 52 | path.lineTo(200, 400); 53 | path.lineTo(100, 100); 54 | path.close(); 55 | option.setStrokeColor(Color.BLACK); 56 | list.add(helper.getBitmapPathShapeHelper().clipPathShape(bitmap, path, rect, false, option)); 57 | list.add(helper.getBitmapPathShapeHelper().clipPathShape(bitmap, path, rect, true, option)); 58 | rvBitmaps.setAdapter(new BitmapRvAdapter(this, list)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/path/BitmapPathShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.path; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | import android.util.Log; 10 | 11 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 12 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 13 | 14 | /** 15 | *
16 |  *     author : 明月春秋
17 |  *     e-mail : xiyujieit@163.com
18 |  *     time   : 2018/10/4
19 |  *     desc   : 任意路径图片裁剪实现类
20 |  *              实现BitmapPathShapeable
21 |  *     version: 1.0
22 |  * 
23 | */ 24 | class BitmapPathShape implements BitmapPathShapeable { 25 | 26 | @Override 27 | public Bitmap clipPathShapeInCenter(Bitmap srcBp, Path path, boolean isOffset, BitmapShapeOption option) { 28 | return clipPathShape(srcBp, path, null, true, isOffset, option); 29 | } 30 | 31 | @Override 32 | public Bitmap clipPathShape(Bitmap srcBp, Path path, Rect rect, boolean isOffset, BitmapShapeOption option) { 33 | return clipPathShape(srcBp, path, rect, false, isOffset, option); 34 | } 35 | 36 | /** 37 | * 裁剪任意路径图片 38 | * 39 | * @param srcBp 源图片 40 | * @param path 裁剪的任意路径(路径中最好X轴和Y轴有点在0处,否则显示path包裹的矩形时,path会偏移处矩形) 41 | * @param rect 任意路径所在矩形 42 | * @param isInCenter 是否是处于源图片中央 43 | * @param isOffset 是否让path偏移,保证在包裹path的显示矩形里 44 | * @param option 额外选项 45 | * @return 返回裁剪好的图片 46 | */ 47 | private Bitmap clipPathShape(Bitmap srcBp, Path path, Rect rect, boolean isInCenter, 48 | boolean isOffset, BitmapShapeOption option) { 49 | if (srcBp == null) { 50 | return null; 51 | } 52 | int width = srcBp.getWidth(); 53 | int height = srcBp.getHeight(); 54 | int wideLength = width; 55 | int highLength = width; 56 | if (path != null) { 57 | RectF rectF = new RectF(); 58 | path.computeBounds(rectF, true); 59 | wideLength = (int) rectF.width(); 60 | highLength = (int) rectF.height(); 61 | if (isOffset) { 62 | path.offset(-rectF.left, -rectF.top); 63 | } 64 | } 65 | Bitmap destBp = Bitmap.createBitmap(wideLength, highLength, Bitmap.Config.ARGB_8888); 66 | Canvas canvas = new Canvas(destBp); 67 | Rect srcRect = rect; 68 | if (isInCenter) { 69 | srcRect = new Rect(); 70 | int left = (width - wideLength) / 2; 71 | int top = (height - highLength) / 2; 72 | srcRect.set(left, top, left + wideLength, top + highLength); 73 | } 74 | Rect destRect = new Rect(); 75 | destRect.set(0, 0, wideLength, highLength); 76 | if (path != null) { 77 | BitmapUtils.clipPath(canvas, path, option); 78 | } 79 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 80 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 81 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 82 | return destBp; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/oval/BitmapOvalShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.oval; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | 10 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 11 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 12 | 13 | /** 14 | *
15 |  *     author : 明月春秋
16 |  *     e-mail : xiyujieit@163.com
17 |  *     time   : 2018/10/4
18 |  *     desc   : 椭圆形图片裁剪实现类
19 |  *              实现BitmapOvalShapeable
20 |  *     version: 1.0
21 |  * 
22 | */ 23 | class BitmapOvalShape implements BitmapOvalShapeable { 24 | 25 | @Override 26 | public Bitmap clipOvalShapeInCenter(Bitmap srcBp, BitmapShapeOption option) { 27 | return clipOvalShapeInCenter(srcBp, 1.0f, option); 28 | } 29 | 30 | @Override 31 | public Bitmap clipOvalShapeInCenter(Bitmap srcBp, float scale, BitmapShapeOption option) { 32 | return clipOvalShape(srcBp, scale, null, option); 33 | } 34 | 35 | @Override 36 | public Bitmap clipOvalShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 37 | return clipOvalShape(srcBp, 1, rect, option); 38 | } 39 | 40 | @Override 41 | public Bitmap clipOvalShape(Bitmap srcBp, float left, float top, float right, float bottom, BitmapShapeOption option) { 42 | Rect rect = new Rect(); 43 | BitmapUtils.getRectF(left, top, right, bottom).roundOut(rect); 44 | return clipOvalShape(srcBp, rect, option); 45 | } 46 | 47 | /** 48 | * 裁剪椭圆形图片 49 | * 50 | * @param srcBp 源图片 51 | * @param scale 裁剪比例 52 | * @param rect 裁剪图形所在矩形 53 | * @return 返回裁剪好的图片 54 | */ 55 | private Bitmap clipOvalShape(Bitmap srcBp, float scale, Rect rect, BitmapShapeOption option) { 56 | if (srcBp == null) { 57 | return null; 58 | } 59 | int width = srcBp.getWidth(); 60 | int height = srcBp.getHeight(); 61 | if (scale <= 0 || scale > 1) { 62 | scale = 1; 63 | } 64 | int wideLength = (int) (width * scale); 65 | int highLength = (int) (height * scale); 66 | if (rect != null) { 67 | wideLength = rect.width(); 68 | highLength = rect.height(); 69 | } 70 | Bitmap destBp = Bitmap.createBitmap(wideLength, highLength, Bitmap.Config.ARGB_8888); 71 | Canvas canvas = new Canvas(destBp); 72 | Rect srcRect = rect; 73 | if (rect == null) { 74 | srcRect = new Rect(); 75 | int left = (width - wideLength) / 2; 76 | int top = (height - highLength) / 2; 77 | srcRect.set(left, top, left + wideLength, top + highLength); 78 | } 79 | Rect destRect = new Rect(); 80 | destRect.set(0, 0, wideLength, highLength); 81 | Path path = new Path(); 82 | path.addOval(new RectF(destRect), Path.Direction.CW); 83 | BitmapUtils.clipPath(canvas, path, option); 84 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 85 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 86 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 87 | return destBp; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/rect/BitmapRectShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.rect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | 10 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 11 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 12 | 13 | /** 14 | *
15 |  *     author : 明月春秋
16 |  *     e-mail : xiyujieit@163.com
17 |  *     time   : 2018/10/4
18 |  *     desc   : 矩形图片裁剪实现类
19 |  *              实现BitmapRectShapeable
20 |  *     version: 1.0
21 |  * 
22 | */ 23 | class BitmapRectShape implements BitmapRectShapeable { 24 | 25 | @Override 26 | public Bitmap clipRectShapeInCenter(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 27 | return clipRectShape(srcBp, rect, true, option); 28 | } 29 | 30 | @Override 31 | public Bitmap clipRectShapeInCenter(Bitmap srcBp, float left, float top, float right, float bottom, 32 | BitmapShapeOption option) { 33 | Rect rect = new Rect(); 34 | BitmapUtils.getRectF(left, top, right, bottom).roundOut(rect); 35 | return clipRectShapeInCenter(srcBp, rect, option); 36 | } 37 | 38 | @Override 39 | public Bitmap clipRectShape(Bitmap srcBp, Rect rect, BitmapShapeOption option) { 40 | return clipRectShape(srcBp, rect, false, option); 41 | } 42 | 43 | @Override 44 | public Bitmap clipRectShape(Bitmap srcBp, float left, float top, float right, float bottom, 45 | BitmapShapeOption option) { 46 | Rect rect = new Rect(); 47 | BitmapUtils.getRectF(left, top, right, bottom).roundOut(rect); 48 | return clipRectShape(srcBp, rect, option); 49 | } 50 | 51 | /** 52 | * 裁剪矩形图片 53 | * 54 | * @param srcBp 源图片 55 | * @param rect 裁剪图形所在矩形 56 | * @param isInCenter 是否是处于源图片中央 57 | * @return 返回裁剪好的图片 58 | */ 59 | private Bitmap clipRectShape(Bitmap srcBp, Rect rect, boolean isInCenter, BitmapShapeOption option) { 60 | if (srcBp == null) { 61 | return null; 62 | } 63 | int width = srcBp.getWidth(); 64 | int height = srcBp.getHeight(); 65 | int wideLength = width; 66 | int highLength = height; 67 | if (rect != null) { 68 | wideLength = rect.width(); 69 | highLength = rect.height(); 70 | } 71 | Bitmap destBp = Bitmap.createBitmap(wideLength, highLength, Bitmap.Config.ARGB_8888); 72 | Canvas canvas = new Canvas(destBp); 73 | Rect srcRect = rect; 74 | if (isInCenter) { 75 | srcRect = new Rect(); 76 | int left = (width - wideLength) / 2; 77 | int top = (height - highLength) / 2; 78 | srcRect.set(left, top, left + wideLength, top + highLength); 79 | } 80 | Rect destRect = new Rect(); 81 | destRect.set(0, 0, wideLength, highLength); 82 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 83 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 84 | Path path = new Path(); 85 | path.addRect(new RectF(destRect), Path.Direction.CW); 86 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 87 | return destBp; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/arc/BitmapArcShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.arc; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | 10 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 11 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 12 | 13 | /** 14 | *
15 |  *     author : 明月春秋
16 |  *     e-mail : xiyujieit@163.com
17 |  *     time   : 2018/10/4
18 |  *     desc   : 弧形图片裁剪实现类
19 |  *              实现BitmapArcShapeable
20 |  *     version: 1.0
21 |  * 
22 | */ 23 | class BitmapArcShape implements BitmapArcShapeable { 24 | 25 | @Override 26 | public Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, BitmapShapeOption option) { 27 | return clipArcShapeInCenter(srcBp, startAngle, sweepAngle, 1.0f, option); 28 | } 29 | 30 | @Override 31 | public Bitmap clipArcShapeInCenter(Bitmap srcBp, float startAngle, float sweepAngle, float scale, 32 | BitmapShapeOption option) { 33 | return clipArcShape(srcBp, startAngle, sweepAngle, scale, null, option); 34 | } 35 | 36 | @Override 37 | public Bitmap clipArcShape(Bitmap srcBp, float startAngle, float sweepAngle, Rect rect, 38 | BitmapShapeOption option) { 39 | return clipArcShape(srcBp, startAngle, sweepAngle, 1, rect, option); 40 | } 41 | 42 | /** 43 | * 裁剪弧形图片 44 | * 45 | * @param srcBp 源图片 46 | * @param startAngle 起始角度 47 | * @param sweepAngle 跨越角度 48 | * @param scale 裁剪比例 49 | * @param rect 裁剪图形所在矩形 50 | * @return 返回裁剪好的图片 51 | */ 52 | private Bitmap clipArcShape(Bitmap srcBp, float startAngle, float sweepAngle, float scale, 53 | Rect rect, BitmapShapeOption option) { 54 | if (srcBp == null) { 55 | return null; 56 | } 57 | int width = srcBp.getWidth(); 58 | int height = srcBp.getHeight(); 59 | if (scale <= 0 || scale > 1) { 60 | scale = 1; 61 | } 62 | int wideLength = (int) (width * scale); 63 | int highLength = (int) (height * scale); 64 | if (rect != null) { 65 | wideLength = rect.width(); 66 | highLength = rect.height(); 67 | } 68 | Bitmap destBp = Bitmap.createBitmap(wideLength, highLength, Bitmap.Config.ARGB_8888); 69 | Canvas canvas = new Canvas(destBp); 70 | Rect srcRect = rect; 71 | if (rect == null) { 72 | srcRect = new Rect(); 73 | int left = (width - wideLength) / 2; 74 | int top = (height - highLength) / 2; 75 | srcRect.set(left, top, left + wideLength, top + highLength); 76 | } 77 | Rect destRect = new Rect(); 78 | destRect.set(0, 0, wideLength, highLength); 79 | Path path = new Path(); 80 | path.addArc(new RectF(destRect), startAngle, sweepAngle); 81 | path.close(); 82 | BitmapUtils.clipPath(canvas, path, option); 83 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 84 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 85 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 86 | return destBp; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 在新版本中提供了自定义功能,优化了项目框架。 2 | 由于许多时候需要使用到对图片的一些裁剪特效,所以写了一个简单的帮助库,目前只是简单对形状做了一些处理,后续会进行优化改进,加入更多的效果。 3 | ## 一.各种处理效果 4 | ![Image text](images/Screenshot_20181006-101504.jpg) 5 | ![Image text](images/Screenshot_20181006-145916.jpg) 6 | 7 | 第一张图片是原图,后续两张依次是裁剪圆形、正方形、椭圆、弧形、矩形、圆角矩形、随意路径不进行偏移处理,随意路径进行偏移处理的正常与反向效果,既可以从源图片中央开始裁剪,指定裁剪比例,也可以在源图片指定任意的矩形位置开始裁剪,并且可以指定是否添加边框,边框颜色和宽度。 8 | ## 二.添加依赖 9 | 在project的build.gradle文件中添加 10 | 11 | ``` 12 | allprojects { 13 | repositories { 14 | ... 15 | maven { url 'https://jitpack.io' } 16 | } 17 | } 18 | ``` 19 | 在module的build.gradle文件中添加 20 | 21 | ``` 22 | dependencies { 23 | implementation 'com.github.MingYueChunQiu:BitmapHelper:0.1.4' 24 | } 25 | ``` 26 | 27 | ## 三.Bitmap的使用 28 | ``` 29 | //先获取对图片形状处理的帮助类 30 | BitmapShapeHelper helper = BitmapHelperFactory.newBitmapShapeHelper(); 31 | 32 | //在BitmapShapeHelper 里目前提供了对7种形状的处理 33 | @NonNull 34 | public BitmapCircleShapeHelper getBitmapCircleShapeHelper() { 35 | return new BitmapCircleShapeHelper(); 36 | } 37 | 38 | @NonNull 39 | public BitmapCircleShapeHelper getBitmapCircleShapeHelper(BitmapCircleShapeable shapeable) { 40 | return new BitmapCircleShapeHelper(shapeable); 41 | } 42 | 43 | @NonNull 44 | public BitmapSquareShapeHelper getBitmapSquareShapeHelper() { 45 | return new BitmapSquareShapeHelper(); 46 | } 47 | 48 | @NonNull 49 | public BitmapSquareShapeHelper getBitmapSquareShapeHelper(BitmapSquareShapeable shapeable) { 50 | return new BitmapSquareShapeHelper(shapeable); 51 | } 52 | 53 | @NonNull 54 | public BitmapRoundRectShapeHelper getBitmapRoundRectShapeHelper() { 55 | return new BitmapRoundRectShapeHelper(); 56 | } 57 | 58 | @NonNull 59 | public BitmapRoundRectShapeHelper getBitmapRoundRectShapeHelper(BitmapRoundRectShapeable shapeable) { 60 | return new BitmapRoundRectShapeHelper(shapeable); 61 | } 62 | 63 | @NonNull 64 | public BitmapPathShapeHelper getBitmapPathShapeHelper() { 65 | return new BitmapPathShapeHelper(); 66 | } 67 | 68 | @NonNull 69 | public BitmapPathShapeHelper getBitmapPathShapeHelper(BitmapPathShapeable shapeable) { 70 | return new BitmapPathShapeHelper(shapeable); 71 | } 72 | 73 | @NonNull 74 | public BitmapArcShapeHelper getBitmapArcShapeHelper() { 75 | return new BitmapArcShapeHelper(); 76 | } 77 | 78 | @NonNull 79 | public BitmapArcShapeHelper getBitmapArcShapeHelper(BitmapArcShapeable shapeable) { 80 | return new BitmapArcShapeHelper(shapeable); 81 | } 82 | 83 | @NonNull 84 | public BitmapRectShapeHelper getBitmapRectShapeHelper() { 85 | return new BitmapRectShapeHelper(); 86 | } 87 | 88 | @NonNull 89 | public BitmapRectShapeHelper getBitmapRectShapeHelper(BitmapRectShapeable shapeable) { 90 | return new BitmapRectShapeHelper(shapeable); 91 | } 92 | 93 | @NonNull 94 | public BitmapOvalShapeHelper getBitmapOvalShapeHelper() { 95 | return new BitmapOvalShapeHelper(); 96 | } 97 | 98 | @NonNull 99 | public BitmapOvalShapeHelper getBitmapOvalShapeHelper(BitmapOvalShapeable shapeable) { 100 | return new BitmapOvalShapeHelper(shapeable); 101 | } 102 | ``` 103 | 更多详细内容请至本文末尾项目地址看项目demo使用或库源码。 104 | ## 四.结语 105 | 项目的GitHub地址是[https://github.com/MingYueChunQiu/BitmapHelper](https://github.com/MingYueChunQiu/BitmapHelper),码云的项目地址是[https://gitee.com/MingYueChunQiu/BitmapHelper](https://gitee.com/MingYueChunQiu/BitmapHelper)。如果有什么不足或建议,欢迎反馈。 106 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/helper/BitmapShapeHelper.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.helper; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import com.zhuolong.bitmaphelper.shape.arc.BitmapArcShapeHelper; 6 | import com.zhuolong.bitmaphelper.shape.arc.BitmapArcShapeable; 7 | import com.zhuolong.bitmaphelper.shape.circle.BitmapCircleShapeHelper; 8 | import com.zhuolong.bitmaphelper.shape.circle.BitmapCircleShapeable; 9 | import com.zhuolong.bitmaphelper.shape.oval.BitmapOvalShapeHelper; 10 | import com.zhuolong.bitmaphelper.shape.oval.BitmapOvalShapeable; 11 | import com.zhuolong.bitmaphelper.shape.path.BitmapPathShapeHelper; 12 | import com.zhuolong.bitmaphelper.shape.path.BitmapPathShapeable; 13 | import com.zhuolong.bitmaphelper.shape.rect.BitmapRectShapeHelper; 14 | import com.zhuolong.bitmaphelper.shape.rect.BitmapRectShapeable; 15 | import com.zhuolong.bitmaphelper.shape.roundRect.BitmapRoundRectShapeHelper; 16 | import com.zhuolong.bitmaphelper.shape.roundRect.BitmapRoundRectShapeable; 17 | import com.zhuolong.bitmaphelper.shape.square.BitmapSquareShapeHelper; 18 | import com.zhuolong.bitmaphelper.shape.square.BitmapSquareShapeable; 19 | 20 | /** 21 | *
 22 |  *     author : 明月春秋
 23 |  *     e-mail : xiyujieit@163.com
 24 |  *     time   : 2018/8/19
 25 |  *     desc   : 图片形状处理帮助类
 26 |  *     version: 1.0
 27 |  * 
28 | */ 29 | public class BitmapShapeHelper { 30 | 31 | @NonNull 32 | public BitmapCircleShapeHelper getBitmapCircleShapeHelper() { 33 | return new BitmapCircleShapeHelper(); 34 | } 35 | 36 | @NonNull 37 | public BitmapCircleShapeHelper getBitmapCircleShapeHelper(BitmapCircleShapeable shapeable) { 38 | return new BitmapCircleShapeHelper(shapeable); 39 | } 40 | 41 | @NonNull 42 | public BitmapSquareShapeHelper getBitmapSquareShapeHelper() { 43 | return new BitmapSquareShapeHelper(); 44 | } 45 | 46 | @NonNull 47 | public BitmapSquareShapeHelper getBitmapSquareShapeHelper(BitmapSquareShapeable shapeable) { 48 | return new BitmapSquareShapeHelper(shapeable); 49 | } 50 | 51 | @NonNull 52 | public BitmapRoundRectShapeHelper getBitmapRoundRectShapeHelper() { 53 | return new BitmapRoundRectShapeHelper(); 54 | } 55 | 56 | @NonNull 57 | public BitmapRoundRectShapeHelper getBitmapRoundRectShapeHelper(BitmapRoundRectShapeable shapeable) { 58 | return new BitmapRoundRectShapeHelper(shapeable); 59 | } 60 | 61 | @NonNull 62 | public BitmapPathShapeHelper getBitmapPathShapeHelper() { 63 | return new BitmapPathShapeHelper(); 64 | } 65 | 66 | @NonNull 67 | public BitmapPathShapeHelper getBitmapPathShapeHelper(BitmapPathShapeable shapeable) { 68 | return new BitmapPathShapeHelper(shapeable); 69 | } 70 | 71 | @NonNull 72 | public BitmapArcShapeHelper getBitmapArcShapeHelper() { 73 | return new BitmapArcShapeHelper(); 74 | } 75 | 76 | @NonNull 77 | public BitmapArcShapeHelper getBitmapArcShapeHelper(BitmapArcShapeable shapeable) { 78 | return new BitmapArcShapeHelper(shapeable); 79 | } 80 | 81 | @NonNull 82 | public BitmapRectShapeHelper getBitmapRectShapeHelper() { 83 | return new BitmapRectShapeHelper(); 84 | } 85 | 86 | @NonNull 87 | public BitmapRectShapeHelper getBitmapRectShapeHelper(BitmapRectShapeable shapeable) { 88 | return new BitmapRectShapeHelper(shapeable); 89 | } 90 | 91 | @NonNull 92 | public BitmapOvalShapeHelper getBitmapOvalShapeHelper() { 93 | return new BitmapOvalShapeHelper(); 94 | } 95 | 96 | @NonNull 97 | public BitmapOvalShapeHelper getBitmapOvalShapeHelper(BitmapOvalShapeable shapeable) { 98 | return new BitmapOvalShapeHelper(shapeable); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/java/com/zhuolong/bitmaphelper/shape/roundRect/BitmapRoundRectShape.java: -------------------------------------------------------------------------------- 1 | package com.zhuolong.bitmaphelper.shape.roundRect; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.Rect; 8 | import android.graphics.RectF; 9 | 10 | import com.zhuolong.bitmaphelper.shape.BitmapShapeOption; 11 | import com.zhuolong.bitmaphelper.util.BitmapUtils; 12 | 13 | /** 14 | *
 15 |  *     author : 明月春秋
 16 |  *     e-mail : xiyujieit@163.com
 17 |  *     time   : 2018/10/4
 18 |  *     desc   : 圆角矩形图片裁剪实现类
 19 |  *              实现BitmapRoundRectShapeable
 20 |  *     version: 1.0
 21 |  * 
22 | */ 23 | class BitmapRoundRectShape implements BitmapRoundRectShapeable { 24 | 25 | @Override 26 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, BitmapShapeOption option) { 27 | return clipRoundRectShapeInCenter(srcBp, radius, 1.0f, option); 28 | } 29 | 30 | @Override 31 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, BitmapShapeOption option) { 32 | return clipRoundRectShapeInCenter(srcBp, radius, 1.0f, option); 33 | } 34 | 35 | @Override 36 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float radius, float scale, BitmapShapeOption option) { 37 | if (radius < 0) { 38 | radius = 0; 39 | } 40 | return clipRoundRectShapeInCenter(srcBp, 41 | new float[]{radius, radius, radius, radius, radius, radius, radius, radius}, 42 | scale, option); 43 | } 44 | 45 | @Override 46 | public Bitmap clipRoundRectShapeInCenter(Bitmap srcBp, float[] radius, float scale, BitmapShapeOption option) { 47 | return clipRoundRectShape(srcBp, radius, scale, null, option); 48 | } 49 | 50 | @Override 51 | public Bitmap clipRoundRectShape(Bitmap srcBp, float radius, Rect rect, BitmapShapeOption option) { 52 | if (radius < 0) { 53 | radius = 0; 54 | } 55 | return clipRoundRectShape(srcBp, 56 | new float[]{radius, radius, radius, radius, radius, radius, radius, radius}, 57 | 1, rect, option); 58 | } 59 | 60 | @Override 61 | public Bitmap clipRoundRectShape(Bitmap srcBp, float[] radius, Rect rect, BitmapShapeOption option) { 62 | return clipRoundRectShape(srcBp, radius, 1, rect, option); 63 | } 64 | 65 | /** 66 | * 裁剪圆角矩形图片 67 | * 68 | * @param srcBp 源图片 69 | * @param radius 裁剪的圆角半径数组(上左;上右;下右;下左) 70 | * @param scale 裁剪比例 71 | * @param rect 裁剪图形所在矩形 72 | * @return 返回裁剪好的图片 73 | */ 74 | private Bitmap clipRoundRectShape(Bitmap srcBp, float[] radius, float scale, Rect rect, BitmapShapeOption option) { 75 | if (srcBp == null) { 76 | return null; 77 | } 78 | int width = srcBp.getWidth(); 79 | int height = srcBp.getHeight(); 80 | if (scale <= 0 || scale > 1) { 81 | scale = 1; 82 | } 83 | int wideLength = (int) (width * scale); 84 | int highLength = (int) (height * scale); 85 | if (rect != null) { 86 | wideLength = rect.width(); 87 | highLength = rect.height(); 88 | } 89 | Bitmap destBp = Bitmap.createBitmap(wideLength, highLength, Bitmap.Config.ARGB_8888); 90 | Canvas canvas = new Canvas(destBp); 91 | Rect srcRect = rect; 92 | if (rect == null) { 93 | srcRect = new Rect(); 94 | int left = (width - wideLength) / 2; 95 | int top = (height - highLength) / 2; 96 | srcRect.set(left, top, left + wideLength, top + highLength); 97 | } 98 | Rect destRect = new Rect(); 99 | destRect.set(0, 0, wideLength, highLength); 100 | Path path = null; 101 | if (radius != null) { 102 | path = new Path(); 103 | path.addRoundRect(new RectF(destRect), radius, Path.Direction.CW); 104 | BitmapUtils.clipPath(canvas, path, option); 105 | } 106 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 107 | canvas.drawBitmap(srcBp, srcRect, destRect, paint); 108 | BitmapUtils.drawShapeOption(canvas, paint, path, option); 109 | return destBp; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /bitmaphelper/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | --------------------------------------------------------------------------------