note 57996 added to function.imagepalettecopy
| From: | buzz at nospam dot oska dot com | Date: | Thu, 20 Oct 2005 23:51:32 +0000 |
| Subject: | note 57996 added to function.imagepalettecopy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97332@lists.php.net to get a copy of this message | ||
actually it doesn't "copy" the palette exactly. It copys the colors from the source
palette to the destination image. the palette you end up with in the destination image will be
"same colors different order". If you want an EXACT palette copy (at the expense of
messing up your image if you aren't careful), then use this code:
<?
// this is a drop-in replacement for imagepalettecopy, except that it make NO attempt to modifiy any
of the
// colors in the dest image, just the palette. The result? if you're palette's
aren't very similar, the image will look completely different, and likely terrible!
function imagepalettecopy_exact ( $dst_img, $src_img) {
for( $c = 0 ; $c < imagecolorstotal($src_img); $c++) {
$col = imagecolorsforindex($src_img,$c); //get color at index 'c' in the color table
imagecolorset($dst_img,$c,$col[red],$col[green],$col[blue]); //set color at index 'c' to
$col in the $dst_image
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagepalettecopy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57996
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57996&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57996&report=yes
Search -- http://master.php.net/manage/user-notes.php