piegamesde / BlockMap

An out-of-game map renderer and viewer for Minecraft 1.13–1.18 worlds [unmaintained]
MIT License
92 stars 22 forks source link

Fix blurry player skin #49

Closed saibotk closed 3 years ago

saibotk commented 3 years ago

This commit fixes the weird blurry textures for player heads, as seen in #48

To fix the blurry images, we first need to set the requested width / height in the image constructor and also set the smoot parameter to false, which can only be set, when using the constructor. As we just want a small part of the image (only the head), we need to scale the whole image by 16x, so that we can later extract the head with a resolution of 128 pixels, that will be scaled correctly (pixel-perfect, without smoothing). The scaling without smoothing, seems to only work this way, as the "smooth" parameter cannot be set/changed when using another constructor/later. Another option would be sampling the image with the PixelReader and creating a new Image with the PixelWriter by hand.

More information can be found here: https://stackoverflow.com/a/16092631