mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Fix rendering of scaled images
This commit is contained in:
@@ -364,10 +364,6 @@ public class FLabel extends JLabel implements ILocalRepaint {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void setIcon(FSkin.SkinImage icon) {
|
||||
this.skin.setIcon(icon);
|
||||
}
|
||||
|
||||
//========== Methods
|
||||
/** @param b0   boolean */
|
||||
@@ -447,21 +443,31 @@ public class FLabel extends JLabel implements ILocalRepaint {
|
||||
return this.cmdRightClick;
|
||||
}
|
||||
|
||||
public void setIcon(FSkin.SkinImage icon) {
|
||||
this.skin.setIcon(icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
// Must be public.
|
||||
public void setIcon(final Icon i0) {
|
||||
if (i0 == null) { this.img = null; return; }
|
||||
// Will need image (not icon) for scaled and non-scaled.
|
||||
if (iconInBackground) { this.img = ((ImageIcon) i0).getImage(); }
|
||||
// Will need image if not in background, but scaled.
|
||||
else if (iconScaleAuto) { this.img = ((ImageIcon) i0).getImage(); }
|
||||
// If not in background, not scaled, can use original icon.
|
||||
else { super.setIcon(i0); }
|
||||
|
||||
if (img != null) {
|
||||
iw = img.getWidth(null);
|
||||
ih = img.getHeight(null);
|
||||
iar = ((double) iw) / ((double) ih);
|
||||
if (iconInBackground || iconScaleAuto) {
|
||||
if (i0 != null) {
|
||||
img = ((ImageIcon) i0).getImage();
|
||||
iw = img.getWidth(null);
|
||||
ih = img.getHeight(null);
|
||||
iar = ((double) iw) / ((double) ih);
|
||||
}
|
||||
else {
|
||||
img = null;
|
||||
iw = 0;
|
||||
ih = 0;
|
||||
iar = 0;
|
||||
}
|
||||
}
|
||||
else { // If not in background, not scaled, can use original icon.
|
||||
super.setIcon(i0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -855,7 +855,7 @@ public enum FSkin {
|
||||
|
||||
final Graphics2D g2d = resizedImage.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
g2d.drawImage(baseImage.image, 0, 0, w0, h0, 0, 0, baseImage.getWidth(), baseImage.getHeight(), null);
|
||||
g2d.drawImage(baseImage.image, 0, 0, w, h, 0, 0, baseImage.getWidth(), baseImage.getHeight(), null);
|
||||
g2d.dispose();
|
||||
|
||||
this.changeImage(resizedImage, null);
|
||||
|
||||
Reference in New Issue
Block a user