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!
imagecolorexactalpha
(PHP 4 >= 4.0.6, PHP 5)
imagecolorexactalpha — Alfası ile birlikte belirtilen rengin indisini verir
Açıklama
$resim
, int $kırmızı
, int $yeşil
, int $mavi
, int $alfa
)Bu işlev, alfası ile birlikte belirtilen rengin paletli resimdeki en yakın benzerinin indisini döndürür.
Değiştirgeler
-
resim -
imagecreatetruecolor() gibi bir resim oluşturma işlevinden dönen bir resim verisi.
-
kırmızı -
Rengin kırmızı bileşeninin değeri.
-
yeşil -
Rengin yeşil bileşeninin değeri.
-
mavi -
Rengin mavi bileşeninin değeri.
-
alfa -
0-127 arasında belirtilebilir. 0 tamamen mat, 127 ise tamamen şeffaf demektir.
Dönen Değerler
Renk palette mevcut değilse -1, aksi takdirde rengin indisini döndürür.
Örnekler
Örnek 1 - GD logosunun renklerini öğrenelim
<?php
// Resmi belirtelim
$im = imagecreatefrompng('./gdlogo.png');
$colors = Array();
$colors[] = imagecolorexactalpha($im, 255, 0, 0, 0);
$colors[] = imagecolorexactalpha($im, 0, 0, 0, 127);
$colors[] = imagecolorexactalpha($im, 255, 255, 255, 55);
$colors[] = imagecolorexactalpha($im, 100, 255, 52, 20);
print_r($colors);
// Belleği serbest bırakalım
imagedestroy($im);
?>
Yukarıdaki örnek şuna benzer bir çıktı üretir:
Array
(
[0] => 16711680
[1] => 2130706432
[2] => 939524095
[3] => 342163252
)
Notlar
Bilginize: Bu işlev GD'nin 2.0.1 veya sonraki sürümlerini gerektirir (2.0.28 veya sonraki sürümler önerilir).
Ayrıca Bakınız
- imagecolorclosestalpha() - Alfası ile birlikte belirtilen rengin en yakın benzerinin renk indisini verir
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.
