Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("Content-type: image/png");
- $c = $_GET['color'];
- if(!isset($_GET['color'])) $c = "#COR PADRAO AQUI";
- function HexParaRGB($hex) {
- $hex = ereg_replace("#", "", $hex);
- $cor = array();
- if(strlen($hex) == 3) {
- $cor['r'] = hexdec(substr($hex, 0, 1) . $r);
- $cor['g'] = hexdec(substr($hex, 1, 1) . $g);
- $cor['b'] = hexdec(substr($hex, 2, 1) . $B);
- }elseif(strlen($hex) == 6) {
- $cor['r'] = hexdec(substr($hex, 0, 2));
- $cor['g'] = hexdec(substr($hex, 2, 2));
- $cor['b'] = hexdec(substr($hex, 4, 2));
- }
- return $cor;
- }
- $im = imagecreatefrompng("puffle.png");
- $x = 0;
- $y = 0;
- $lar = imagesx($im);
- $alt = imagesy($im);
- for ($x=0;$x<=$lar;$x++){
- for ($y=0;$y<=$alt;$y++){
- $rgb = imagecolorat($im, $x, $y);
- $r = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $b = $rgb & 0xFF;
- $cor = $r.'-'.$g.'-'.$b;
- if($cor == '0-0-255'){
- $corHex = HexParaRGB($c);
- $color = imagecolorallocate($im, $corHex['r'], $corHex['g'], $corHex['b']);
- imagesetpixel($im, $x, $y, $color);
- }
- }
- }
- imagepng($im);
- imagedestroy($im);
- ?>
Add Comment
Please, Sign In to add comment