3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Update SkinProvider.java

Instead of calling the scale method 3 times, just used a cached scaled image
Dieser Commit ist enthalten in:
OnlyBMan 2019-12-15 19:24:00 -05:00
Ursprung 16950bf8f2
Commit 203b3b9d46

Datei anzeigen

@ -162,6 +162,7 @@ public class SkinProvider {
private static byte[] requestImage(String imageUrl, boolean cape) throws Exception { private static byte[] requestImage(String imageUrl, boolean cape) throws Exception {
BufferedImage image = ImageIO.read(new URL(imageUrl)); BufferedImage image = ImageIO.read(new URL(imageUrl));
BufferedImage scale = scale(image);
Geyser.getLogger().debug("Downloaded " + imageUrl); Geyser.getLogger().debug("Downloaded " + imageUrl);
if (cape && image.getWidth() <= 64) { if (cape && image.getWidth() <= 64) {
@ -174,7 +175,7 @@ public class SkinProvider {
else if(cape && image.getWidth() >= 64 && image.getWidth() <= 128) { else if(cape && image.getWidth() >= 64 && image.getWidth() <= 128) {
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB); BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
Graphics g = newImage.createGraphics(); Graphics g = newImage.createGraphics();
g.drawImage(scale(image), 0, 0, scale(image).getWidth(), scale(image).getHeight(), null); g.drawImage(scale, 0, 0, scale.getWidth(), scale.getHeight(), null);
g.dispose(); g.dispose();
image = newImage; image = newImage;
} }