forked from External/mage
Fixed that the flag on avatar image could be to big.
This commit is contained in:
parent
ad4b68dcb5
commit
f87c5bbbec
2 changed files with 17 additions and 2 deletions
|
|
@ -27,7 +27,6 @@ public class CountryUtil {
|
|||
public static ImageIcon getCountryFlagIcon(String countryCode) {
|
||||
ImageIcon flagIcon = FLAG_ICON_CACHE.get(countryCode);
|
||||
if (flagIcon == null) {
|
||||
// URL url = CountryUtil.class.getResource("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
Image flagImage = ImageHelper.getImageFromResources("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
if (flagImage != null) {
|
||||
if (GUISizeHelper.flagHeight > 11) {
|
||||
|
|
@ -48,6 +47,22 @@ public class CountryUtil {
|
|||
return flagIcon;
|
||||
}
|
||||
|
||||
public static ImageIcon getCountryFlagIconSize(String countryCode, int height) {
|
||||
ImageIcon flagIcon = null;
|
||||
Image flagImage = ImageHelper.getImageFromResources("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
if (flagImage != null) {
|
||||
|
||||
if (height > 11) {
|
||||
int width = Math.round(height * flagImage.getWidth(null) / flagImage.getHeight(null));
|
||||
BufferedImage resized = ImageHelper.scale((BufferedImage) flagImage, BufferedImage.TYPE_4BYTE_ABGR, width, height);
|
||||
flagIcon = new ImageIcon(resized);
|
||||
} else {
|
||||
flagIcon = new ImageIcon(flagImage);
|
||||
}
|
||||
}
|
||||
return flagIcon;
|
||||
}
|
||||
|
||||
public static void changeGUISize() {
|
||||
FLAG_ICON_CACHE.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue