Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 93
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
W takich dniach, jak ten, nie żałuję, że wykupiłem abonament. Korzystam z porad na tych stronach nawet kilkanaście razy w tygodniu i dzięki nim prace nad stronami dla klientów idą mi o wiele szybciej, a strony wyglądają bardziej profesjonalnie. Nie wiem, jak mogłem wcześniej pracować bez dostępu do porad w tym serwisie!

Wojciech Miszkiewicz

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

imagecolorset

(PHP 3, PHP 4, PHP 5)

imagecolorset -- Set the color for the specified palette index

Description

bool imagecolorset ( resource image, int index, int red, int green, int blue )

This sets the specified index in the palette to the specified color. This is useful for creating flood-fill-like effects in palleted images without the overhead of performing the actual flood-fill.

See also imagecolorat().




User Contributed Notes

dade dot c at email dot it
02-Oct-2004 10:47

this is helpful if you would like to implement a color theme system in your website... try it out
Davide Candiloro Italy

function colorize ($pngpath, $r, $g, $b)
/*
REQUIRES: $pngpath to be a valid path of a greyscale PNG-8 image with 64 colors palette
         $r, $g, $b to be integers in the range 0..255
EFFECTS: returns the png image colorized with the color represented by $r, $g, $b.
*/
{
   header("Content-type: image/png");
   $im = imagecreatefrompng("images/table.png");

   imagetruecolortopalette($im, FALSE, 256);
  
     for ($c = 0; $c < 64; $c++){ /*64 is the number of colors in the PNG-8 palette*/
       $col = imagecolorsforindex($im, $c);         
       imagecolorset ( $im, $c, $r*$col['red']/256, $g*$col['green']/256, $b*$col['blue']/256); /*replaces original greyscale palette with a colorized one*/
     }

   imagepng($im);
   imagedestroy($im);
}


m4551 at abasoft dot it
23-Apr-2004 06:19

here's a function to greyscale an image even from a truecolor source (jpeg or png).

slightly poor quality, but very fast...

function imagegreyscale(&$img, $dither=1) {   
   if (!($t = imagecolorstotal($img))) {
       $t = 256;
       imagetruecolortopalette($img, $dither, $t);   
   }
   for ($c = 0; $c < $t; $c++) {   
       $col = imagecolorsforindex($img, $c);
       $min = min($col['red'],$col['green'],$col['blue']);
       $max = max($col['red'],$col['green'],$col['blue']);
       $i = ($max+$min)/2;
       imagecolorset($img, $c, $i, $i, $i);
   }
}


info at devking dot com
08-Aug-2002 11:20

here's a simple function to greyscale an image...

function imagecolorgrey( &$img ) {
 for( $i=0; $i<imagecolorstotal( $img ); $i++ ) {
  $c = ImageColorsForIndex( $img, $i );
  $t = ($c["red"]+$c["green"]+$c["blue"])/3;
  imagecolorset( $img, $i, $t, $t, $t );   
 }
}


olivier at moostik dot net
12-Jul-2001 02:49

This function change colors of an image with ranges 0>100 for each primary color:

int ImageSelectiveColor (int im, int red, int green, int blue)

im is image pointer
red, green and blue are ranges 0->100

function ImageSelectiveColor($im,$red,$green,$blue)
 {
  for($i=0;$i<imagecolorstotal($im);$i++)
   {
   $col=ImageColorsForIndex($im,$i);
   $red_set=$red/100*$col['red'];
   $green_set=$green/100*$col['green'];
   $blue_set=$blue/100*$col['blue'];
   if($red_set>255)$red_set=255;
   if($green_set>255)$green_set=255;
   if($blue_set>255)$blue_set=255;
   imagecolorset($im,$i,$red_set,$green_set,$blue_set);
  
   }
  return $im;
 
 }


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt