Latest web development tutorials
×

PHP kuliah

PHP kuliah PHP pengantar singkat PHP memasang PHP tatabahasa PHP variabel PHP echo/print PHP Jenis Data PHP konstan PHP tali PHP operator PHP If...Else PHP Switch PHP susunan PHP Sorting array PHP superglobals PHP While sirkulasi PHP For sirkulasi PHP fungsi PHP Variabel sihir PHP Ruang nama PHP Berorientasi Objek

PHP bentuk

PHP bentuk PHP bentuk Authentication PHP bentuk - bidang yang harus diisi PHP bentuk - email verifikasi dan URL PHP contoh bentuk lengkap PHP $_GET variabel PHP $_POST variabel

PHP canggih Tutorial

PHP Array multidimensi PHP tanggal PHP berisi PHP berkas PHP Upload File PHP Cookie PHP Session PHP E-mail PHP keamanan E-mail PHP Error PHP Exception PHP filter PHP filter lanjutan PHP JSON

PHP 7 Fitur baru

PHP 7 Fitur baru

PHP database

PHP MySQL pengantar singkat PHP MySQL koneksi PHP MySQL Membuat database PHP MySQL Buat tabel data PHP MySQL memasukkan data PHP MySQL Menyisipkan beberapa data yang PHP MySQL Laporan disiapkan PHP MySQL membaca data PHP MySQL WHERE PHP MySQL ORDER BY PHP MySQL UPDATE PHP MySQL DELETE PHP ODBC

PHP XML

XML Expat Parser XML DOM XML SimpleXML

PHP & AJAX

AJAX pengantar singkat AJAX PHP AJAX database AJAX XML AJAX pencarian real-time AJAX RSS Reader AJAX suara

PHP Reference manual

PHP Array PHP Calendar PHP cURL PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP PDO PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones PHP image Processing PHP RESTful

PHP imagecolorallocatealpha - menetapkan warna dan transparansi gambar

PHP Image Processing PHP Image Processing

imagecolorallocatealpha - menetapkan warna dan transparansi gambar.

tatabahasa

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

imagecolorallocatealpha () perilaku dan imagecolorallocate () sama, tapi lebih dari satu tambahan parameter transparansi alpha, dan nilainya 0-127,0 benar-benar buram, 127 berarti benar-benar transparan.

Jika alokasi gagal ia mengembalikan FALSE.

Catatan: Fungsi ini memerlukan GD 2.0.1 atau yang lebih baru (2.0.28 atau yang lebih dianjurkan).

contoh

<?php
$size = 300;
$image=imagecreatetruecolor($size, $size);

// 用白色背景加黑色边框画个方框
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagerectangle($image, 0, 0, $size - 1, $size - 1, $border);

$yellow_x = 100;
$yellow_y = 75;
$red_x    = 120;
$red_y    = 165;
$blue_x   = 187;
$blue_y   = 125;
$radius   = 150;

// 用 alpha 值分配一些颜色
$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
$red    = imagecolorallocatealpha($image, 255, 0, 0, 75);
$blue   = imagecolorallocatealpha($image, 0, 0, 255, 75);

// 画三个交迭的圆
imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red);
imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue);

// 不要忘记输出正确的 header!
header('Content-type: image/png');

// 最后输出结果
imagepng($image);
imagedestroy($image);
?>

Contoh di atas dari gambar output sebagai berikut:

Artikel terkait

PHP Image Processing PHP Image Processing