hecky

Obtener pixeles diferentes

Aug 28th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2. $file=imagecreatefrompng("PORFAVOR.png");
  3. $salida=imagecreatetruecolor(imagesx($file),imagesy($file));
  4. $white = imagecolorexact($salida,255,255,255);
  5. //imagefill($salida,0,0,$white);
  6.     for($x=0;$x<imagesx($file);$x++){
  7.         for($y=0;$y<imagesy($file);$y++){
  8.         $getpix = imagecolorat($file,$x,$y);
  9.         $rgb[0]= ($getpix >> 16) & 0xFF;
  10.         $rgb[1]= ($getpix >> 8) & 0xFF;
  11.         $rgb[2]= $getpix & 0xFF;
  12.         if( ($rgb[0]==0) && ($rgb[1]==1) && ($rgb[2]==0)){
  13.             $color = imagecolorexact($salida,251,0,0);
  14.             imagesetpixel($salida,$x,$y,$color);
  15.             echo "Pixel 0,1,0 encontrado en ($x,$y)\n";
  16.             }
  17.         elseif( ($rgb[0]==0) && ($rgb[1]==2) && ($rgb[2]==0)){
  18.             $color = imagecolorexact($salida,0,252,0);
  19.             imagesetpixel($salida,$x,$y,$color);
  20.             echo "Pixel 0,2,0 encontrado en ($x,$y)\n";
  21.             }
  22.         elseif( ($rgb[0]==0) && ($rgb[1]==3) && ($rgb[2]==0)){
  23.             $color = imagecolorexact($salida,0,0,253);
  24.             imagesetpixel($salida,$x,$y,$color);
  25.             echo "Pixel 0,3,0 encontrado en ($x,$y)\n";
  26.             }
  27.         else{
  28.             $color = imagecolortransparent($salida,imagecolorexact($salida,255,255,255));
  29.             imagesetpixel($salida,$x,$y,$color);
  30.             }
  31.         }
  32.     }
  33. imagepng($salida,"Final.png");
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment