Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	README
  • Loading branch information
CloCkWeRX committed Dec 11, 2011
2 parents be135fb + 8e71cee commit 324b699
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Image/Barcode2.php
Expand Up @@ -86,7 +86,7 @@ class Image_Barcode2
* @author Marcelo Subtil Marcal <msmarcal@php.net>
* @since Image_Barcode2 0.3
*/
public function draw($text,
public static function draw($text,
$type = Image_Barcode2::BARCODE_INT25,
$imgtype = Image_Barcode2::IMAGE_PNG,
$bSendToBrowser = true,
Expand Down
39 changes: 6 additions & 33 deletions Image/Barcode2/Code39.php
Expand Up @@ -120,46 +120,20 @@ class Image_Barcode2_Code39
' ' => '011000100'
);

/**
* Constructor
*
* @param string $text A text that should be in the image barcode
* @param int $wThin Width of the thin lines on the barcode
* @param int $wThick Width of the thick lines on the barcode
*
* @author Ryan Briones <ryanbriones@webxdesign.org>
*
*/
public function __construct($text = '', $wThin = 0, $wThick = 0)
{
// Check $text for invalid characters
if ($this->_checkInvalid($text)) {
return false;
}

$this->text = $text;
if ($wThin > 0 ) {
$this->_barthinwidth = $wThin;
}
if ($wThick > 0 ) {
$this->_barthickwidth = $wThick;
}

return true;
}

/**
* Make an image resource using the GD image library
*
* @param string $text A text that should be in the image barcode
* @return resource The Barcode Image (TM)
*
* @author Ryan Briones <ryanbriones@webxdesign.org>
*
*/
private function _plot()
private function _plot($text)
{
// add start and stop * characters
$final_text = '*' . $this->text . '*';
$final_text = '*' . $text . '*';

$barcode = '';
foreach (str_split($final_text) as $character) {
Expand Down Expand Up @@ -212,9 +186,9 @@ private function _plot()
imagestring(
$img,
$this->_font_size,
($barcode_len - $font_width * strlen($this->text))/2,
($barcode_len - $font_width * strlen($this->text)) / 2,
$this->_barcodeheight - $font_height,
$this->text,
$text,
$black
);

Expand All @@ -240,8 +214,7 @@ public function draw($text)
return 'Invalid text';
}

$this->text = $text;
return $this->_plot();
return $this->_plot($text);
}


Expand Down
7 changes: 4 additions & 3 deletions Image/Barcode2/ean13.php
Expand Up @@ -152,10 +152,10 @@ public function draw($text)
+ 3 * $this->_barwidth // left
+ 5 * $this->_barwidth // center
+ 3 * $this->_barwidth // right
+ imagefontwidth($this->_font)+1
+ imagefontwidth($this->_font) + 1
;

$barcodelongheight = (int) (imagefontheight($this->_font)/2)
$barcodelongheight = (int) (imagefontheight($this->_font) / 2)
+ $this->_barcodeheight;

// Create the image
Expand Down Expand Up @@ -219,7 +219,7 @@ public function draw($text)
$black
);

foreach ($this->_number_set[$value][$set_array[$idx-1]] as $bar) {
foreach ($this->_number_set[$value][$set_array[$idx - 1]] as $bar) {
if ($bar) {
imagefilledrectangle(
$img,
Expand Down Expand Up @@ -318,4 +318,5 @@ public function draw($text)
} // function create

} // class

?>
1 change: 1 addition & 0 deletions Image/Barcode2/ean8.php
Expand Up @@ -287,4 +287,5 @@ public function draw($text)
} // function create

} // class

?>
2 changes: 1 addition & 1 deletion docs/Readme.txt
Expand Up @@ -24,7 +24,7 @@ Application Repository homepage at http://pear.php.net

Just load the class in your script:

require_once('Image/Barcode.php');
require_once('Image/Barcode2.php');

Call the Image_Barcode2::draw() as the follow:

Expand Down

0 comments on commit 324b699

Please sign in to comment.