Skip to content

Instantly share code, notes, and snippets.

@TheNewHEROBRINEX
Created February 4, 2017 20:45
Show Gist options
  • Save TheNewHEROBRINEX/2c74a21473369da9b95fe6720bc88c1c to your computer and use it in GitHub Desktop.
Save TheNewHEROBRINEX/2c74a21473369da9b95fe6720bc88c1c to your computer and use it in GitHub Desktop.
<?php
$skindata = base64_decode(file_get_contents("/Users/luca/Desktop/skindata.txt"));
$colors = str_split($skindata, 4);
$height = count($colors) / 64;
$skin = imagecreatetruecolor(64, $height);
$allocatedColors = array();
foreach ($colors as $color) {
str_split($color);
$red = hexdec(bin2hex($color[0]));
$green = hexdec(bin2hex($color[1]));
$blue = hexdec(bin2hex($color[2]));
$allocatedColors[] = imagecolorallocate($skin, $red, $green, $blue);
}
for ($y = 0; $y < $height; $y++) {
for ($x = 0; $x < 64; $x++) {
$color = array_shift($allocatedColors);
imagesetpixel($skin, $x, $y, $color);
}
}
imagecolortransparent($skin, imagecolorallocate($skin, 0, 0, 0));
imagepng($skin, "/Users/luca/Desktop/skin.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment