modify picture resource to rounded rectangle borde

2019-09-05 02:04发布

问题:

Before modifing

after modyfing

just as we can see,i want to achieve it by code.I have searched many materials ,but they are just making a rounded rectangle by their own color,not form one picture.Any help will be very appreciated.

回答1:

I made a method for doing this which takes an original pixmap (image) and combines it with a mask to crop the original image to the shape of the mask. I posted the code in a question here:

libGDX: How can I crop Texture as a circle

In your case the mask should be a rounded rectangle. It doesn't matter what the color of the mask is as long as the alpha channel is "1". Then the result will be your original image cropped to the rounded rectangle.