imagecolormatch

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

imagecolormatch使一个图像中调色板版本的颜色与真彩色版本更能匹配

说明

imagecolormatch(GdImage $image1, GdImage $image2): bool

使一个图像中调色板版本的颜色与真彩色版本更能匹配。

参数

image1

真彩色图像对象。

image2

调色板图像对象,指向与 image1 相同大小的图像。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 image1image2 现在需要 GdImage 实例,之前需要 resource

范例

示例 #1 imagecolormatch() 示例

<?php
// Setup the true color and palette images
$im1 = imagecreatefrompng('./gdlogo.png');
$im2 = imagecreate(imagesx($im1), imagesy($im1));

// Add some colors to $im2
$colors = Array();
$colors[] = imagecolorallocate($im2, 255, 36, 74);
$colors[] = imagecolorallocate($im2, 40, 0, 240);
$colors[] = imagecolorallocate($im2, 82, 100, 255);
$colors[] = imagecolorallocate($im2, 84, 63, 44);

// Match these colors with the true color image
imagecolormatch($im1, $im2);

// Free from memory
imagedestroy($im1);
imagedestroy($im2);
?>

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top