From 1f3ebafd103bceef36b0c228afb432a14fafca96 Mon Sep 17 00:00:00 2001 From: Mark-225 Date: Sun, 23 Oct 2022 19:38:42 +0200 Subject: [PATCH] More accurate player head layers (#353) --- .../bluemap/common/plugin/skins/PlayerSkin.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkin.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkin.java index ea0d9728..5fee0fc7 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkin.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkin.java @@ -83,19 +83,21 @@ public void update(File storageFolder, File fallback) { } public BufferedImage createHead(BufferedImage skinTexture) { - BufferedImage head = new BufferedImage(8, 8, skinTexture.getType()); + BufferedImage head; BufferedImage layer1 = skinTexture.getSubimage(8, 8, 8, 8); BufferedImage layer2 = skinTexture.getSubimage(40, 8, 8, 8); try { + head = new BufferedImage(48, 48, BufferedImage.TYPE_INT_ARGB); Graphics2D g = head.createGraphics(); - g.drawImage(layer1, 0, 0, null); - g.drawImage(layer2, 0, 0, null); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + g.drawImage(layer1, 4, 4, 40, 40, null); + g.drawImage(layer2, 0, 0, 48, 48, null); } catch (Throwable t) { // There might be problems with headless servers when loading the graphics class, so we catch every exception and error on purpose here Logger.global.noFloodWarning("headless-graphics-fail", "Could not access Graphics2D to render player-skin texture. Try adding '-Djava.awt.headless=true' to your startup flags or ignore this warning."); - + head = new BufferedImage(8, 8, skinTexture.getType()); layer1.copyData(head.getRaster()); }