= 4.0.6, PHP 5, PHP 7, PHP 8)imagetruecolortopalette — 將真彩色圖像轉(zhuǎn)換為調(diào)色板圖像說(shuō)明imagetruecolortopalette(resource $image, bool $d">

imagetruecolortopalette

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagetruecolortopalette將真彩色圖像轉(zhuǎn)換為調(diào)色板圖像

說(shuō)明

imagetruecolortopalette(resource $image, bool $dither, int $ncolors): bool

imagetruecolortopalette() 將一幅真彩色圖像轉(zhuǎn)換為調(diào)色板圖像。本函數(shù)的代碼原本是從獨(dú)立的 JPEG 小組庫(kù)代碼中提取出來(lái)的,非常出色。此代碼被修改以在結(jié)果調(diào)色板中保留盡可能多的 alpha 通道信息以及盡可能多的顏色。但并沒(méi)有達(dá)到期望的效果。通常最好生成真彩色圖像輸出,這樣可以保證得到最高的輸出質(zhì)量。

參數(shù)

image

由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的 GdImage 對(duì)象。

dither

指明圖像是否被抖動(dòng)(dithered),如果為 true 則圖像將被抖動(dòng)使圖像中的斑點(diǎn)更多但是顏色更接近。

ncolors

設(shè)定調(diào)色板中被保留的顏色的最大數(shù)目。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

范例

示例 #1 Converting a true color image to a palette-based image

<?php
// Create a new true color image
$im imagecreatetruecolor(100100);

// Convert to palette-based with no dithering and 255 colors
imagetruecolortopalette($imfalse255);

// Save the image
imagepng($im'./paletteimage.png');
imagedestroy($im);
?>

注釋