Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zmiana koloru obrazka
jerzes
post 10.06.2007, 12:37:37
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 4.10.2003
Skąd: Poznań

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


Napisalem funkcje ktora ma pobrac identyfikator koloru i wstawic w jego miejsce inny.
  1. <?php
  2. $bg = imagecreatefromjpeg("we.jpg");
  3. $kol = imagecolorclosest($bg,1,255,254);
  4. imagecolorset($bg,$kol,255,0,255);
  5.  
  6. imagejpeg($bg);
  7. ?>

Niestety nie dziala.Pytanie: jakiej funkcji zapomnialem dopisac albo co jest nie tak?
Z gory dzieki smile.gif
Go to the top of the page
+Quote Post
expert
post 29.01.2010, 20:28:39
Post #2





Grupa: Zarejestrowani
Postów: 211
Pomógł: 4
Dołączył: 29.10.2008

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


Czy ktoś zna odpowiedź na to pytanie? Nie będę zakładał nowego wątku, bo problem mam taki sam. Może autor znalazł już rozwiązanie?
Go to the top of the page
+Quote Post
darko
post 29.01.2010, 20:56:57
Post #3





Grupa: Zarejestrowani
Postów: 2 885
Pomógł: 463
Dołączył: 3.10.2009
Skąd: Wrocław

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


Raczej imagecolorallocate i imagefilledrectangle Coś mniej więcej takiego:
  1. $filename = "we.jpg";
  2. $_background_color = array(255, 124, 65);
  3. $im = imagecreatefromjpeg($filename);
  4. list($_width, $_height) = getimagesize($filename);
  5. $background_color = imagecolorallocate(
  6. $im,
  7. $_background_color[0],
  8. $_background_color[1],
  9. $_background_color[2]
  10. );
  11. imagefilledrectangle($im, 0, 0, $_width-1, $_height-1, $background_color);
  12. header('Content-type: image/jpg');
  13. imagejpeg($im);


--------------------
Nie pomagam na pw, tylko forum.
Go to the top of the page
+Quote Post
expert
post 29.01.2010, 21:21:34
Post #4





Grupa: Zarejestrowani
Postów: 211
Pomógł: 4
Dołączył: 29.10.2008

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


Oki. W prawdzie to nie to, ale podpowiedziałeś mi.
  1. <?php
  2. $bg = imagecreatefrompng("we.png");
  3. $size = getimagesize("we.png"); //pobranie rozmiarów obrazka
  4.  
  5. $szerokosc=$size[0];
  6. $wysokosc=$size[1];
  7.  
  8. for($a=0;$a<$wysokosc;$a++){
  9.  
  10. for($b=0;$b<$szerokosc;$b++){
  11.  
  12. $rgb = imagecolorat($obrazc, $b, $a);
  13. $colors = imagecolorsforindex($obrazc, $rgb);
  14.  
  15. $kolor = $colors["red"].','.$colors["green"].','.$colors["blue"];
  16.  
  17. if ($kolor=='107,107,191'){
  18. $background_color = imagecolorallocate($obrazc,0,255,0);
  19. imagefilledrectangle($obrazc, $b, $a, $b, $a, $background_color);
  20.  
  21. }
  22. }
  23.  
  24. }
  25.  
  26. header("Content-type: image/png");
  27. ImagePng($obrazc);
  28. ImageDestroy($obrazc);
  29. ?>


Mam to czego chciałem. Podaje fragment kodu.
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: 12.06.2025 - 22:22