Skip to content

Commit

Permalink
检测边长等阈值
Browse files Browse the repository at this point in the history
  • Loading branch information
wzgl5533 committed Sep 23, 2018
1 parent e812550 commit 7392808
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

9 changes: 5 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@
app:cv_outer_bg_color="@color/black_alpha_160"
app:cv_scan_line_color="@color/white"
app:cv_scan_line_width="1dp"
app:cv_border_length="247dp"
app:cv_border_length="100dp"
app:cv_border_line_width="1dp"
app:cv_corner_line_with="3dp"
app:cv_corner_line_height="13dp"
app:cv_min_border_length="100dp"
app:cv_crop_model="oval"
app:cv_min_border_length="45dp"
app:cv_crop_model="circle"
app:cv_is_show_corner_line="true"
app:cv_is_show_border_line="true"
app:cv_is_show_middle_line="true"
app:cv_is_show_scan_line="false"
app:cv_is_touch_corner_line_scale="true"
app:cv_is_touch_middle_line_scale="true"/>
app:cv_is_touch_middle_line_scale="true"
/>

</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static Bitmap getCropPicture(Bitmap bitmap, float preWidth, float preHeig
*/
public static Bitmap getCircularBitmap(Bitmap square) {
if (square == null) return null;
Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_8888);
Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_4444);

final Rect rect = new Rect(0, 0, square.getWidth(), square.getHeight());
Canvas canvas = new Canvas(output);
Expand All @@ -86,7 +86,7 @@ public static Bitmap getCircularBitmap(Bitmap square) {
*/
public static Bitmap getOvalBitmap(Bitmap square) {
if (square == null) return null;
Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_8888);
Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_4444);

final Rect rect = new Rect(0, 0, square.getWidth(), square.getHeight());
Canvas canvas = new Canvas(output);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.qlh.crop.cropviewlibrary.utils;


import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.view.WindowManager;

import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -280,4 +285,49 @@ public static void changePositions(int point, int offsetX, int offsetY, float[][
break;
}
}

/**
* 判断字符串是否为空,即为null或""
*/
public static boolean isEmpty(String str) {
return ((str == null) || (str.length() == 0) || "null".equals(str));
}

/**
* Return the width of screen, in pixel.
*
* @return the width of screen, in pixel
*/
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) {
return context.getResources().getDisplayMetrics().widthPixels;
}
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
wm.getDefaultDisplay().getRealSize(point);
} else {
wm.getDefaultDisplay().getSize(point);
}
return point.x;
}

/**
* Return the height of screen, in pixel.
*
* @return the height of screen, in pixel
*/
public static int getScreenHeight(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) {
return context.getResources().getDisplayMetrics().heightPixels;
}
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
wm.getDefaultDisplay().getRealSize(point);
} else {
wm.getDefaultDisplay().getSize(point);
}
return point.y;
}
}
Loading

0 comments on commit 7392808

Please sign in to comment.