imagesavealpha

(PHP 4 >= 4.3.2, PHP 5, PHP 7)

imagesavealpha — ���ñ�����ڱ��� PNG ͼ��ʱ���������� alpha ͨ����Ϣ���뵥һ͸��ɫ�෴��

˵��

imagesavealpha ( resource $image , bool $saveflag ) : bool

imagesavealpha() ���ñ�����ڱ��� PNG ͼ��ʱ���������� alpha ͨ����Ϣ���뵥һ͸��ɫ�෴����

Ҫʹ�ñ����������뽫 alphablending ��λ��imagealphablending($im, false)����

�������е��������֧�� alpha ͨ��������������������������⣬�����ü��� alpha ͨ������������������°�� Mozilla�����¼��ؽű���

����

image

��ͼ�󴴽�����(����imagecreatetruecolor())���ص�ͼ����Դ��

saveflag

�Ƿ񱣴�͸����alpha��ͨ���� Ĭ�� FALSE��

����ֵ

�ɹ�ʱ���� TRUE�� ������ʧ��ʱ���� FALSE��

����

Example #1 imagesavealpha() ����

<?php
// ����� alpha ͨ���� png ͼ��
$png = imagecreatefrompng('./alphachannel_example.png');

// ��Щ����IJ���

// �ر� alpha ��Ⱦ������ alpha ��־
imagealphablending($png, false);
imagesavealpha($png, true);

// ���ͼ�������
header('Content-Type: image/png');

imagepng($png);
imagedestroy($png);
?>

ע��

Note: �˺�����Ҫ GD 2.0.1 ����߰汾(�Ƽ� 2.0.28 �����߰汾)��

�μ�