(PHP 4 >= 4.0.6, PHP 5, PHP 7)
imagetruecolortopalette — 锟斤拷锟斤拷锟缴硷拷锟阶拷锟轿拷锟缴拷锟酵硷拷锟�
$image
, bool $dither
, int $ncolors
) : boolimagetruecolortopalette() 锟斤拷一锟斤拷锟斤拷锟缴硷拷锟阶拷锟轿拷锟缴拷锟酵硷拷瘛1锟斤拷锟斤拷锟斤拷拇锟斤拷锟皆拷锟斤拷谴佣锟斤拷锟斤拷锟� JPEG 小锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷取锟斤拷锟斤拷锟侥o拷锟角筹拷锟斤拷色锟斤拷锟剿达拷锟诫被锟睫革拷锟斤拷锟节斤拷锟斤拷锟缴拷锟斤拷斜锟斤拷锟斤拷锟斤拷锟斤拷芏锟斤拷 alpha 通锟斤拷锟斤拷息锟皆硷拷锟斤拷锟斤拷锟杰讹拷锟斤拷锟缴拷锟斤拷锟斤拷锟矫伙拷写锏斤拷锟斤拷锟斤拷锟叫э拷锟斤拷锟酵拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟缴硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆憋拷证锟矫碉拷锟斤拷叩锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
image
锟斤拷图锟襟创斤拷锟斤拷锟斤拷(锟斤拷锟斤拷imagecreatetruecolor())锟斤拷锟截碉拷图锟斤拷锟斤拷源锟斤拷
dither
指锟斤拷图锟斤拷锟角否被讹拷锟斤拷锟斤拷dithered锟斤拷锟斤拷锟斤拷锟轿�
TRUE
锟斤拷图锟今将憋拷锟斤拷锟斤拷使图锟斤拷锟叫的斑碉拷锟斤拷嗟拷锟斤拷锟缴拷锟斤拷咏锟斤拷锟�
ncolors
锟借定锟斤拷色锟斤拷锟叫憋拷锟斤拷锟斤拷锟斤拷锟斤拷色锟斤拷锟斤拷锟斤拷锟侥匡拷锟�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 Converting a true color image to a palette-based image
<?php
// Create a new true color image
$im = imagecreatetruecolor(100, 100);
// Convert to palette-based with no dithering and 255 colors
imagetruecolortopalette($im, false, 255);
// Save the image
imagepng($im, './paletteimage.png');
imagedestroy($im);
?>
Note: 锟剿猴拷锟斤拷锟斤拷要 GD 2.0.1 锟斤拷锟斤拷甙姹�(锟狡硷拷 2.0.28 锟斤拷锟斤拷锟竭版本)锟斤拷