|
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; |
@@ -2047,33 +2049,46 @@ static public Image getThemeImage(String name, Component who) { |
2047 | 2049 | /** |
2048 | 2050 | * Return an Image object from inside the Processing lib folder. |
2049 | 2051 | */ |
2050 | | - static public Image getLibImage(String name, Component who) { |
| 2052 | + static public Image getLibImage(String filename, Component who) { |
2051 | 2053 | Toolkit tk = Toolkit.getDefaultToolkit(); |
2052 | 2054 |
|
| 2055 | + SplitFile name = FileUtils.splitFilename(filename); |
2053 | 2056 | int scale = Theme.getInteger("gui.scalePercent"); |
2054 | | - // TODO: create high-res enlarged copies and load those if |
2055 | | - // the scale is more than 125% |
2056 | | - File imageLocation = new File(getContentFile("lib"), name); |
2057 | | - Image image = tk.getImage(imageLocation.getAbsolutePath()); |
| 2057 | + File libFolder = getContentFile("lib"); |
| 2058 | + File imageFile1x = new File(libFolder, name.basename + "." + name.extension); |
| 2059 | + File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension); |
| 2060 | + |
| 2061 | + File imageFile; |
| 2062 | + int sourceScale; |
| 2063 | + if ((scale > 125 && imageFile2x.exists()) || !imageFile1x.exists()) { |
| 2064 | + imageFile = imageFile2x; |
| 2065 | + sourceScale = 200; |
| 2066 | + } else { |
| 2067 | + imageFile = imageFile1x; |
| 2068 | + sourceScale = 100; |
| 2069 | + } |
| 2070 | + |
| 2071 | + Image image = tk.getImage(imageFile.getAbsolutePath()); |
2058 | 2072 | MediaTracker tracker = new MediaTracker(who); |
2059 | 2073 | tracker.addImage(image, 0); |
2060 | 2074 | try { |
2061 | 2075 | tracker.waitForAll(); |
2062 | 2076 | } catch (InterruptedException e) { |
2063 | 2077 | } |
2064 | | - if (scale != 100) { |
2065 | | - int width = image.getWidth(null) * scale / 100; |
2066 | | - int height = image.getHeight(null) * scale / 100; |
| 2078 | + |
| 2079 | + if (scale != sourceScale) { |
| 2080 | + int width = image.getWidth(null) * scale / sourceScale; |
| 2081 | + int height = image.getHeight(null) * scale / sourceScale; |
2067 | 2082 | image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); |
2068 | 2083 | tracker.addImage(image, 1); |
2069 | 2084 | try { |
2070 | 2085 | tracker.waitForAll(); |
2071 | | - } catch (InterruptedException e) { } |
| 2086 | + } catch (InterruptedException e) { |
| 2087 | + } |
2072 | 2088 | } |
2073 | 2089 | return image; |
2074 | 2090 | } |
2075 | 2091 |
|
2076 | | - |
2077 | 2092 | // ................................................................... |
2078 | 2093 |
|
2079 | 2094 |
|
|
0 commit comments