Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capes being scaled wrong and invisible skins #1940

Merged
merged 5 commits into from
Mar 3, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,38 @@ private static byte[] requestImage(String imageUrl, CapeProvider provider) throw

// if the requested image is a cape
if (provider != null) {
// Scale capes based on size
BufferedImage newImage;
if (image.getWidth() > 64) {
image = scale(image, 64, 32);
newImage = new BufferedImage(128, 64, BufferedImage.TYPE_INT_ARGB);
Graphics g = newImage.createGraphics();
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
g.dispose();
newImage = scale(newImage, 64, 32);
} else {
newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_ARGB);
rtm516 marked this conversation as resolved.
Show resolved Hide resolved
Graphics g = newImage.createGraphics();
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
g.dispose();
}

image.flush();
image = newImage;
} else {
// Very rarely, skins can be larger than Minecraft's default.
// Bedrock will not render anything above a width of 128.
if (image.getWidth() > 128) {
image = scale(image, 128, image.getHeight() / (image.getWidth() / 128));
}

// Remove alpha from skins to replicate how java displays
BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = newImage.createGraphics();
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
g.dispose();

image.flush();
image = newImage;
rtm516 marked this conversation as resolved.
Show resolved Hide resolved
Camotoy marked this conversation as resolved.
Show resolved Hide resolved
}

byte[] data = bufferedImageToImageData(image);
Expand Down