Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> generowanie rysunku
-Gość_marek-
post 15.02.2006, 22:18:39
Post #1





Goście







Probuje narysowac pasek w odcieniach szarosci, od bialego do czarnego o szerokosci 20. Nie moge doszukac sie bledu w skrypcie ponizej, uparcie rusyje mi pasek o szerokosci 1. Prosze o pomoc.

  1. <?php
  2. $wys=256;
  3. $szer=20;
  4.  
  5. $rys=ImageCreate($szer,$wys);
  6. for ($x=0;$x<$szer;$x++) {
  7. for ($y=0;$y<$wys;$y++) {
  8.  
  9. $r=$y;
  10. $g=$y;
  11. $b=$y;
  12. if ($r>255) $r=255; if ($r<0) $r=0;
  13. if ($g>255) $g=255; if ($g<0) $g=0;
  14. if ($b>255) $b=255; if ($b<0) $b=0;
  15.  
  16. $kolor=imagecolorallocate($rys, $r, $g, $b);
  17. imagesetpixel($rys,$x,$y,$kolor);
  18. }
  19.  } 
  20.  header("Content-type: image/png");
  21.  imagepng($rys);
  22.  imagedestroy($rys);
  23. ?>



~mike_mech
Go to the top of the page
+Quote Post
crash
post 15.02.2006, 23:42:03
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


Tyle Ci nie starczy?
  1. <?php
  2. $height = 256;
  3. $width = 20;
  4.  
  5. $img = imagecreate( $width, $height );
  6.  
  7. imagecolorallocate( $img, 255, 255, 255 );
  8.  
  9. for( $x = 0; $x < $height; $x++ )
  10. {
  11.  imageline( $img, 0, $x, 20, $x, imagecolorallocate( $img, $x, $x, $x ) );
  12. }
  13.  
  14. header( 'Content-type: image/png' );
  15.  
  16. imagepng( $img );
  17. imagedestroy( $img );
  18. ?>


--------------------
Go to the top of the page
+Quote Post
-Gość_Marek-
post 16.02.2006, 11:54:31
Post #3





Goście







super!! dziala, jestes wielki winksmiley.jpg. Pozdrawiam
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 20.06.2025 - 14:52