public ImageIcon getMinecraftSkin() { File file = null; if (isReal()) { file = new File(App.settings.getSkinsDir(), minecraftUsername + ".png"); if (!file.exists()) { updateSkin(); } } if (file == null || !file.exists()) { file = new File(App.settings.getSkinsDir(), "default.png"); } BufferedImage image = null; try { image = ImageIO.read(file); } catch (IOException e) { App.settings.logStackTrace(e); } BufferedImage head = image.getSubimage(8, 8, 8, 8); BufferedImage helmet = image.getSubimage(40, 8, 8, 8); BufferedImage arm = image.getSubimage(44, 20, 4, 12); BufferedImage body = image.getSubimage(20, 20, 8, 12); BufferedImage leg = image.getSubimage(4, 20, 4, 12); BufferedImage skin = new BufferedImage(16, 32, BufferedImage.TYPE_INT_ARGB); int count = 0; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { if (helmet.getRGB(x, y) == -1) { count++; } } } Graphics g = skin.getGraphics(); g.drawImage(head, 4, 0, null); if (count <= 32) { g.drawImage(helmet, 4, 0, null); } g.drawImage(arm, 0, 8, null); g.drawImage(arm, 12, 8, null); g.drawImage(body, 4, 8, null); g.drawImage(leg, 4, 20, null); g.drawImage(leg, 8, 20, null); ImageIcon icon = new ImageIcon(skin.getScaledInstance(128, 256, Image.SCALE_SMOOTH)); return icon; }
public ImageIcon getMinecraftHead() { File file = null; if (isReal()) { file = new File(App.settings.getSkinsDir(), minecraftUsername + ".png"); if (!file.exists()) { updateSkin(); } } if (file == null || !file.exists()) { file = new File(App.settings.getSkinsDir(), "default.png"); } BufferedImage image = null; try { image = ImageIO.read(file); } catch (IOException e) { App.settings.logStackTrace(e); } BufferedImage main = image.getSubimage(8, 8, 8, 8); BufferedImage helmet = image.getSubimage(40, 8, 8, 8); BufferedImage head = new BufferedImage(8, 8, BufferedImage.TYPE_INT_ARGB); int count = 0; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { if (helmet.getRGB(x, y) == -1) { count++; } } } Graphics g = head.getGraphics(); g.drawImage(main, 0, 0, null); if (count <= 32) { g.drawImage(helmet, 0, 0, null); } ImageIcon icon = new ImageIcon(head.getScaledInstance(32, 32, Image.SCALE_SMOOTH)); return icon; }