1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-13 10:29:35 +01:00

Added hi-res toolbar images

Hi-resolution images are saved with the "@2x.png" suffix, the image
loader will select the best image available based on the user selected
scaling.

Missing hi-res images can be added later together with lo-res images.
This commit is contained in:
Cristian Maglie 2015-12-30 13:45:47 +01:00
parent 5637130818
commit f1fc862575
14 changed files with 25 additions and 10 deletions

View File

@ -36,12 +36,14 @@ import cc.arduino.packages.DiscoveryManager;
import cc.arduino.view.Event;
import cc.arduino.view.JMenuUtils;
import cc.arduino.view.SplashScreenHelper;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils;
import processing.app.debug.TargetBoard;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
import processing.app.helpers.*;
import processing.app.helpers.FileUtils.SplitFile;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@ -2047,33 +2049,46 @@ public class Base {
/**
* Return an Image object from inside the Processing lib folder.
*/
static public Image getLibImage(String name, Component who) {
static public Image getLibImage(String filename, Component who) {
Toolkit tk = Toolkit.getDefaultToolkit();
SplitFile name = FileUtils.splitFilename(filename);
int scale = Theme.getInteger("gui.scalePercent");
// TODO: create high-res enlarged copies and load those if
// the scale is more than 125%
File imageLocation = new File(getContentFile("lib"), name);
Image image = tk.getImage(imageLocation.getAbsolutePath());
File libFolder = getContentFile("lib");
File imageFile1x = new File(libFolder, name.basename + "." + name.extension);
File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension);
File imageFile;
int sourceScale;
if ((scale > 125 && imageFile2x.exists()) || !imageFile1x.exists()) {
imageFile = imageFile2x;
sourceScale = 200;
} else {
imageFile = imageFile1x;
sourceScale = 100;
}
Image image = tk.getImage(imageFile.getAbsolutePath());
MediaTracker tracker = new MediaTracker(who);
tracker.addImage(image, 0);
try {
tracker.waitForAll();
} catch (InterruptedException e) {
}
if (scale != 100) {
int width = image.getWidth(null) * scale / 100;
int height = image.getHeight(null) * scale / 100;
if (scale != sourceScale) {
int width = image.getWidth(null) * scale / sourceScale;
int height = image.getHeight(null) * scale / sourceScale;
image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
tracker.addImage(image, 1);
try {
tracker.waitForAll();
} catch (InterruptedException e) { }
} catch (InterruptedException e) {
}
}
return image;
}
// ...................................................................

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B