-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from CameraKit/v1.1.0
v1.1.0
- Loading branch information
Showing
7 changed files
with
126 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
blurkit/src/main/java/io/alterac/blurkit/RoundedImageView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.alterac.blurkit; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.graphics.PorterDuff; | ||
import android.graphics.PorterDuffXfermode; | ||
import android.graphics.RectF; | ||
import android.graphics.Xfermode; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.util.AttributeSet; | ||
import android.widget.ImageView; | ||
|
||
public class RoundedImageView extends ImageView { | ||
|
||
private float mCornerRadius = 0; | ||
public static final int DEFAULT_COLOR = 0xff000000; | ||
public static final int DEFAULT_RGB = 0; | ||
|
||
private RectF rectF; | ||
private PorterDuffXfermode porterDuffXfermode; | ||
|
||
public RoundedImageView(Context context) { | ||
super(context, null); | ||
rectF = new RectF(); | ||
porterDuffXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); | ||
} | ||
|
||
public RoundedImageView(Context context, AttributeSet attributes) { | ||
super(context, attributes); | ||
rectF = new RectF(); | ||
porterDuffXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN); | ||
} | ||
|
||
@Override | ||
protected void onDraw(Canvas canvas) { | ||
Drawable myDrawable = getDrawable(); | ||
if (myDrawable!=null && myDrawable instanceof BitmapDrawable && mCornerRadius > 0) { | ||
rectF.set(myDrawable.getBounds()); | ||
int prevCount = canvas.saveLayer(rectF, null, Canvas.ALL_SAVE_FLAG); | ||
getImageMatrix().mapRect(rectF); | ||
|
||
Paint paint = ((BitmapDrawable) myDrawable).getPaint(); | ||
paint.setAntiAlias(true); | ||
paint.setColor(DEFAULT_COLOR); | ||
Xfermode prevMode = paint.getXfermode(); | ||
|
||
canvas.drawARGB(DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB); | ||
canvas.drawRoundRect(rectF, mCornerRadius, mCornerRadius, paint); | ||
|
||
paint.setXfermode(porterDuffXfermode); | ||
super.onDraw(canvas); | ||
|
||
paint.setXfermode(prevMode); | ||
canvas.restoreToCount(prevCount); | ||
} else { | ||
super.onDraw(canvas); | ||
} | ||
} | ||
|
||
public void setCornerRadius(float cornerRadius) { | ||
this.mCornerRadius = cornerRadius; | ||
} | ||
|
||
public float getCornerRadius() { | ||
return this.mCornerRadius; | ||
} | ||
} |
73 changes: 0 additions & 73 deletions
73
blurkit/src/main/java/io/alterac/blurkit/RoundedImageView.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters