modify picture resource to rounded rectangle border in libgdx

倖福魔咒の 提交于 2020-01-25 20:04:57

问题


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.



来源:https://stackoverflow.com/questions/37716128/modify-picture-resource-to-rounded-rectangle-border-in-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!