emilianbold commented on a change in pull request #1278: [NETBEANS-2604]
Support SVG icon loading from ImageUtilities
URL: https://github.com/apache/netbeans/pull/1278#discussion_r289608706
##########
File path: platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
##########
@@ -858,66 +1097,71 @@ public int getIconWidth() {
}
public void paintIcon(Component c, Graphics g, int x, int y) {
- g.drawImage(this, x, y, null);
+ if (delegateIcon != null) {
+ delegateIcon.paintIcon(c, g, x, y);
+ } else {
+ /* There is no scalable delegate icon available. On HiDPI
displays, this means that
+ original low-resolution icons will need to be scaled up to a
higher resolution. Do a
+ few tricks here to improve the quality of the scaling. See
NETBEANS-2614 and the
+ before/after screenshots that are attached to said JIRA
ticket. */
+ Graphics2D g2 = (Graphics2D) g.create();
+ try {
+ final AffineTransform tx = g2.getTransform();
+ final int txType = tx.getType();
+ final double scale;
+ if (txType == AffineTransform.TYPE_UNIFORM_SCALE ||
+ txType == (AffineTransform.TYPE_UNIFORM_SCALE |
AffineTransform.TYPE_TRANSLATION))
+ {
+ scale = tx.getScaleX();
+ } else {
+ scale = 1.0;
+ }
+ if (scale != 1.0) {
+ /* The default interpolation mode is nearest neighbor.
Use bicubic
+ interpolation instead, which looks better, especially
with non-integral
+ HiDPI scaling factors (e.g. 150%). Even for an
integral 2x scaling factor
+ (used by all Retina displays on MacOS), the blurred
appearance of bicubic
+ scaling ends up looking better on HiDPI displays than
the blocky appearance
+ of nearest neighbor. */
Review comment:
:-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists