Skip to content

Commit

Permalink
Merge pull request #50 from pelli23/overload-setImage
Browse files Browse the repository at this point in the history
Overloaded setImage Method: usefull for downloaded images
  • Loading branch information
jamie-beardedhen committed Oct 15, 2014
2 parents d13eede + 31569af commit 38e3530
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,27 @@ public void setImage(int drawable)
invalidate();
requestLayout();
}

public void setImage(Bitmap bitmap)
{
float scale = getResources().getDisplayMetrics().density;

//convert image size to pixels
int widthPX = (int)((this.imageWidth * scale) + 0.5);
int heightPX = (int)((this.imageHeight * scale) + 0.5);

int paddingPX = (int)((this.padding * scale) + 0.5);

if(this.minimal == false)
{
widthPX = widthPX - (paddingPX * 2);
heightPX = heightPX - (paddingPX * 2);
}

Bitmap roundBitmap = ImageUtils.getCircleBitmap(bitmap, widthPX, heightPX);
image.setImageBitmap(roundBitmap);

invalidate();
requestLayout();
}
}

0 comments on commit 38e3530

Please sign in to comment.