Posted By

m3000 on 09/05/17


Tagged

bitmap #circular


Versions (?)

Make circuar bitmap


 / Published in: Java
 

this is the code to make the circular bitmap and use it in the image views and other viewers in android technology. at the end of the code the circle mode of bitmap is created by the en um Mode.

  1. private Bitmap getCircleBitmap(Bitmap bitmap) {
  2. final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
  3. bitmap.getHeight(), Bitmap.Config.ARGB_8888);
  4. final Canvas canvas = new Canvas(output);
  5.  
  6. final int color = Color.RED;
  7. final Paint paint = new Paint();
  8. final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
  9. final RectF rectF = new RectF(rect);
  10.  
  11. paint.setAntiAlias(true);
  12. canvas.drawARGB(0, 0, 0, 0);
  13. paint.setColor(color);
  14. canvas.drawOval(rectF, paint);
  15.  
  16. paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  17. canvas.drawBitmap(bitmap, rect, rect, paint);
  18.  
  19. bitmap.recycle();
  20.  
  21. return output;
  22. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: DylanParker on October 17, 2017

Thank you for sharing. Here's another code to achieve the roundedImageview: ImageView profilePic = (ImageView) findViewById (R.id.userimage); // get bitmap of the image Bitmap imageBitmap = BitmapFactory.decodeResource (getResources (), R.drawable.largeicon); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create (getResources (), imageBitmap); // setting radius roundedBitmapDrawable.setCornerRadius (50.0f); roundedBitmapDrawable.setAntiAlias (true); profilePic.setImageDrawable (roundedBitmapDrawable). more you can find on my website.

Posted By: fin337sun on November 8, 2017

https://speedypaper.com/paraphrasing-rewriting - this is not just a link. It can rescue every student who seeks help with his or her writing assignment. Save and share it!

Posted By: fin337sun on November 8, 2017

https://speedypaper.com/paraphrasing-rewriting - this is not just a link. It can rescue every student who seeks help with his or her writing assignment. Save and share it!

Posted By: KerryWin89 on November 9, 2017

Thanks for sharing this information! Useful for my https://rocketpaper.net/global-warming-essay-writing and other essay topics at all.

Posted By: KerryWin89 on November 9, 2017

Thanks for sharing this information! Useful for my [url]https://rocketpaper.net/global-warming-essay-writing[url] and other essay topics at all.

Posted By: KerryWin89 on November 9, 2017

Thanks for sharing this information! Useful for my and other essay topics at all.

Posted By: KerryWin89 on November 9, 2017

Thanks for sharing this information! Useful for my

Posted By: John32 on November 17, 2017

All paper writing companies try to assure you in providing the best services to attract as many college students as possible. Of course, there are services that keep their promise. However, there are also services that do not care about delivering quality essay help but only want to get your money. Read the detailed ultius review in order to not be scammed.

You need to login to post a comment.