mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 11:47:01 +00:00
GraphicUtils.scaleImageIcon(): scale only if needed
This commit is contained in:
parent
7eb44ca4cc
commit
97beb604fc
@ -722,11 +722,17 @@ public final class GraphicUtils {
|
||||
public static ImageIcon scaleImageIcon(ImageIcon icon, int newHeight, int newWidth) {
|
||||
int height = icon.getIconHeight();
|
||||
int width = icon.getIconWidth();
|
||||
boolean resize = false;
|
||||
if (height > newHeight) {
|
||||
height = newHeight;
|
||||
resize = true;
|
||||
}
|
||||
if (width > newWidth) {
|
||||
width = newWidth;
|
||||
resize = true;
|
||||
}
|
||||
if (!resize) {
|
||||
return icon;
|
||||
}
|
||||
Image img = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
return new ImageIcon(img);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user