function draw_gnuplot($array)
{
    $pollutant = $array[0]['pollutant'];
    if ($pollutant == 'pm10' || $pollutant == 'pm2.5') {
        $c1 = 10;
        $c2 = 40;
    } else {
        if ($pollutant == 'co') {
            $c1 = 0;
            $c2 = 10;
        } else {
            $c1 = 0;
            $c2 = 1;
        }
    }
    $path = 'http://www.hazewatch.unsw.edu.au';
    //$image = imagecreatefrompng($_SERVER["DOCUMENT_ROOT"].'/cgi-bin/contour.cgi');
    $mask = imagecreatefrompng($_SERVER["DOCUMENT_ROOT"] . '/images/old_imagemask.png');
    $image = imagecreatefrompng($path . '/cgi-bin/contour.cgi?c1=' . $c1 . '&c2=' . $c2);
    imagealphamask($image, $mask);
    header('Content-Type: image/png');
    imagepng($image);
    return true;
}
Exemple #2
0
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}';
    }
}
/********* Toolheads *************/
$tooltypes = array("axe", "hoe", "pickaxe", "saw", "shovel", "sword", "hammer", "sickle");
foreach ($tooltypes as $tooltype) {
    $mask = imagecreatefrompng('textures/items/toolhead/layer_' . $tooltype . '.png');
    foreach ($metals as $metal) {
        if (!file_exists("textures/items/tool/{$metal}_{$tooltype}.png")) {
            continue;
        }
        $source = imagecreatefrompng("textures/items/tool/{$metal}_{$tooltype}.png");
        imagealphamask($source, $mask);
        imagepng($source, "textures/items/toolhead/{$metal}_{$tooltype}.png");
    }
}
function imagealphamask(&$picture, $mask)
{
    // Get sizes and set up new picture
    $xSize = imagesx($picture);
    $ySize = imagesy($picture);
    $newPicture = imagecreatetruecolor($xSize, $ySize);
    imagesavealpha($newPicture, true);
    imagefill($newPicture, 0, 0, imagecolorallocatealpha($newPicture, 0, 0, 0, 127));
    // Resize mask if necessary
    if ($xSize != imagesx($mask) || $ySize != imagesy($mask)) {
        $tempPic = imagecreatetruecolor($xSize, $ySize);
        imagecopyresampled($tempPic, $mask, 0, 0, 0, 0, $xSize, $ySize, imagesx($mask), imagesy($mask));
Exemple #3
0
imagesavealpha($mapLayerImg, true);
$colorTransparent = imagecolorallocatealpha($mapLayerImg, 255, 255, 255, 0);
imagefill($mapLayerImg, 0, 0, $colorTransparent);
//colors
$colorBg = imagecolorallocate($img, 255, 255, 255);
$colorShadow = imagecolorallocate($img, 255, 255, 255);
$colorBorder = imagecolorallocate($img, 0, 0, 0);
$colorHeader = imagecolorallocate($img, 207, 13, 14);
$colorRoute = imagecolorallocate($img, 50, 50, 50);
$colorText = imagecolorallocate($img, 120, 120, 120);
//fill bg
imagefilledrectangle($img, 0, 0, $dstWidth, $dstHeight, $colorBg);
imagecopyresized($img, $bgImg, 0, 0, 0, 0, 640, 640, $srcWidth, $srcHeight);
imagecopyresized($img, $textImg, 0, 0, 0, 0, $dstWidth, $dstHeight, $dstWidth, $dstHeight);
imagecopyresized($mapLayerImg, $mapImg, $dstWidth - 550, $dstHeight - 180, 0, 50, 600, 300, 600, 300);
imagealphamask($mapLayerImg, $maskLayerImg);
imagecopyresized($img, $mapLayerImg, 0, 0, 0, 0, $dstWidth, $dstHeight, $dstWidth, $dstHeight);
imagecopyresized($img, $dotLayerImg, 840, 550, 0, 0, 200, 100, 200, 100);
//header text
$box = new Box($img);
$box->setFontFace(__DIR__ . '/fonts/Amatic-Bold.ttf');
$box->setFontColor($colorHeader);
$box->setFontSize(80);
$box->setLineHeight(1);
$box->setBox(580, 70, 480, 50);
$box->setTextAlign('center', 'center');
$box->draw($headerText);
//route box
$box = new Box($img);
$box->setFontFace(__DIR__ . '/fonts/Lato-Medium.ttf');
$box->setFontColor($colorRoute);
Exemple #4
0
<?php

$source = imagecreatefrompng('photo.png');
$mask = imagecreatefrompng('cur3-3.png');
$xSize_picture = imagesx($source);
$ySize_picture = imagesy($source);
$xSize = imagesx($mask);
$ySize = imagesy($mask);
$rand_x = rand($xSize_picture / 2, $xSize_picture - $xSize);
$rand_y = rand($ySize, $ySize_picture - $ySize);
/////////////////////////////========抠出小图片=========/////////////////////////////////
//$source = imagecreatefrompng( 'photo.png');
imagealphamask($source, $mask, $xSize, $ySize, $rand_x, $rand_y);
/////////////////////////////=======合并出背景图片==========/////////////////////////////////
$mask = imagecreatefrompng('cur_tou40lh.png');
//换一个透明度的蒙版图片
imagealphamerge($source, $mask, $xSize, $ySize, $rand_x, $rand_y);
imagedestroy($source);
/////////////////////////////=================/////////////////////////////////
function imagealphamerge($picture, $mask, $xSize, $ySize, $rand_x, $rand_y)
{
    //imagecopymerge($picture, $mask, $rand_x, $rand_y, 0, 0, $xSize,$ySize , 100);
    imagecopy($picture, $mask, $rand_x, $rand_y, 0, 0, $xSize, $ySize);
    // 将图像保存到文件,并释放内存
    header('Content-type: image/png');
    imagepng($picture);
    imagepng($picture, 'source_test.png');
}
function imagealphamask($picture, $mask, $xSize, $ySize, $rand_x, $rand_y)
{
    $newPicture = imagecreatetruecolor($xSize, $ySize);
Exemple #5
0
<?php

include dirname(__FILE__) . '/_init.php';
$mask = imagecreatefrompng('images/alpha-star.png');
$im = imagecreatefromjpeg('images/mutzig.jpg');
imagealphamask($im, $mask);
imagepng($im, 'output/masked-1.png');
$mask = imagecreatefrompng('images/alpha-star.png');
$im = imagecreatefromjpeg('images/mutzig.jpg');
imagealphamask($im, $mask, IMAGE_EX_MASK_TILE);
imagepng($im, 'output/masked-2.png');
$mask = imagecreatefrompng('images/alpha-star.png');
$im = imagecreatefromjpeg('images/mutzig.jpg');
imagealphamask($im, $mask, IMAGE_EX_MASK_TILE | IMAGE_EX_MASK_NOT);
imagepng($im, 'output/masked-3.png');