コード例 #1
0
function setImage($x, $y, $image)
{
    global $bcg, $wsp;
    $part_image = getimagesize($image);
    if ($part_image['mime'] == 'image/jpeg') {
        $img = imagecreatefromjpeg($image);
    }
    if ($part_image['mime'] == 'image/gif') {
        $img = imagecreatefromgif($image);
    }
    if ($part_image['mime'] == 'image/png') {
        $img = imagecreatefrompng($image);
    }
    list($img_width, $img_height) = $part_image;
    $img_new_width = $img_width * $wsp;
    $img_new_height = $img_height * $wsp;
    $thumb = imagecreatetruecolor($img_new_width, $img_new_height);
    imagecopyresized($thumb, $img, 0, 0, 0, 0, $img_new_width, $img_new_height, $img_width, $img_height);
    imagecopymerge($bcg, $thumb, $x * $wsp, $y * $wsp, 0, 0, imagesx($thumb), imagesy($thumb), 100);
    $black = imagecolorallocate($bcg, 0, 0, 0);
    /*		LEFT	*/
    imageBoldLine($bcg, $x * $wsp, $y * $wsp, $x * $wsp, $y * $wsp + imagesy($thumb), $black, 2);
    /*		TOP	*/
    imageBoldLine($bcg, $x * $wsp, $y * $wsp, $x * $wsp + imagesx($thumb), $y * $wsp, $black, 2);
    /*		BOTTOM	*/
    imageBoldLine($bcg, $x * $wsp, $y * $wsp + imagesy($thumb), $x * $wsp + imagesx($thumb), $y * $wsp + imagesy($thumb), $black, 2);
    /*		RIGHT	*/
    imageBoldLine($bcg, $x * $wsp + imagesx($thumb), $y * $wsp, $x * $wsp + imagesx($thumb), $y * $wsp + imagesy($thumb), $black, 2);
}
コード例 #2
0
ファイル: attendance_diagram.php プロジェクト: Blu2z/implsk
function drawLegend($img, $report, $caption_color, $color1, $color2, $color3, $caption1, $caption2, $caption3)
{
    global $ttf_font_file, $nc_core;
    $y_step = 40;
    $base_x = DIAGRAM_WIDTH + DIAGRAM_X + 25;
    //imagettftext($img, 12, 0, $base_x, DIAGRAM_Y, $caption_color, $ttf_font_file, $report['title']);
    $y = DIAGRAM_Y + 25;
    $x = $base_x + 12 + nc_strlen($caption1) * 7;
    if (!$nc_core->NC_UNICODE) {
        $caption1 = $nc_core->utf8->win2utf($caption1);
    }
    imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption1);
    imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color3, 3);
    //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][2]);
    $y = $y + $y_step;
    $x = $base_x + 12 + nc_strlen($caption2) * 7;
    if (!$nc_core->NC_UNICODE) {
        $caption2 = $nc_core->utf8->win2utf($caption2);
    }
    imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption2);
    imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color2, 3);
    //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][1]);
    $y = $y + $y_step;
    $x = $base_x + 12 + nc_strlen($caption3) * 7;
    if (!$nc_core->NC_UNICODE) {
        $caption3 = $nc_core->utf8->win2utf($caption3);
    }
    imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption3);
    imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color1, 3);
    //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][0]);
}