Permalink
Browse files

#3 Have final driver use writer

  • Loading branch information...
1 parent 4e25dcc commit 12c507d80b75abdeb26a18703cf17d7b8bf5ad30 @CloCkWeRX committed Dec 11, 2011
Showing with 22 additions and 18 deletions.
  1. +8 −8 Image/Barcode2/Code39.php
  2. +4 −0 Image/Barcode2/Writer.php
  3. +10 −10 Image/Barcode2/code128.php
View
@@ -171,21 +171,21 @@ private function _plot($text)
$img = $this->writer->imagecreate($barcode_len, $this->_barcodeheight);
// Allocate black and white colors to the image
- $black = imagecolorallocate($img, 0, 0, 0);
- $white = imagecolorallocate($img, 255, 255, 255);
- $font_height = imagefontheight($this->_font_size);
- $font_width = imagefontwidth($this->_font_size);
+ $black = $this->writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $this->writer->imagecolorallocate($img, 255, 255, 255);
+ $font_height = $this->writer->imagefontheight($this->_font_size);
+ $font_width = $this->writer->imagefontwidth($this->_font_size);
// fill background with white color
- imagefill($img, 0, 0, $white);
+ $this->writer->imagefill($img, 0, 0, $white);
// Initialize X position
$xpos = 0;
// draw barcode bars to image
foreach (str_split($barcode) as $character_code) {
if ($character_code == 0) {
- imageline(
+ $this->writer->imageline(
$img,
$xpos,
0,
@@ -194,7 +194,7 @@ private function _plot($text)
$white
);
} else {
- imageline(
+ $this->writer->imageline(
$img,
$xpos,
0,
@@ -208,7 +208,7 @@ private function _plot($text)
}
// draw text under barcode
- imagestring(
+ $this->writer->imagestring(
$img,
$this->_font_size,
($barcode_len - $font_width * strlen($this->text)) / 2,
@@ -39,4 +39,8 @@ public function imagefontwidth($font) {
public function imagecolorallocate($image, $red, $green, $blue) {
return imagecolorallocate($image, $red, $green, $blue);
}
+
+ public function imageline($image, $x1, $y1, $x2, $y2, $color) {
+ return imageline($image, $x1, $y1, $x2, $y2, $color);
+ }
}
View
@@ -146,21 +146,21 @@ public function draw($text)
$barcodewidth += ($nval * $this->_barwidth);
}
- $barcodelongheight = (int) (imagefontheight($this->_font) / 2)
+ $barcodelongheight = (int)($this->writer->imagefontheight($this->_font) / 2)
+ $this->_barcodeheight;
// Then, we create the image, allocate the colors, and fill
// the image with a nice, white background, ready for printing
// our black bars and the text.
- $img = imagecreate(
+ $img = $this->writer->imagecreate(
$barcodewidth,
- $barcodelongheight + imagefontheight($this->_font) + 1
+ $barcodelongheight + $this->writer->imagefontheight($this->_font) + 1
);
- $black = imagecolorallocate($img, 0, 0, 0);
- $white = imagecolorallocate($img, 255, 255, 255);
- imagefill($img, 0, 0, $white);
+ $black = $this->writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $this->writer->imagecolorallocate($img, 255, 255, 255);
+ $this->writer->imagefill($img, 0, 0, $white);
//------------------------------------------------------//
@@ -169,11 +169,11 @@ public function draw($text)
// First, print the image, centered across the bottom.
- imagestring(
+ $this->writer->imagestring(
$img,
$this->_font,
- $barcodewidth / 2 - strlen($text) / 2 * (imagefontwidth($this->_font)),
- $this->_barcodeheight + imagefontheight($this->_font) / 2,
+ $barcodewidth / 2 - strlen($text) / 2 * ($this->writer->imagefontwidth($this->_font)),
+ $this->_barcodeheight + $this->writer->imagefontheight($this->_font) / 2,
$text,
$black
);
@@ -191,7 +191,7 @@ public function draw($text)
$width = $nval * $this->_barwidth;
if ($bar == 1) {
- imagefilledrectangle(
+ $this->writer->imagefilledrectangle(
$img,
$xpos,
0,

0 comments on commit 12c507d

Please sign in to comment.