Exemplo n.º 1
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.º 2
0
$stride = $s->getStride();
for ($i = 0; $i < 12; $i++) {
    $str = $str . chr(0x0);
    //blue
    $str = $str . chr(0x0);
    //green
    $str = $str . chr(0xff);
    //red
    $str = $str . chr(0xff);
    //alpha
    $str = $str . chr(0x0);
    $str = $str . chr(0xff);
    $str = $str . chr(0x0);
    $str = $str . chr(0xff);
    $str = $str . chr(0xff);
    $str = $str . chr(0x0);
    $str = $str . chr(0x0);
    $str = $str . chr(0xff);
    $str = $str . chr(0xff);
    $str = $str . chr(0xff);
    $str = $str . chr(0xff);
    $str = $str . chr(0xff);
}
$s->createForData($str, CairoFormat::ARGB32, $width, $height);
$wid = $s->getHeight();
$con->setSourceRgb(1, 1, 1);
$con->paint();
$con->setSourceSurface($s, 0, 0);
//$con->mask_surface($s,0,0);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/bilevel-image-php.png");