[prev in list] [next in list] [prev in thread] [next in thread]
List: php-general
Subject: [PHP] Re: Changing black to blue (2)
From: 195.252.185.134
Date: 2002-03-31 19:52:44
[Download RAW message or body]
thanx!
"Hugh Bothwell" <hugh_bothwell@hotmail.com> schrieb im Newsbeitrag
news:20020331160429.53145.qmail@pb1.pair.com...
> > I have a map of the world with all countries. I have
> > 250 maps of the same size as png where only one
> > country is black, rest is transp.
> > Now I neeed to set this country color to blue or red
> > to indicate a special spot.
> > I just don't want to save the same map double or tripple.
>
> Good! Makes much more sense.
>
> Call this like
> <img src='country.php?cty=germany&col=255,0,0'>
> (functions in bold you will have to write yourself)
> ====== country.php ===========
> <?php
> Header("Content-type: image/png");
> $mapURL = '\images\countrymask\'.MAKESAFE($cty);
>
> // load image
> $img = ImageCreateFromPNG($mapURL.$mapname)
> or MAKEDEFAULTIMAGE();
>
> // parse new desired color
> $newcolor = split(',', $col);
>
> // find black
> $oldcolor = ImageColorResolve($img, 0, 0, 0);
>
> // change to new color
> ImageColorSet($img, $oldcolor, $newcolor[0], $newcolor[1],
> $newcolor[2]);
>
> // ... and return result
> ImagePNG($img);
> ?>
>
> Note that depending on how much this gets used,
> it may indeed be better (faster, less computationally
> intensive) in the long run to use multiple image
> copies, ie country_red.png, country_blu.png etc.
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic