コード例 #1
0
 public static function Barcode39($barcode, $width, $height, $quality, $text, $path)
 {
     $im = ImageCreate($width, $height) or die("Cannot Initialize new GD image stream");
     $White = ImageColorAllocate($im, 255, 255, 255);
     $Black = ImageColorAllocate($im, 0, 0, 0);
     //ImageColorTransparent ($im, $White);
     ImageInterLace($im, 1);
     $NarrowRatio = 20;
     $WideRatio = 55;
     $QuietRatio = 35;
     $nChars = (strlen($barcode) + 2) * (6 * $NarrowRatio + 3 * $WideRatio + $QuietRatio);
     $Pixels = $width / $nChars;
     $NarrowBar = (int) (20 * $Pixels);
     $WideBar = (int) (55 * $Pixels);
     $QuietBar = (int) (35 * $Pixels);
     $ActualWidth = ($NarrowBar * 6 + $WideBar * 3 + $QuietBar) * (strlen($barcode) + 2);
     if ($NarrowBar == 0 || $NarrowBar == $WideBar || $NarrowBar == $QuietBar || $WideBar == 0 || $WideBar == $QuietBar || $QuietBar == 0) {
         ImageString($im, 1, 0, 0, "Image is too small!", $Black);
         OutputImage($im, $format, $quality);
         exit;
     }
     $CurrentBarX = (int) (($width - $ActualWidth) / 2);
     $Color = $White;
     $BarcodeFull = "*" . strtoupper($barcode) . "*";
     settype($BarcodeFull, "string");
     $FontNum = 3;
     $FontHeight = ImageFontHeight($FontNum);
     $FontWidth = ImageFontWidth($FontNum);
     if ($text != 0) {
         $CenterLoc = (int) (($width - 1) / 2) - (int) ($FontWidth * strlen($BarcodeFull) / 2);
         ImageString($im, $FontNum, $CenterLoc, $height - $FontHeight, "{$BarcodeFull}", $Black);
     } else {
         $FontHeight = -2;
     }
     for ($i = 0; $i < strlen($BarcodeFull); $i++) {
         $StripeCode = self::Code39($BarcodeFull[$i]);
         for ($n = 0; $n < 9; $n++) {
             if ($Color == $White) {
                 $Color = $Black;
             } else {
                 $Color = $White;
             }
             switch ($StripeCode[$n]) {
                 case '0':
                     ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $NarrowBar, $height - 1 - $FontHeight - 2, $Color);
                     $CurrentBarX += $NarrowBar;
                     break;
                 case '1':
                     ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $WideBar, $height - 1 - $FontHeight - 2, $Color);
                     $CurrentBarX += $WideBar;
                     break;
             }
         }
         $Color = $White;
         ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $QuietBar, $height - 1 - $FontHeight - 2, $Color);
         $CurrentBarX += $QuietBar;
     }
     return ImageJPEG($im, $path, $quality);
 }
コード例 #2
0
ファイル: printbcpha1.php プロジェクト: robocon/shs
function Barcode39 ($barcode, $width, $height, $quality, $format, $text)
{
switch ($format)
{
default:
$format = "JPEG";
case "JPEG": 
header ("Content-type: image/jpeg");
break;
case "PNG":
header ("Content-type: image/png");
break;
case "GIF":
header ("Content-type: image/gif");
break;
}


$im = ImageCreate ($width, $height)
or die ("Cannot Initialize new GD image stream");
$White = ImageColorAllocate ($im, 255, 255, 255);
$Black = ImageColorAllocate ($im, 0, 0, 0);
//ImageColorTransparent ($im, $White);
ImageInterLace ($im, 1);



$NarrowRatio = 20;
$WideRatio = 55;
$QuietRatio = 35;


$nChars = (strlen($barcode)+2) * ((6 * $NarrowRatio) + (3 * $WideRatio) + ($QuietRatio));
$Pixels = $width / $nChars;
$NarrowBar = (int)(20 * $Pixels);
$WideBar = (int)(55 * $Pixels);
$QuietBar = (int)(35 * $Pixels);


$ActualWidth = (($NarrowBar * 6) + ($WideBar*3) + $QuietBar) * (strlen ($barcode)+2);

if (($NarrowBar == 0) || ($NarrowBar == $WideBar) || ($NarrowBar == $QuietBar) || ($WideBar == 0) || ($WideBar == $QuietBar) || ($QuietBar == 0))
{
ImageString ($im, 1, 0, 0, "Image is too small!", $Black);
OutputImage ($im, $format, $quality);
exit;
}

$CurrentBarX = (int)(($width - $ActualWidth) / 2);
$Color = $White;
$BarcodeFull = "*".strtoupper ($barcode)."*";
settype ($BarcodeFull, "string");

$FontNum = 3;
$FontHeight = ImageFontHeight ($FontNum);
$FontWidth = ImageFontWidth ($FontNum);
if ($text != 0)
{
$CenterLoc = (int)(($width-1) / 2) - (int)(($FontWidth * strlen($BarcodeFull)) / 2);
ImageString ($im, $FontNum, $CenterLoc, $height-$FontHeight, "$BarcodeFull", $Black);
}
else
{
$FontHeight=-2;
}


for ($i=0; $i<strlen($BarcodeFull); $i++)
{
$StripeCode = Code39 ($BarcodeFull[$i]);


for ($n=0; $n < 9; $n++)
{
if ($Color == $White) $Color = $Black;
else $Color = $White;


switch ($StripeCode[$n])
{
case '0':
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$NarrowBar, $height-1-$FontHeight-2, $Color);
$CurrentBarX += $NarrowBar;
break;


case '1':
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$WideBar, $height-1-$FontHeight-2, $Color);
$CurrentBarX += $WideBar;
break;
}
}


$Color = $White;
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$QuietBar, $height-1-$FontHeight-2, $Color);
$CurrentBarX += $QuietBar;
}


OutputImage ($im, $format, $quality);
}
コード例 #3
0
ファイル: barcode.php プロジェクト: gocanto/gocanto-pos
function Barcode39($barcode, $width, $height, $quality, $format, $text)
{
    switch ($format) {
        default:
            $format = 'JPEG';
        case 'JPEG':
            header('Content-type: image/jpeg');
            break;
        case 'PNG':
            header('Content-type: image/png');
            break;
        case 'GIF':
            header('Content-type: image/gif');
            break;
    }
    $im = ImageCreate($width, $height) or die('Cannot Initialize new GD image stream');
    $White = ImageColorAllocate($im, 255, 255, 255);
    $Black = ImageColorAllocate($im, 0, 0, 0);
    //ImageColorTransparent ($im, $White);
    ImageInterLace($im, 1);
    $NarrowRatio = 20;
    $WideRatio = 55;
    $QuietRatio = 35;
    $nChars = (strlen($barcode) + 2) * (6 * $NarrowRatio + 3 * $WideRatio + $QuietRatio);
    $Pixels = $width / $nChars;
    $NarrowBar = (int) (20 * $Pixels);
    $WideBar = (int) (55 * $Pixels);
    $QuietBar = (int) (35 * $Pixels);
    $ActualWidth = ($NarrowBar * 6 + $WideBar * 3 + $QuietBar) * (strlen($barcode) + 2);
    if ($NarrowBar == 0 || $NarrowBar == $WideBar || $NarrowBar == $QuietBar || $WideBar == 0 || $WideBar == $QuietBar || $QuietBar == 0) {
        ImageString($im, 1, 0, 0, 'Image is too small!', $Black);
        OutputImage($im, $format, $quality);
        exit;
    }
    $CurrentBarX = (int) (($width - $ActualWidth) / 2);
    $Color = $White;
    $BarcodeFull = '*' . strtoupper($barcode) . '*';
    settype($BarcodeFull, 'string');
    $FontNum = 3;
    $FontHeight = ImageFontHeight($FontNum);
    $FontWidth = ImageFontWidth($FontNum);
    if ($text != '') {
        $CenterLoc = (int) ($width / 2) - (int) ($FontWidth * strlen($text) / 2);
        ImageString($im, $FontNum, $CenterLoc, $height - $FontHeight, "{$text}", $Black);
    }
    for ($i = 0; $i < strlen($BarcodeFull); $i++) {
        $StripeCode = Code39($BarcodeFull[$i]);
        for ($n = 0; $n < 9; $n++) {
            if ($Color == $White) {
                $Color = $Black;
            } else {
                $Color = $White;
            }
            switch ($StripeCode[$n]) {
                case '0':
                    ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $NarrowBar, $height - 1 - $FontHeight - 2, $Color);
                    $CurrentBarX += $NarrowBar;
                    break;
                case '1':
                    ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $WideBar, $height - 1 - $FontHeight - 2, $Color);
                    $CurrentBarX += $WideBar;
                    break;
            }
        }
        $Color = $White;
        ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $QuietBar, $height - 1 - $FontHeight - 2, $Color);
        $CurrentBarX += $QuietBar;
    }
    OutputImage($im, $format, $quality);
}
コード例 #4
0
ファイル: chartbig.php プロジェクト: robocon/iopr
    $start = $end;
    $value_counter++;
}
for ($i = $centerY + $shadow_height; $i > $centerY; $i--) {
    for ($j = 0; $j < count($slice); $j++) {
        if ($slice[$j][0] != $slice[$j][1]) {
            ImageFilledArc($img, $centerX, $i, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][2], IMG_ARC_PIE);
        }
    }
}
for ($j = 0; $j < count($slice); $j++) {
    if ($slice[$j][0] != $slice[$j][1]) {
        ImageFilledArc($img, $centerX, $centerY, $diameterX, $diameterY, $slice[$j][0], $slice[$j][1], $slice[$j][3], IMG_ARC_PIE);
    }
}
OutputImage($img);
ImageDestroy($img);
function colorHex($img, $HexColorString)
{
    $R = hexdec(substr($HexColorString, 0, 2));
    $G = hexdec(substr($HexColorString, 2, 2));
    $B = hexdec(substr($HexColorString, 4, 2));
    return ImageColorAllocate($img, $R, $G, $B);
}
function colorHexshadow($img, $HexColorString, $mork)
{
    $R = hexdec(substr($HexColorString, 0, 2));
    $G = hexdec(substr($HexColorString, 2, 2));
    $B = hexdec(substr($HexColorString, 4, 2));
    if ($mork) {
        $R > 99 ? $R -= 100 : ($R = 0);
コード例 #5
0
ファイル: default.php プロジェクト: bizanto/Hooked
 }
 if ($params->get('commentstable') != '0') {
     $dcomm = OutputComments($params->get('uselangfile'), $commentprefix, $commenti, $commenttitle, $params->get('show_comment_image'), $body_bottom_css);
 }
 if ($checkhits !== false) {
     $dhits = OutputHits($params->get('show_hits_image'), $params->get('uselangfile'), $hitprefix, $row->hits, $hittitle, $body_bottom_css);
 }
 if ($checkrating !== false) {
     $drating = OutputRating($params->get('show_rating_image'), $params->get('uselangfile'), $ratingprefix, $voti, $ratingtitle, $body_bottom_css);
 }
 $drm = OutputRM($params->get('uselangfile'), $link, $params->get('continue_reading'), $params->get('readmore'), $titolo, $row->title, $readmore_css);
 if ($checkaddcomm !== false) {
     $daddcomm = Outputaddcomm($params->get('uselangfile'), $link, $addcomm, $readmore_css, $commentstable);
 }
 if ($params->get('show_image') != '0') {
     $dimage = OutputImage($imgfloat, $image_css, $link, $params->get('artblank'), $image_url, $params->get('use_tooltips'), $titolo, $intro);
 }
 if ($checkf1 !== false) {
     $df1 = OutputField($flexi_fields_css, $flexifield1, $ft1);
 }
 if ($checkf2 !== false) {
     $df2 = OutputField($flexi_fields_css, $flexifield2, $ft2);
 }
 if ($checkf3 !== false) {
     $df3 = OutputField($flexi_fields_css, $flexifield3, $ft3);
 }
 if ($checkf4 !== false) {
     $df4 = OutputField($flexi_fields_css, $flexifield4, $ft4);
 }
 if ($checkf5 !== false) {
     $df5 = OutputField($flexi_fields_css, $flexifield5, $ft5);
コード例 #6
0
function Barcode39($barcode, $width, $height, $quality, $format, $text)
{
    switch ($format) {
        default:
            $format = "JPEG";
        case "JPEG":
            header("Content-type: image/jpeg");
            break;
        case "PNG":
            header("Content-type: image/png");
            break;
        case "GIF":
            header("Content-type: image/gif");
            break;
    }
    $height1 = 35;
    $im = ImageCreate($width, $height1) or die("Cannot Initialize new GD image stream");
    $White = ImageColorAllocate($im, 255, 255, 255);
    $Black = ImageColorAllocate($im, 0, 0, 0);
    ImageInterLace($im, 1);
    $NarrowRatio = 20;
    $WideRatio = 55;
    $QuietRatio = 35;
    $nChars = (strlen($barcode) + 2) * (6 * $NarrowRatio + 3 * $WideRatio + $QuietRatio);
    $Pixels = $width / $nChars;
    $NarrowBar = (int) (20 * $Pixels);
    $WideBar = (int) (55 * $Pixels);
    $QuietBar = (int) (35 * $Pixels);
    $ActualWidth = ($NarrowBar * 6 + $WideBar * 3 + $QuietBar) * (strlen($barcode) + 2);
    $CurrentBarX = (int) (($width - $ActualWidth) / 2);
    $Color = $White;
    $BarcodeFull = "*" . strtoupper($barcode) . "*";
    settype($BarcodeFull, "string");
    $FontNum = 3;
    $FontHeight = ImageFontHeight($FontNum);
    $FontWidth = ImageFontWidth($FontNum);
    for ($i = 0; $i < strlen($BarcodeFull); $i++) {
        $StripeCode = Code39($BarcodeFull[$i]);
        for ($n = 0; $n < 9; $n++) {
            if ($Color == $White) {
                $Color = $Black;
            } else {
                $Color = $White;
            }
            switch ($StripeCode[$n]) {
                case '0':
                    ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $NarrowBar, $height - 1 - $FontHeight - 2, $Color);
                    $CurrentBarX += $NarrowBar;
                    break;
                case '1':
                    ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $WideBar, $height - 1 - $FontHeight - 2, $Color);
                    $CurrentBarX += $WideBar;
                    break;
            }
        }
        $Color = $White;
        ImageFilledRectangle($im, $CurrentBarX, 0, $CurrentBarX + $QuietBar, $height - 1 - $FontHeight - 2, $Color);
        $CurrentBarX += $QuietBar;
    }
    OutputImage($im, $format, $quality);
}