$data .= chr(0xff);
}
for ($i = 0; $i < 2; $i++) {
    $data .= chr(0x0);
    $data .= chr(0xff);
    $data .= chr(0x0);
    $data .= chr(0xff);
    $data .= chr(0x0);
    $data .= chr(0xff);
    $data .= chr(0x0);
    $data .= chr(0xff);
    $data .= chr(0xff);
    $data .= chr(0x0);
    $data .= chr(0x0);
    $data .= chr(0xff);
    $data .= chr(0xff);
    $data .= chr(0x0);
    $data .= chr(0x0);
    $data .= chr(0xff);
}
$con->setSourceRgb(0, 0, 0);
$con->paint();
$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$s->createForData($data, CairoFormat::RGB24, 4, 4, 16);
//$con->test_paint_checkered();
$con->scale(0.5, 0.5);
$con->setSourceSurface($s, 4, 4);
$pat = $con->getSource();
$pat->setFilter(CairoFilter::NEAREST);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/scale-down-source-surface-paint-php.png");
Exemplo n.º 2
0
$c = array();
$color = "";
$color .= chr(0xff);
$color .= chr(0xff);
$color .= chr(0xff);
$color .= chr(0xff);
$c[0] = $color;
$color = "";
$color .= chr(0x0);
$color .= chr(0x0);
$color .= chr(0xff);
$color .= chr(0xff);
$c[1] = $color;
$color = "";
$color .= chr(0x0);
$color .= chr(0xff);
$color .= chr(0x0);
$color .= chr(0xff);
$c[2] = $color;
$color = "";
$color .= chr(0xff);
$color .= chr(0x0);
$color .= chr(0x0);
$color .= chr(0xff);
$c[3] = $color;
for ($i = 0; $i < 4; $i++) {
    $s->createForData($c[$i], CairoFormat::RGB24, 1, 1, 4);
    $con->setSourceSurface($s, $i % 2, $i / 2);
    $con->paint();
}
$sur->writeToPng(dirname(__FILE__) . "/move-to-show-surface-php.png");
Exemplo n.º 3
0
$con = new CairoContext($sur);
$con->setSourceRgb(0, 0, 1);
$con->paint();
$s = new CairoImageSurface(CairoFormat::A1, 6400, 20);
$stride = $s->getStride();
$height = $s->getHeight();
$width = $s->getWidth();
$data = "";
for ($y = 0; $y < $height; $y++) {
    for ($x = 0; $x < ($width + 7) / 8; $x++) {
        $data = $data . chr(5);
    }
}
$s->createForData($data, CairoFormat::A1, $width, $height, $stride);
$con->setSourceRgb(1, 0, 0);
$con->maskSurface($s);
$con->fill();
$s = new CairoImageSurface(CairoFormat::A1, 20, 6400);
$stride = $s->getStride();
$height = $s->getHeight();
$width = $s->getWidth();
$data = "";
for ($y = 0; $y < $height; $y++) {
    for ($x = 0; $x < ($width + 7) / 8; $x++) {
        $data = $data . chr(80);
    }
}
$s->createForData($data, CairoFormat::A1, $width, $height, $stride);
$con->setSourceRgb(0, 1, 0);
$con->maskSurface($s, 0, 0);
$sur->writeToPng(dirname(__FILE__) . "/large-source-php.png");
Exemplo n.º 4
0
<?php

$sur = new CairoImageSurface(CairoFormat::ARGB32, 10, 10);
$con = new CairoContext($sur);
$data = "";
for ($i = 0; $i < 4; $i++) {
    $data = $data . chr(0x80);
    $data = $data . chr(0x0);
    $data = $data . chr(0x0);
    $data = $data . chr(0x0);
}
$s = new CairoImageSurface(CairoFormat::ARGB32, 1, 1);
$s->createForData(data, CairoFormat::ARGB32, 2, 2, 8);
$pat = new CairoSurfacePattern($s);
$con->setSourceRgb(1, 0, 0);
$con->save();
$con->translate(2, 2);
$con->mask($pat);
$con->restore();
$mat = new CairoMatrix();
$mat->translate(-4, -4);
$pat->setMatrix($mat);
$con->mask($pat);
$con->translate(2, 2);
$con->mask($pat);
$sur->writeToPng(dirname(__FILE__) . "/mask-ctm-php.png");
?>



Exemplo n.º 5
0
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x80);
}
for ($i = 0; $i < 2; $i++) {
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x80);
    $data .= chr(0x0);
    $data .= chr(0x0);
    $data .= chr(0x80);
    $data .= chr(0x80);
    $data .= chr(0x0);
    $data .= chr(0x0);
    $data .= chr(0x80);
}
echo $data;
$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$s->createForData($data, CairoFormat::ARGB32, 4, 4, 16);
$con->scale(4, 4);
$con->setSourceSurface($s, 2, 2);
$pat = $con->getSource();
$pat->setFilter(CairoFilter::NEAREST);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/paint-source-alpha-php.png");
Exemplo n.º 6
0
$sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height);
$con = new CairoContext($sur);
$s = new CairoImageSurface(CairoFormat::A1, $width, $height);
$str = "";
$stride = $s->getStride();
echo "Stride: " . $stride . "\n";
for ($i = 0; $i < 8; $i++) {
    $str = $str . chr(0x14);
    $str = $str . chr(0xaa);
    /*$str=$str . chr(255);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(255);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(0);*/
}
echo $str;
$s->createForData($str, CairoFormat::A1, $width, $height);
$con->setSourceRgb(0, 0, 1);
$con->paint();
$con->setSourceRgb(1, 0, 0);
$con->maskSurface($s, 0, 0);
$sur->writeToPng(dirname(__FILE__) . "/a1-mask-php.png");
?>

Exemplo n.º 7
0
<?php

$sur = new CairoImageSurface(CairoFormat::ARGB32, 5, 5);
$con = new CairoContext($sur);
$color = '';
$color .= chr(0x4c);
$color .= chr(0x33);
$color .= chr(0x19);
$color .= chr(0x80);
$s = new CairoImageSurface(CairoFormat::ARGB32, 1, 1);
$s->createForData($color, CairoFormat::ARGB32, 1, 1, 4);
$pat = new CairoSurfacePattern($s);
$pat->setExtend(CairoExtend::REPEAT);
for ($i = 0; $i < 5; $i++) {
    switch ($i) {
        case 0:
            $con->setSourceRgb(0.6, 0.7, 0.8);
            break;
        case 1:
            $con->setSourceRgba(0.2, 0.4, 0.6, 0.5);
            break;
        case 2:
            $con->setSourceRgba(0.2, 0.4, 0.6, 0.5);
            break;
        case 3:
        default:
            $con->setSource($pat);
    }
    $con->rectangle($i, 0, 1, 5);
    $con->fill();
}