Liquidz
Liquidz

Reputation: 283

libgdx Resizing an Image with Border

i have an image with a 5px black border what i will use for serveral buttons. The only problem is, that the buttons have different sizes. Is there a way to resize it properly? The only way i can figure it out, is to split it in individually pieces.

Eg.: The Image is 200x200 and the Button 200x200 -> Border is ok. The Image is 200x200 (the same) and the button 400x200 -> Border is stretched.

Upvotes: 1

Views: 153

Answers (2)

Liquidz
Liquidz

Reputation: 283

After the last Months i´ve learned very much about libgdx and i must say that the use of ninepatches are the best solution.

See here to learn more about 9patch in libGDX

Upvotes: 0

Netero
Netero

Reputation: 3819

resize an image to diffrerent image ratio without stretch i don't know i someting like taht could exist , but here what i will do to solve your problem

this is your what is happening enter image description here

to solve this i would use an image border full black and draw it under the image like the picture enter image description here when re-size it instead of 400X200 i will decrease it with a little margin like 380x200

hope this was clear and helpfull

Upvotes: 1

Related Questions