Supported Versions: PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8
Allocate a color for an image
<?php imagecolorallocatealpha( GdImage $image, int $red, int $green, int $blue, int $alpha): int|false
<?php if (is_null($matte)) {
$matte = imagecolorallocatealpha($resource, 255, 255, 255, 127);
} else {
$matte = $image->getDriver()->parseColor($matte)->getInt();
}
<?php $transparent = imagecolorallocatealpha($canvas->getCore(), 255, 255, 255, 127);
imagealphablending($canvas->getCore(), false); // do not blend / just overwrite
imagefilledrectangle($canvas->getCore(), $dst_x, $dst_y, $dst_x + $src_w - 1, $dst_y + $src_h - 1, $transparent);
<?php if ($transIndex != -1) {
$rgba = imagecolorsforindex($modified, $transIndex);
$transColor = imagecolorallocatealpha($modified, $rgba['red'], $rgba['green'], $rgba['blue'], 127);
imagefill($modified, 0, 0, $transColor);
imagecolortransparent($modified, $transColor);
} else {
<?php imagealphablending($canvas, false);
$transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127);
imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent);
imagecolortransparent($canvas, $transparent);
imagealphablending($canvas, true);
<?php $clone = imagecreatetruecolor($width, $height);
imagealphablending($clone, false);
imagesavealpha($clone, true);
$transparency = imagecolorallocatealpha($clone, 0, 0, 0, 127);
imagefill($clone, 0, 0, $transparency);
imagecopy($clone, $core, 0, 0, 0, 0, $width, $height);