downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imagecolormatch> <imagecolorexact
[edit] Last updated: Fri, 25 May 2012

view this page in

imagecolorexactalpha

(PHP 4 >= 4.0.6, PHP 5)

imagecolorexactalphaПолучение индекса заданного цвета и альфа компонента

Описание

int imagecolorexactalpha ( resource $image , int $red , int $green , int $blue , int $alpha )

Возвращает индекс для заданного цвета и альфа компонента в палитре изображения.

Список параметров

image

Ресурс изображения, полученный одной из функций создания изображений, например, такой как imagecreatetruecolor().

red

Значение красного компонента цвета.

green

Значение зеленого компонента цвета.

blue

Значение синего компонента цвета.

alpha

Значение в диапазоне от 0 до 127. 0 означает непрозрачность, 127 означает абсолютную прозрачность.

Параметры цвета могут быть либо целочисленными в диапазоне от 0 до 255, либо шестнадцатиричными в диапазоне от 0x00 до 0xFF.

Возвращаемые значения

Возвращает индекс для заданного цвета и альфа компонента в палитре изображения либо -1, если такого цвета в палитре нет.

Примеры

Пример #1 Получение цветов GD логотипа

<?php

// создание изображения
$im imagecreatefrompng('./gdlogo.png');

$colors   = Array();
$colors[] = imagecolorexactalpha($im255000);
$colors[] = imagecolorexactalpha($im000127);
$colors[] = imagecolorexactalpha($im25525525555);
$colors[] = imagecolorexactalpha($im1002555220);

print_r($colors);

// освобождение памяти
imagedestroy($im);
?>

Результатом выполнения данного примера будет что-то подобное:

Array
(
    [0] => 16711680
    [1] => 2130706432
    [2] => 939524095
    [3] => 342163252
)

Примечания

Замечание: Эта функция нуждается в GD версии 2.0.1 или выше.

Смотрите также

  • imagecolorclosestalpha() - Получение индекса цвета ближайшего к заданному с учетом прозрачности



add a note add a note User Contributed Notes imagecolorexactalpha
matt at matt-darby dot com 11-Jul-2005 12:09
Note that a color allocated with imagecolorexactalpha won't show alpha (it will be opaque) when used with imageline(). Use imagerectangle() set to your normal start and end points instead.

Ensure that the image is created via imagecreatetruecolor() as well!
phpdoc-comment at aditus dot nu 08-Nov-2002 03:01
What might be misleading in the docs is that if the specified color + alpha channel does not exist it will be created. So if you like to use an alpha channel in your image enable alpha blending and then create you color using this method.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites