Annotation of embedaddon/php/ext/gd/tests/copypalette.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: imagepalettecopy
        !             3: --SKIPIF--
        !             4: <?php
        !             5:         if (!function_exists('imagecolorat')) die("skip gd extension not available\n");
        !             6: ?>
        !             7: --FILE--
        !             8: <?php
        !             9: $failed = false;
        !            10: $im = imagecreate(1,1);
        !            11: for ($i=0; $i<256; $i++) {
        !            12:        imagecolorallocate($im, $i, $i, $i);
        !            13: }
        !            14: 
        !            15: $im2 = imagecreate(1,1);
        !            16: imagepalettecopy($im2, $im);
        !            17: 
        !            18: for ($i=0; $i<256; $i++) {
        !            19:        $c = imagecolorsforindex($im2, $i);
        !            20:        if ($c['red']!=$i || $c['green']!=$i || $c['blue']!=$i) {
        !            21:                $failed = true;
        !            22:                break;
        !            23:        } 
        !            24: }
        !            25: echo "copy palette 255 colors: ";
        !            26: echo $failed ? 'failed' : 'ok';
        !            27: echo "\n";
        !            28: 
        !            29: $im = imagecreate(1,1);
        !            30: $im2 = imagecreate(1,1);
        !            31: imagecolorallocatealpha($im, 0,0,0,100);
        !            32: 
        !            33: imagepalettecopy($im2, $im);
        !            34: $c = imagecolorsforindex($im2, 0);
        !            35: if ($c['red']!=0 || $c['green']!=0 || $c['blue']!=0 || $c['alpha']!=100) {
        !            36:        $failed = true;
        !            37: } 
        !            38: echo 'copy palette 1 color and alpha: ';
        !            39: echo $failed ? 'failed' : 'ok';
        !            40: echo "\n";
        !            41: ?>
        !            42: --EXPECT--
        !            43: copy palette 255 colors: ok
        !            44: copy palette 1 color and alpha: ok

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>