I want display user avatars in my app with round corners.
How can i make round corner on a existing images like http://www.roundpic.com/
If I understand correctly you want to actually change the image not just set the border to rounded border right?
To change the image do something like this:
<p>// do this code once in the application and reuse the globalMaskImage variable. You can create the mask image in photoshop to get anti-aliasing etc.</p>
<p>Image mask = Image.createImage(width, height); </p>
<p>Graphics g = mask.getGraphics(); </p>
<p>g.fillRect(0, 0, mask.getWidth(), mask.getHeight()); </p>
<p>g.fillRoundRect(0, 0, mask.getWidth(), mask.getHeight(), 12, 12); </p>
<p>globalMaskImage = mask.createMask();</p>
<p>// use this code when you want to round the image</p>
<p>Image roundedImage = squareImage.applyMask(globalMaskImage);</p>
Keep in mind that the rounded image will take up more space in RAM as a result and that the cost of rounding is expensive so don't do it in the renderer!
That is exactly what i wanted. It works fine
Thank you very much
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.