"; imagecopyresized($image,$add,$xoffset,$yoffset,0,0,$width,$height,imagesx($add),imagesy($add)); imageDestroy($add); } } function mergeDesaturate($image,$add,$saturation = 0,$hue = 0,$stretch,$xoffset = 0,$yoffset = 0,$wstretch = 0) { if (file_exists($add)) { //300: Purple //240 - 280: Red //230: Blue //200 - 220: Cyan/Blue //170 - 190: Turqoise //80 - 140: Green //50 - 60: Yellow //30 - 40: Orange //1 - 20: Red //0: Purple //-40: Pink $size = getimagesize($add); $add = imagecreatefrompng($add); $width = $size[0]; $height = $size[1]; for ($i = 0;$i < $height;$i++) { for ($ii = 0;$ii < $width;$ii++) { if ($saturation) { $rgb = imagecolorat($add,$ii,$i); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $getArrayHSB = RGBtoHSB($r,$g,$b); $getArrayHSB[1] = $saturation * $getArrayHSB[1]; $getArrayHSB[1] = max(0.0,min($getArrayHSB[1],1.0)); $getArrayRGB = HSBtoRGB($getArrayHSB[0], $getArrayHSB[1],$getArrayHSB[2]); $hsbrgb = imagecolorallocate($add,$getArrayRGB[0], $getArrayRGB[1],$getArrayRGB[2]); $result = (($rgb & 0xff000000)|($hsbrgb)); imagesetpixel($add,$ii,$i,$result); } if ($hue) { $rgb = imagecolorat($add, $ii, $i); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $getArrayHSB = RGBtoHSB($r,$g,$b); $getArrayHSB[0] = $hue; $getArrayHSB[0] = max(0.0,min($getArrayHSB[0],360.0)); $getArrayRGB = HSBtoRGB($getArrayHSB[0],$getArrayHSB[1],$getArrayHSB[2]); $hsbrgb = imagecolorallocate($add, $getArrayRGB[0], $getArrayRGB[1], $getArrayRGB[2]); $result = (($rgb & 0xff000000)|($hsbrgb)); imagesetpixel($add, $ii, $i, $result); } } } $width = imagesx($image); $height = imagesy($image); if (($xoffset) || ($yoffset)) { $width = 92 + abs(round($stretch / 2)); $height = 200 + $stretch; } if ($wstretch) { $width = imagesx($image); } imagecopyresized($image,$add,$xoffset,$yoffset,0,0,$width,$height,imagesx($image),imagesy($image)); imageDestroy($add); } } //gather information $table = $_GET['table']; if (!$table) $table = "posts"; $id = $_GET['id']; $conditions = "WHERE id='$id'"; if ($table == "posts") $user = getInfo(username,$table,$conditions); elseif ($table == "archives") $user = getInfo(username,$table,$conditions); elseif ($table == "memory_avatars") $user = getInfo(user,$table,$conditions); else $user = $id; $base = getInfo(base,$table,$conditions); $tattoos = getInfo(tattoos,$table,$conditions); $clothes = getInfo(clothes,$table,$conditions); $hair = getInfo(hair,$table,$conditions); $stretch = getInfo(stretch,$table,$conditions); $overhead = getInfo(overhead,$table,$conditions); $behind = getInfo(behind,$table,$conditions); $sex = getInfo(sex,users,"WHERE id='$user'"); $transformed = getInfo(transformed,$table,$conditions); $mount = getInfo(mount,$table,$conditions); $master = getInfo(master,$table,$conditions); $health = getInfo(health,$table,$conditions); $statmax = getInfo(statmax,$table,$conditions); $hue = getInfo(hue,$table,$conditions); $saturation = getInfo(saturation,$table,$conditions); if ($statmax > 0) $health = round(($health / $statmax) * 100); else $health = 100; $transformed = getInfo(image,transformations,"WHERE id='$transformed'"); //starting, create image, create transparency #440404 - R68 G4 B4 if ($mount) $width = 120; else $width = 92; $width += abs(round($stretch / 2)); $height = 200; if ($stretch > 0) $height += $stretch; if ($stretch < 0) { $yoffset = abs($stretch); $mountyoffset = abs($stretch); } $image = imagecreatetruecolor($width,$height); $trans = imagecolorallocate($image,81,5,5); imageFilledRectangle($image, 0, 0,imagesx($image),imagesy($image), $trans); if ($mount) { if (($table == "posts") || ($table == "memory_avatars")) $mount_clothes = getInfo(mount_clothes,$table,$conditions); else { if (getInfo(clothes,users,"WHERE id='$mount'")) $mount_clothes = getInfo(clothes,users,"WHERE id='$mount'"); if (getInfo(overhead,users,"WHERE id='$mount'")) { if ($mount_clothes) $mount_clothes .= '.'.getInfo(overhead,users,"WHERE id='$mount'"); else $mount_clothes = getInfo(overhead,users,"WHERE id='$mount'"); } } $mounted = getInfo(mounted,mounts,"WHERE npc='$mount'"); $mounted = getInfo(image,transformations,"WHERE id='$mounted'"); $file = "avatars/transformations/$mounted"; if ($mounted) merge($image,$file,0,0,$stretch + $mountyoffset,$stretch); if ($mount_clothes) { $mount_clothes = explode('.',$mount_clothes); $max = count($mount_clothes); for ($i = 0;$i < $max;$i++) { $item = $mount_clothes[$i]; $item = getInfo(item,user_items,"WHERE id='$item'"); $itemsex = getInfo(sex,items,"WHERE id='$item'"); $itemsex = getInfo(sex,bases,"WHERE id='$itemsex'"); $file = getInfo(image,items,"WHERE id='$item'"); if ($itemsex) { if ($file) merge($image,"avatars/".$itemsex."/clothes/".$file,$stretch,0,$mountyoffset + $stretch); } else { if ($file) merge($image,"avatars/clothes/".$file,$stretch,0,$mountyoffset + $stretch); } } } $xoffset = 40 - abs(round($stretch / 4)); $yoffset += 5; } else { $yoffset += 0; $xoffset = 0; } //*--create images--* //behind if (!$transformed) { $behind = explode('.',$behind); $max = count($behind); for ($i = 0;$i < $max;$i++) { $item = $behind[$i]; $item = getInfo(item,user_items,"WHERE id='$item'"); $itemsex = getInfo(sex,items,"WHERE id='$item'"); $itemsex = getInfo(sex,bases,"WHERE id='$itemsex'"); $file = getInfo(image,items,"WHERE id='$item'"); if ($itemsex != "t") { if ($file) merge($image,"avatars/".$itemsex."/clothes/".$file,$stretch,$xoffset,$yoffset); } else { if ($file) merge($image,"avatars/clothes/".$file,$stretch,$xoffset,$yoffset); } } } //base if ((!$transformed) && ($base)) { $file = getInfo(image,bases,"WHERE id='$base'"); $basesex = getInfo(sex,bases,"WHERE id='$base'"); if ($file) { if (($saturation) || ($hue)) mergeDesaturate($image,"avatars/".$basesex."/bases/".$file,$saturation,$hue,$stretch,$xoffset,$yoffset); else merge($image,"avatars/".$basesex."/bases/".$file,$stretch,$xoffset,$yoffset); } //tattoos $tattoos = explode('.',$tattoos); $max = count($tattoos); for ($i = 0;$i < $max;$i++) { $tattoo = $tattoos[$i]; $file = getInfo(image,tattoos,"WHERE id='$tattoo'"); if ($file) merge($image,"avatars/".$sex."/tattoos/".$file,$stretch,$xoffset,$yoffset); } //wounds $_80 = getInfo(wound80,bases,"WHERE id='$base'"); $_60 = getInfo(wound60,bases,"WHERE id='$base'"); $_40 = getInfo(wound40,bases,"WHERE id='$base'"); $_20 = getInfo(wound20,bases,"WHERE id='$base'"); $collar = getInfo(collar,bases,"WHERE id='$base'"); if ($health <= 80) merge($image,"avatars/".$sex."/".$_80,$stretch,$xoffset,$yoffset); if ($health <= 60) merge($image,"avatars/".$sex."/".$_60,$stretch,$xoffset,$yoffset); if ($health <= 40) merge($image,"avatars/".$sex."/".$_40,$stretch,$xoffset,$yoffset); if ($health <= 20) merge($image,"avatars/".$sex."/".$_20,$stretch,$xoffset,$yoffset); //slave collar if ($master) merge($image,"avatars/".$sex."/$collar",$stretch,$xoffset,$yoffset); } else { $file = getInfo(image,transformations,"WHERE id='$transformed'"); if ($file) merge($image,"avatars/transformations/".$file,$stretch,$xoffset,$yoffset); elseif ($transformed) merge($image,"avatars/transformations/".$transformed,$stretch,$xoffset,$yoffset); } //underhead clothing $clothes = explode('.',$clothes); $max = count($clothes); for ($i = 0;$i < $max;$i++) { $item = $clothes[$i]; $item = getInfo(item,user_items,"WHERE id='$item'"); $itemsex = getInfo(sex,items,"WHERE id='$item'"); $itemsex = getInfo(sex,bases,"WHERE id='$itemsex'"); $file = getInfo(image,items,"WHERE id='$item'"); if ($itemsex) { if ($file) merge($image,"avatars/".$itemsex."/clothes/".$file,$stretch,$xoffset,$yoffset); } else { if ($file) merge($image,"avatars/clothes/".$file,$stretch,$xoffset,$yoffset); } } if ((!$transformed) && ($base)) { //hair $hairsex = getInfo(sex,hair,"WHERE id='$hair'"); $hairsex = getInfo(sex,bases,"WHERE id='$hairsex'"); $file = getInfo(image,hair,"WHERE id='$hair'"); if ($file) merge($image,"avatars/".$hairsex."/hair/".$file,$stretch,$xoffset,$yoffset); } //overhead clothing $overhead = explode('.',$overhead); $max = count($overhead); for ($i = 0;$i < $max;$i++) { $item = $overhead[$i]; $item = getInfo(item,user_items,"WHERE id='$item'"); $itemsex = getInfo(sex,items,"WHERE id='$item'"); $itemsex = getInfo(sex,bases,"WHERE id='$itemsex'"); $file = getInfo(image,items,"WHERE id='$item'"); if ($itemsex) { if ($file) merge($image,"avatars/".$itemsex."/clothes/".$file,$stretch,$xoffset,$yoffset); } else { if ($file) merge($image,"avatars/clothes/".$file,$stretch,$xoffset,$yoffset); } } /* if ($stretch) { $newimage = imagecreatetruecolor($width + abs(round($stretch / 2)),200 + $stretch); imagecopyresized($newimage,$image,0,0,0,0,$width + abs(round($stretch / 2)),200 + $stretch,$width,200); $image = $newimage; } */ //final display and output header("Content-type: image/png"); //imagecolortransparent($image,$trans); imagePNG($image,'',9); imageDestroy($image); mysql_close(); ?>