Source for file int25.php
Documentation is available at int25.php
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2001 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Marcelo Subtil Marcal <jason@unleashed.com.br> |
// +----------------------------------------------------------------------+
// $Id: int25.php,v 1.2 2003/01/21 11:46:20 jason Exp $
require_once "Image/Barcode.php";
* Class to create a Interleaved 2 of 5 barcode
* @author Marcelo Subtil Marcal <jason@conectiva.com.br>
class Image_Barcode_int25 extends Image_Barcode
var $_barcodeheight = 50;
var $_coding_map = array (
function draw ($text, $imgtype = 'png')
// if odd $text lenght adds a '0' at string beginning
$text = strlen($text) % 2 ? '0' . $text : $text;
// Calculate the barcode width
$barcodewidth = (strlen($text)) * (3 * $this->_barthinwidth + 2 * $this->_barthickwidth) +
(7 * $this->_barthinwidth + $this->_barthickwidth) + 3;
$img = ImageCreate ($barcodewidth, $this->_barcodeheight);
// Alocate the black and white colors
$black = ImageColorAllocate ($img, 0 , 0 , 0 );
$white = ImageColorAllocate ($img, 255 , 255 , 255 );
// Fill image with white color
for ($i=0; $i < 2; $i++ ) {
$elementwidth = $this->_barthinwidth;
$xpos += $this->_barthinwidth;
for ($idx = 0; $idx < strlen($text); $idx += 2 ) { // Draw 2 chars at a time
$oddchar = substr($text, $idx, 1 ); // get odd char
$evenchar = substr($text, $idx + 1 , 1 ); // get even char
for ($baridx = 0; $baridx < 5; $baridx++ ) {
// Draws odd char corresponding bar (black)
$elementwidth = (substr($this->_coding_map[$oddchar], $baridx, 1 )) ? $this->_barthickwidth : $this->_barthinwidth;
// Left enought space to draw even char (white)
$elementwidth = (substr($this->_coding_map[$evenchar], $baridx, 1 )) ? $this->_barthickwidth : $this->_barthinwidth;
$elementwidth = $this->_barthickwidth;
$xpos += $this->_barthinwidth;
$elementwidth = $this->_barthinwidth;
header("Content-type: image/gif");
header("Content-type: image/jpg");
header("Content-type: image/png");
Documentation generated on Mon, 11 Mar 2019 14:21:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|