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
|
//========== Methods
|
||||||
/** @param b0   boolean */
|
/** @param b0   boolean */
|
||||||
@@ -447,21 +443,31 @@ public class FLabel extends JLabel implements ILocalRepaint {
|
|||||||
return this.cmdRightClick;
|
return this.cmdRightClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIcon(FSkin.SkinImage icon) {
|
||||||
|
this.skin.setIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Must be public.
|
// Must be public.
|
||||||
public void setIcon(final Icon i0) {
|
public void setIcon(final Icon i0) {
|
||||||
if (i0 == null) { this.img = null; return; }
|
|
||||||
// Will need image (not icon) for scaled and non-scaled.
|
// 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.
|
// Will need image if not in background, but scaled.
|
||||||
else if (iconScaleAuto) { this.img = ((ImageIcon) i0).getImage(); }
|
if (iconInBackground || iconScaleAuto) {
|
||||||
// If not in background, not scaled, can use original icon.
|
if (i0 != null) {
|
||||||
else { super.setIcon(i0); }
|
img = ((ImageIcon) i0).getImage();
|
||||||
|
iw = img.getWidth(null);
|
||||||
if (img != null) {
|
ih = img.getHeight(null);
|
||||||
iw = img.getWidth(null);
|
iar = ((double) iw) / ((double) ih);
|
||||||
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();
|
final Graphics2D g2d = resizedImage.createGraphics();
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
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();
|
g2d.dispose();
|
||||||
|
|
||||||
this.changeImage(resizedImage, null);
|
this.changeImage(resizedImage, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user