Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/12/2011, 12:14
darkram
 
Fecha de Ingreso: septiembre-2007
Mensajes: 152
Antigüedad: 16 años, 7 meses
Puntos: 1
Respuesta: PHP Libreria GD, Problema canal alpha?

Mira estoy desesperado ya!!! :(

Mire mi code, por favor:

Código PHP:
Ver original
  1. <?php
  2. $img = imagecreatefrompng("imagen2.png");
  3.  
  4. $w = imagesx($img);
  5. $h = imagesy($img);
  6.  
  7.  
  8. /*
  9. // establece el fondo a rojo
  10.  
  11. imagefill($im, 0, 0, $rojo);
  12.  
  13. header('Content-type: image/png');
  14. imagepng($im);
  15. imagedestroy($im);
  16. */
  17.  
  18. $rojo = imagecolorallocate($img, 255, 0, 0);
  19. $verde = imagecolorallocate($img, 0, 255, 0);
  20.  
  21. for($y=0;$y<$h;$y++) {
  22.     for($x=0;$x<$w;$x++) {
  23.        
  24.          $rgb = imagecolorat($img, $x, $y);
  25.          $r = ($rgb >> 16) & 0xFF;
  26.          $g = ($rgb >> 8) & 0xFF;
  27.          $b = $rgb & 0xFF;        
  28.          
  29.          //$colorInstante = "#".str_repeat("0",2-strlen(dechex($r))).dechex($r).str_repeat("0",2-strlen(dechex($g))).dechex($g).str_repeat("0",2-strlen(dechex($b))).dechex($b).",";
  30.        
  31.          $colorInstante = "#".str_repeat("0",2-strlen(dechex($r))).dechex($r).str_repeat("0",2-strlen(dechex($g))).dechex($g).str_repeat("0",2-strlen(dechex($b))).dechex($b);
  32.                  
  33.          if ( $colorInstante == "#ffffff" )
  34.          {
  35.             imagefill($img, $y, $x, $verde);
  36.            
  37.          }/*
  38.          else
  39.          {
  40.             echo "BLANCO <br />";
  41.          }*/
  42.          
  43.    
  44.     }
  45.     //echo "<br />\r\n";
  46. }
  47. header('Content-type: image/png');
  48. imagepng($img);
  49. ?>

Un saludo y muchas gracias de antemano, por vuestro interés!


PD: imagen2.php, es un shape de photoshop, rojo! con fondo blanco.

Última edición por darkram; 10/12/2011 a las 12:16 Razón: Añadir más cosas