-
-
Save folivares/00fffd8b9388e65a3660 to your computer and use it in GitHub Desktop.
Revisions
-
folivares revised this gist
Jul 7, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,6 +38,13 @@ public class CircularNetworkImageView extends NetworkImageView { getCircularBitmap(bm))); } @Override public void setImageResource(int resId) { Bitmap circularImage = BitmapFactory.decodeResource(getResources(), resId); setImageBitmap(circularImage); } /** * Creates a circular bitmap and uses whichever dimension is smaller to determine the width * <br/>Also constrains the circle to the leftmost part of the image -
bkurzius revised this gist
Nov 7, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public class CircularNetworkImageView extends NetworkImageView { /** * Creates a circular bitmap and uses whichever dimension is smaller to determine the width * <br/>Also constrains the circle to the leftmost part of the image * * @param bitmap * @return bitmap -
bkurzius revised this gist
Nov 7, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import android.graphics.PorterDuff.Mode; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import com.android.volley.toolbox.NetworkImageView; public class CircularNetworkImageView extends NetworkImageView { -
bkurzius revised this gist
Nov 7, 2014 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; -
bkurzius revised this gist
Nov 7, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ package org.imemorize.widgets; import android.content.Context; import android.graphics.Bitmap; -
bkurzius revised this gist
Nov 7, 2014 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ package com.aetn.history.android.historyhere.widgets; import android.content.Context; import android.graphics.Bitmap; @@ -36,12 +36,14 @@ public class CircularNetworkImageView extends NetworkImageView { @Override public void setImageBitmap(Bitmap bm) { if(bm==null) return; setImageDrawable(new BitmapDrawable(mContext.getResources(), getCircularBitmap(bm))); } /** * Creates a circular bitmap and uses whichever dimension is smaller to determine the width * <br/>Also onstrains the circle to the leftmost part of that image * * @param bitmap * @return bitmap @@ -50,14 +52,13 @@ public class CircularNetworkImageView extends NetworkImageView { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); int width = bitmap.getWidth(); if(bitmap.getWidth()>bitmap.getHeight()) width = bitmap.getHeight(); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, width, width); final RectF rectF = new RectF(rect); final float roundPx = width / 2; paint.setAntiAlias(true); -
bkurzius renamed this gist
Nov 7, 2014 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,10 @@ public class CircularNetworkImageView extends NetworkImageView { final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); int width = bitmap.getWidth(); if(bitmap.getWidth()>bitmap.getHeight()) width = bitmap.getHeight(); final float roundPx = width / 2; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); -
bkurzius created this gist
Nov 7, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ package org.imemorize.widgets; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Bitmap.Config; import android.graphics.PorterDuff.Mode; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import com.aetn.history.android.historyhere.utils.ImageUtils; import com.android.volley.toolbox.NetworkImageView; public class CircularNetworkImageView extends NetworkImageView { Context mContext; public CircularNetworkImageView(Context context) { super(context); mContext = context; } public CircularNetworkImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); mContext = context; } public CircularNetworkImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context; } @Override public void setImageBitmap(Bitmap bm) { setImageDrawable(new BitmapDrawable(mContext.getResources(), getCircularBitmap(bm))); } /** * creates a circular bitmap using the width of the image as the constrainer * * @param bitmap * @return bitmap */ public Bitmap getCircularBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = bitmap.getWidth() / 2; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } }