Skip to content

Commit

Permalink
#UPDATE 可以自行配置解析图像质量,默认为RGB_565
Browse files Browse the repository at this point in the history
#FIX 修复minScale初始化时无效的问题
#UPDATE 更新到2.1.2
  • Loading branch information
EvilBT committed Dec 31, 2018
1 parent 367e37f commit 6772287
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 35 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ Requires Android SDK version 10 or higher.
**Step 1.** Add the dependency
```
dependencies {
implementation 'xyz.zpayh:hdimageview:2.1.1'
implementation 'xyz.zpayh:hdimageview:2.1.2'
// 以下可以选用
// if you use Glide 4.x , you can compile :(如果你正在使用Glide4.0或以上的版本,你可以添加下面的库)
implementation 'xyz.zpayh:hdimageview-glide:2.0.0'
// if you use Glide 4.x , you can compile :(如果你正在使用Glide 4.0或以上的版本,你可以添加下面的库)
implementation 'xyz.zpayh:hdimageview-glide:2.1.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
// if you use Fresco 1.4.x , you can compile :(如果你正在使用Fresco1.4.0或以上的版本,你可以添加下面的库)
implementation 'com.facebook.fresco:imagepipeline:1.4.0'
// if you use Fresco 1.4.x , you can compile :(如果你正在使用Fresco 1.11.0或以上的版本,你可以添加下面的库)
implementation 'com.facebook.fresco:imagepipeline:1.11.0'
//... or
implementation 'com.facebook.fresco:fresco:1.4.0'
implementation 'com.facebook.fresco:fresco:1.11.0'
implementation 'xyz.zpayh:hdimageview-fresco:2.0.0'
implementation 'xyz.zpayh:hdimageview-fresco:2.1.2'
}
```
**Step 2.** Add the view to your layout XML
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
compile 'xyz.zpayh:sherlockadapter:1.0.9'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:28.0.0'
compile 'com.facebook.fresco:imagepipeline:1.4.0'
compile 'com.facebook.fresco:imagepipeline:1.11.0'
//compile project(':support-fresco')
//compile project(':support-glide')
//compile 'xyz.zpayh:hdimageview-glide:2.0.0'
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ publish {
userOrg = 'sherlock' //bintray注册的用户名
groupId = 'xyz.zpayh' //compile引用时的第1部分groupId
artifactId = 'hdimageview' //compile引用时的第2部分项目名
publishVersion = '2.1.1' //compile引用时的第3部分版本号
publishVersion = '2.1.2' //compile引用时的第3部分版本号
desc = 'This is a high-definition picture control that supports zooming'
website = 'https://github.com/EvilBT/HDImageView'
}
2 changes: 1 addition & 1 deletion library/src/main/java/xyz/zpayh/hdimage/HDImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class HDImageView extends View {

private float mMaxScale = 2F;

private float mMinScale = minScale();
private float mMinScale = 0.1F;

/**
* 加载更高分辨率的贴图之前达到的密度
Expand Down
31 changes: 14 additions & 17 deletions library/src/main/java/xyz/zpayh/hdimage/core/HDImageViewConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,13 @@

package xyz.zpayh.hdimage.core;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.media.ExifInterface;
import android.util.Log;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand All @@ -51,15 +44,6 @@
import xyz.zpayh.hdimage.datasource.interceptor.ResourceInterceptor;
import xyz.zpayh.hdimage.util.Preconditions;

import static android.os.Build.VERSION.SDK_INT;
import static xyz.zpayh.hdimage.datasource.BitmapDataSource.ASSET_SCHEME;
import static xyz.zpayh.hdimage.datasource.BitmapDataSource.FILE_SCHEME;
import static xyz.zpayh.hdimage.state.Orientation.ORIENTATION_0;
import static xyz.zpayh.hdimage.state.Orientation.ORIENTATION_180;
import static xyz.zpayh.hdimage.state.Orientation.ORIENTATION_270;
import static xyz.zpayh.hdimage.state.Orientation.ORIENTATION_90;
import static xyz.zpayh.hdimage.state.Orientation.ORIENTATION_EXIF;

/**
* 文 件 名: HDImageViewConfig
* 创 建 人: 陈志鹏
Expand All @@ -76,12 +60,14 @@ public class HDImageViewConfig {

private final List<Interceptor> mInterceptors;
private final List<OrientationInterceptor> mOrientationInterceptors;
private final Bitmap.Config mBitmapConfig;

public static Builder newBuilder(Context context){
return new Builder(context);
}

private HDImageViewConfig(Builder builder){
mBitmapConfig = builder.mBitmapConfig;
mScaleAnimationInterpolator = builder.mScaleAnimationInterpolator == null ?
new DecelerateInterpolator() : builder.mScaleAnimationInterpolator;
mTranslationAnimationInterpolator = builder.mTranslationAnimationInterpolator == null ?
Expand Down Expand Up @@ -172,16 +158,27 @@ public List<OrientationInterceptor> getOrientationInterceptors() {
return mOrientationInterceptors;
}

public Bitmap.Config getBitmapConfig() {
return mBitmapConfig;
}

public static class Builder {
private Interpolator mScaleAnimationInterpolator;
private Interpolator mTranslationAnimationInterpolator;
private Context mContext;
private List<Interceptor> mInterceptors;
private final List<OrientationInterceptor> mOrientationInterceptors;
private Bitmap.Config mBitmapConfig;
private Builder(Context context){
mContext = Preconditions.checkNotNull(context);
mInterceptors = new ArrayList<>();
mOrientationInterceptors = new ArrayList<>();
mBitmapConfig = Bitmap.Config.RGB_565;
}

public Builder setBitmapConfig(@NonNull Bitmap.Config config) {
mBitmapConfig = Preconditions.checkNotNull(config);
return this;
}

public Builder setScaleAnimationInterpolator(Interpolator scaleAnimationInterpolator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package xyz.zpayh.hdimage.core;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.animation.Interpolator;

import java.util.List;
Expand Down Expand Up @@ -87,4 +88,8 @@ public List<Interceptor> getDataSourceInterceptor(){
public List<OrientationInterceptor> getOrientationInterceptor() {
return mConfig.getOrientationInterceptors();
}

public Bitmap.Config getBitmapConfig() {
return mConfig.getBitmapConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public Bitmap decode(Rect sRect, int sampleSize) {
synchronized (mDecoderLock) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = sampleSize;
options.inPreferredConfig = Bitmap.Config.RGB_565;
// Default RGB_565
options.inPreferredConfig = HDImageViewFactory.getInstance().getBitmapConfig();
return mDecoder.decodeRegion(sRect, options);
}
}
Expand Down
8 changes: 4 additions & 4 deletions support-fresco/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:28.0.0'
testCompile 'junit:junit:4.12'
provided 'com.facebook.fresco:imagepipeline:1.4.0'
//provided 'xyz.zpayh:hdimageview:2.0.0'
compile project(':library')
provided 'com.facebook.fresco:imagepipeline:1.11.0'
provided 'xyz.zpayh:hdimageview:2.1.2'
//compile project(':library')
}

// jcenter configuration for novoda's bintray-release
Expand All @@ -60,7 +60,7 @@ dependencies {
userOrg = 'sherlock' //bintray注册的用户名
groupId = 'xyz.zpayh' //compile引用时的第1部分groupId
artifactId = 'hdimageview-fresco' //compile引用时的第2部分项目名
publishVersion = '2.0.0' //compile引用时的第3部分版本号
publishVersion = '2.1.2' //compile引用时的第3部分版本号
desc = 'This is a high-definition picture control that supports zooming'
website = 'https://github.com/EvilBT/HDImageView'
}*/
6 changes: 3 additions & 3 deletions support-glide/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:28.0.0'
testCompile 'junit:junit:4.12'
//provided 'xyz.zpayh:hdimageview:2.0.0'
compile project(':library')
provided 'xyz.zpayh:hdimageview:2.1.2'
//compile project(':library')
provided 'com.github.bumptech.glide:glide:4.8.0'
}

Expand All @@ -60,7 +60,7 @@ dependencies {
userOrg = 'sherlock' //bintray注册的用户名
groupId = 'xyz.zpayh' //compile引用时的第1部分groupId
artifactId = 'hdimageview-glide' //compile引用时的第2部分项目名
publishVersion = '2.0.0' //compile引用时的第3部分版本号
publishVersion = '2.1.2' //compile引用时的第3部分版本号
desc = 'This is a high-definition picture control that supports zooming'
website = 'https://github.com/EvilBT/HDImageView'
}*/

0 comments on commit 6772287

Please sign in to comment.