Skip to content

Commit

Permalink
增加锚点颜色及宽度修改
Browse files Browse the repository at this point in the history
  • Loading branch information
bingming.yu committed Aug 16, 2018
1 parent 7b60a72 commit c664ca0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class CropImageView extends ImageView {

Point[] mCropPoints; // 裁剪区域
float mLineWidth; // 选区线的宽度
int mPointColor; //锚点颜色
float mPointWidth; //锚点宽度
float mGuideLineWidth; // 辅助线宽度
int mPointFillColor = DEFAULT_POINT_FILL_COLOR; // 锚点内部填充颜色
int mPointFillAlpha = DEFAULT_POINT_FILL_ALPHA; // 锚点填充颜色透明度
Expand Down Expand Up @@ -107,6 +109,8 @@ private void initAttrs(Context context, AttributeSet attrs) {
mShowGuideLine = ta.getBoolean(R.styleable.CropImageView_civShowGuideLine, true);
mLineColor = ta.getColor(R.styleable.CropImageView_civLineColor, DEFAULT_LINE_COLOR);
mLineWidth = ta.getDimension(R.styleable.CropImageView_civLineWidth, dp2px(DEFAULT_LINE_WIDTH));
mPointColor = ta.getColor(R.styleable.CropImageView_civPointColor, DEFAULT_LINE_COLOR);
mPointWidth = ta.getDimension(R.styleable.CropImageView_civPointWidth, dp2px(DEFAULT_LINE_WIDTH));
mMagnifierCrossColor = ta.getColor(R.styleable.CropImageView_civMagnifierCrossColor, DEFAULT_MAGNIFIER_CROSS_COLOR);
mShowMagnifier = ta.getBoolean(R.styleable.CropImageView_civShowMagnifier, true);
mGuideLineWidth = ta.getDimension(R.styleable.CropImageView_civGuideLineWidth, dp2px(DEFAULT_GUIDE_LINE_WIDTH));
Expand Down Expand Up @@ -245,6 +249,16 @@ public void setLineWidth(int lineWidth) {
invalidate();
}

public void setPointColor(int pointColor) {
this.mPointColor = pointColor;
invalidate();
}

public void setPointWidth(float pointWidth) {
this.mPointWidth = pointWidth;
invalidate();
}

/**
* 设置是否显示放大镜
* @param showMagnifier 是否
Expand Down Expand Up @@ -326,8 +340,8 @@ public Bitmap getBitmap() {

private void initPaints() {
mPointPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPointPaint.setColor(mLineColor);
mPointPaint.setStrokeWidth(mLineWidth);
mPointPaint.setColor(mPointColor);
mPointPaint.setStrokeWidth(mPointWidth);
mPointPaint.setStyle(Paint.Style.STROKE);

mPointFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Expand Down
2 changes: 2 additions & 0 deletions smartcropperlib/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<attr name="civGuideLineColor" format="color"/>
<attr name="civPointFillColor" format="color"/>
<attr name="civPointFillAlpha" format="integer"/>
<attr name="civPointColor" format="color"/>
<attr name="civPointWidth" format="dimension"/>
</declare-styleable>

</resources>

0 comments on commit c664ca0

Please sign in to comment.