|
36 | 36 | import cc.arduino.view.Event;
|
37 | 37 | import cc.arduino.view.JMenuUtils;
|
38 | 38 | import cc.arduino.view.SplashScreenHelper;
|
| 39 | + |
39 | 40 | import org.apache.commons.compress.utils.IOUtils;
|
40 | 41 | import org.apache.commons.lang3.StringUtils;
|
41 | 42 | import processing.app.debug.TargetBoard;
|
42 | 43 | import processing.app.debug.TargetPackage;
|
43 | 44 | import processing.app.debug.TargetPlatform;
|
44 | 45 | import processing.app.helpers.*;
|
| 46 | +import processing.app.helpers.FileUtils.SplitFile; |
45 | 47 | import processing.app.helpers.filefilters.OnlyDirs;
|
46 | 48 | import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
47 | 49 | import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
|
@@ -2059,33 +2061,46 @@ static public Image getThemeImage(String name, Component who) {
|
2059 | 2061 | /**
|
2060 | 2062 | * Return an Image object from inside the Processing lib folder.
|
2061 | 2063 | */
|
2062 |
| - static public Image getLibImage(String name, Component who) { |
| 2064 | + static public Image getLibImage(String filename, Component who) { |
2063 | 2065 | Toolkit tk = Toolkit.getDefaultToolkit();
|
2064 | 2066 |
|
| 2067 | + SplitFile name = FileUtils.splitFilename(filename); |
2065 | 2068 | int scale = Theme.getInteger("gui.scalePercent");
|
2066 |
| - // TODO: create high-res enlarged copies and load those if |
2067 |
| - // the scale is more than 125% |
2068 |
| - File imageLocation = new File(getContentFile("lib"), name); |
2069 |
| - Image image = tk.getImage(imageLocation.getAbsolutePath()); |
| 2069 | + File libFolder = getContentFile("lib"); |
| 2070 | + File imageFile1x = new File(libFolder, name.basename + "." + name.extension); |
| 2071 | + File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension); |
| 2072 | + |
| 2073 | + File imageFile; |
| 2074 | + int sourceScale; |
| 2075 | + if ((scale > 125 && imageFile2x.exists()) || !imageFile1x.exists()) { |
| 2076 | + imageFile = imageFile2x; |
| 2077 | + sourceScale = 200; |
| 2078 | + } else { |
| 2079 | + imageFile = imageFile1x; |
| 2080 | + sourceScale = 100; |
| 2081 | + } |
| 2082 | + |
| 2083 | + Image image = tk.getImage(imageFile.getAbsolutePath()); |
2070 | 2084 | MediaTracker tracker = new MediaTracker(who);
|
2071 | 2085 | tracker.addImage(image, 0);
|
2072 | 2086 | try {
|
2073 | 2087 | tracker.waitForAll();
|
2074 | 2088 | } catch (InterruptedException e) {
|
2075 | 2089 | }
|
2076 |
| - if (scale != 100) { |
2077 |
| - int width = image.getWidth(null) * scale / 100; |
2078 |
| - int height = image.getHeight(null) * scale / 100; |
| 2090 | + |
| 2091 | + if (scale != sourceScale) { |
| 2092 | + int width = image.getWidth(null) * scale / sourceScale; |
| 2093 | + int height = image.getHeight(null) * scale / sourceScale; |
2079 | 2094 | image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
2080 | 2095 | tracker.addImage(image, 1);
|
2081 | 2096 | try {
|
2082 | 2097 | tracker.waitForAll();
|
2083 |
| - } catch (InterruptedException e) { } |
| 2098 | + } catch (InterruptedException e) { |
| 2099 | + } |
2084 | 2100 | }
|
2085 | 2101 | return image;
|
2086 | 2102 | }
|
2087 | 2103 |
|
2088 |
| - |
2089 | 2104 | // ...................................................................
|
2090 | 2105 |
|
2091 | 2106 |
|
|
0 commit comments