Draws the barcode.

@param resource $im
970515
public function draw($im) {
        // The following code is exactly the same as EAN13. We just add a 0 in front of the code !
        $this->text = '0' . $this->text; // We will remove it at the end... don't worry

        parent::draw($im);

        // We remove the 0 in front, as we said :)
        $this->text = substr($this->text, 1);
    }
361109
public function addToImageMap(
        $Type,
        $Plots,
        $Color = null,
        $Title = null,
        $Message = null,
        $HTMLEncode = false
    ) {
        if ($this->ImageMapStorageMode == null) {
            $this->initialiseImageMap();
        }

        /* Encode the characters in the imagemap in HTML standards */
        $Title = htmlentities(
            str_replace("&#8364;", "\u20AC", $Title),
            ENT_QUOTES,
            "ISO-8859-15"
        );
        if ($HTMLEncode) {
            $Message = str_replace(
                "&gt;",
                ">",
                str_replace(
                    "&lt;",
                    "<",
                    htmlentities($Message, ENT_QUOTES, "ISO-8859-15")
                )
            );
        }

        if ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION) {
            if (!isset($_SESSION)) {
                $this->initialiseImageMap();
            }
            $_SESSION[$this->ImageMapIndex][] = [$Type, $Plots, $Color, $Title, $Message];
        } elseif ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE) {
            $Handle = fopen(
                sprintf("%s/%s.map", $this->ImageMapStorageFolder, $this->ImageMapFileName),
                'a'
            );
            fwrite(
                $Handle,
                sprintf(
                    "%s%s%s%s%s%s%s%s%s\r\n",
                    $Type,
                    IMAGE_MAP_DELIMITER,
                    $Plots,
                    IMAGE_MAP_DELIMITER,
                    $Color,
                    IMAGE_MAP_DELIMITER,
                    $Title,
                    IMAGE_MAP_DELIMITER,
                    $Message
                )
            );
            fclose($Handle);
        }
    }
341552
private void draw() throws IOException { // NOPMD
		assert x == 0;
		final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
		final int fullBlockCount = (int) Math.floor(myPercent / (UNIT_SIZE * PARTIAL_BLOCKS));
		final int partialBlockIndex = (int) Math
				.floor((myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS) / UNIT_SIZE);

		addImage(getBarImage(fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0"));

		final BufferedImage fullBody = getBarImage(String.valueOf(PARTIAL_BLOCKS));
		for (int i = 0; i < fullBlockCount; i++) {
			addImage(fullBody);
		}

		if (partialBlockIndex > 0) {
			final BufferedImage partialBody = getBarImage(String.valueOf(partialBlockIndex));
			addImage(partialBody);
		}

		final int emptyBlocks = FULL_BLOCKS - fullBlockCount - (partialBlockIndex > 0 ? 1 : 0);
		final BufferedImage emptyBody = getBarImage(String.valueOf(0));
		for (int i = 0; i < emptyBlocks; i++) {
			addImage(emptyBody);
		}

		addImage(getBarImage(fullBlockCount == FULL_BLOCKS ? "b" : "b0"));

		if (alertOnHighUsage) {
			x += 8;
			graphics.drawImage(getImage("alert.png"), x, 0, null);
		}
	}
1113880
public function draw()
    {
        $numberLen = strlen(' 100%');
        $complete = round($this->_progress / $this->_total, 2);
        $barLen = ($this->_width - $numberLen) * ($this->_progress / $this->_total);
        $bar = '';
        if ($barLen > 1) {
            $bar = str_repeat('=', $barLen - 1) . '>';
        }

        $pad = ceil($this->_width - $numberLen - $barLen);
        if ($pad > 0) {
            $bar .= str_repeat(' ', $pad);
        }
        $percent = ($complete * 100) . '%';
        $bar .= str_pad($percent, $numberLen, ' ', STR_PAD_LEFT);

        $this->_io->overwrite($bar, 0);

        return $this;
    }
31565
private function generateBarcode($sString, $iWidth = null, $iHeight = null)
    {
        //  Prep the string
        $sString = strtoupper($sString);
        $sString = preg_replace('/[^A-Z0-9]/', '', $sString);

        // --------------------------------------------------------------------------

        if (empty($sString)) {

            $this->setError('String cannot be empty');
            return false;
        }

        // --------------------------------------------------------------------------

        /**
         * Create an oversized image first. We're going to generate the barcode with
         * the text centered then crop it to fit into an image of the requested size.
         */

        $_width  = 2000;
        $_height = 60;
        $rImg    = imagecreate($_width, $_height);

        //  Define the colours
        $rColorWhite = imagecolorallocate($rImg, 255, 255, 255);
        $rColorBlack = imagecolorallocate($rImg, 0, 0, 0);

        // --------------------------------------------------------------------------

        //  Write the barcode text, centered
        $iFontSize  = 36;
        $sFontPath  = $this->sFontPathBarcode;

        $aTextBox    = @imageTTFBbox($iFontSize, 0, $sFontPath, $sString);
        $iTextWidth  = abs($aTextBox[4] - $aTextBox[0]);
        $iTextHeight = abs($aTextBox[5] - $aTextBox[1]);
        $nTextX      = ($_width/2)-($iTextWidth/2)-2;
        $nTextY      = $iTextHeight;

        imagettftext($rImg, $iFontSize, 0, $nTextX, $nTextY, $rColorBlack, $sFontPath, $sString);

        $nBarcodeHeight = $iTextHeight;
        $nBarcodeWidth  = $iTextWidth;
        $nBarcodeTextX  = $nTextX;

        // --------------------------------------------------------------------------

        //  Write the number text, also centered
        $iFontSize = 14;
        $sFontPath = $this->sFontPathPlain;

        $aTextBox    = @imageTTFBbox($iFontSize, 0, $sFontPath, $sString);
        $iTextWidth  = abs($aTextBox[4] - $aTextBox[0]);
        $iTextHeight = abs($aTextBox[5] - $aTextBox[1]);
        $nTextX      = ($_width/2)-($iTextWidth/2)-2;
        $nTextY      = $nBarcodeHeight + $iTextHeight;

        /**
         * If the string contains a J or a Q then the positioning of the string
         * is skewed, adjust accordingly.
         */

        if (strpos($sString, 'J') == false && strpos($sString, 'Q') == false) {

            $nTextY += 5;
        }

        imagettftext($rImg, $iFontSize, 0, $nTextX, $nTextY, $rColorBlack, $sFontPath, $sString);

        // --------------------------------------------------------------------------

        /**
         * Crop image to fit barcode; it seems there's a PHP bug however - image crop
         * creates black lines when cropping: https://bugs.php.net/bug.php?id=67447
         */

        $aOptions           = array();
        $aOptions['height'] = $_height;
        $aOptions['width']  = max($nBarcodeWidth, $iTextWidth);
        $aOptions['y']      = 0;
        $aOptions['x']      = min($nBarcodeTextX, $nTextX);

        $rImgCropped = imagecrop($rImg, $aOptions);

        imagedestroy($rImg);

        // --------------------------------------------------------------------------

        /**
         * If a user defined width or height has been supplied then resize to those
         * dimensions.
         */

        if (!is_null($iWidth) || !is_null($iHeight)) {

            $iWidth      = is_null($iWidth) ? $aOptions['width']: $iWidth;
            $iHeight     = is_null($iHeight) ? $aOptions['height']: $iHeight;
            $_width      = min($iWidth, $aOptions['width']);
            $_height     = min($iHeight, $aOptions['height']);
            $rImgUser    = imagecreate($iWidth, $iHeight);
            $rColorWhite = imagecolorallocate($rImgUser, 255, 255, 255) ;

            imagecopyresampled(
                $rImgUser,
                $rImgCropped,
                0,
                0,
                0,
                0,
                $_width,
                $_height,
                $aOptions['width'],
                $aOptions['height']
            );

            return $rImgUser;

        } else {

            return $rImgCropped;
        }
    }
800049
public function draw($im) {
        if ($this->quietZone) {
            $this->positionX += 9;
        }

        $c = strlen($this->data);
        for ($i = 0; $i < $c; $i++) {
            $this->drawChar($im, $this->data[$i]);
        }

        $this->drawText($im, 0, 0, $this->positionX, $this->thickness + ($this->quietZone ? 4 : 0));
    }
873643
public static function convertImagickToGDRessource(\Imagick $imagick, $png = false)
  {
    $imagick->setImageFormat('png');
    $data = $imagick->getimageblob();
    $im = imagecreatefromstring($data);

    if ($png) {
      imagealphablending($im, true); // setting alpha blending on
      imagesavealpha($im, true);
    }

    return $im;
  }
1174865
public function barcodeAction()
    {
        $code = $this->getRequest()->getParam('code', 'empty');
        \Zend_Layout::getMvcInstance()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        $barcodeOptions = array('text' => $code);
        $rendererOptions = array();
        $barcode = \Zend_Barcode::render('code128', 'image', $barcodeOptions, $rendererOptions);
        $barcode->render();
    }
513236
protected void drawBars(Canvas _Canvas) {

        RectF  bounds;
        String valueString;
        float  animatedRightOffset;

        for (BarModel model : mData) {
            bounds              = model.getBarBounds();
            valueString         = Utils.getFloatString(model.getValue(), mShowDecimal) + mValueUnit;
            animatedRightOffset = bounds.right * mRevealValue;

            mGraphPaint.setColor(model.getColor());

            _Canvas.drawRect(
                    bounds.left,
                    bounds.top,
                    bounds.right * mRevealValue,
                    bounds.bottom, mGraphPaint);

            if (mShowValues && animatedRightOffset > mValuePaint.measureText(valueString)) {
                mValuePaint.setColor(mLegendColor);
                _Canvas.drawText(
                        valueString,
                        bounds.left + mValueDistance,
                        bounds.centerY() + (mMaxFontHeight / 2),
                        mValuePaint
                );
            }

            if (mShowBarLabel) {
                mValuePaint.setColor(mBarLabelColor);
                _Canvas.drawText(
                        model.getLegendLabel(),
                        animatedRightOffset + mValueDistance,
                        bounds.centerY() + (mMaxFontHeight / 2),
                        mValuePaint
                );
            }
        }
    }
254762
public function checkImgType($imgName){
	    $file = fopen($imgName, "rb");
	    $bin = fread($file, 2);
	    $strInfo  = @unpack("C2chars", $bin);
	    $typeCode = intval($strInfo['chars1'].$strInfo['chars2']);
	    switch($typeCode)
	    {
	        case '255216':
	            return 'jpg';
	            break;
	        case '7173':
	            return 'gif';
	            break;
	        case '13780':
	            return 'png';
	            break;
	        case '6677':
	            return 'bmp';
	            break;
	        default:
	            return 'unknown';
	            break;
	    }
	}
929305
protected function drawScratch($img, $imageWidth, $imageHeight, $hex)
    {
        $rgb = $this->hexToRgb($hex);

        imageline(
            $img,
            mt_rand(0, floor($imageWidth / 2)),
            mt_rand(1, $imageHeight),
            mt_rand(floor($imageWidth / 2), $imageWidth),
            mt_rand(1, $imageHeight),
            imagecolorallocate($img, $rgb['r'], $rgb['g'], $rgb['b'])
        );
    }
516892
@Override
    public void draw(Canvas canvas) {
        Barcode barcode = mBarcode;
        if (barcode == null) {
            return;
        }

        // Draws the bounding box around the barcode.
        RectF rect = getViewBoundingBox(barcode);

        canvas.drawRect(rect, mOverlayPaint);

        /**
         * Draw the top left corner
         */
        canvas.drawLine(rect.left, rect.top, rect.left + CORNER_WIDTH, rect.top, mRectPaint);
        canvas.drawLine(rect.left, rect.top, rect.left, rect.top + CORNER_WIDTH, mRectPaint);

        /**
         * Draw the bottom left corner
         */
        canvas.drawLine(rect.left, rect.bottom, rect.left, rect.bottom - CORNER_WIDTH, mRectPaint);
        canvas.drawLine(rect.left, rect.bottom, rect.left + CORNER_WIDTH, rect.bottom, mRectPaint);

        /**
         * Draw the top right corner
         */
        canvas.drawLine(rect.right, rect.top, rect.right - CORNER_WIDTH, rect.top, mRectPaint);
        canvas.drawLine(rect.right, rect.top, rect.right, rect.top + CORNER_WIDTH, mRectPaint);

        /**
         * Draw the bottom right corner
         */
        canvas.drawLine(rect.right, rect.bottom, rect.right - CORNER_WIDTH, rect.bottom, mRectPaint);
        canvas.drawLine(rect.right, rect.bottom, rect.right, rect.bottom - CORNER_WIDTH, mRectPaint);
    }
50676
public function draw() {
        $size = $this->barcode->getDimension(0, 0);
        $this->w = max(1, $size[0]);
        $this->h = max(1, $size[1]);
        $this->init();
        $this->barcode->draw($this->im);
    }
303295
def has_im():
    """"""
    if shutil.which("magick"):
        return ["magick", "convert"]

    if shutil.which("convert"):
        return ["convert"]

    logging.error("Imagemagick wasn't found on your system.")
    logging.error("Try another backend. (wal --backend)")
    sys.exit(1)
970759
protected function drawBillet()
    {
        $wallet = $this->title->assignment->wallet;
        $this->fields['wallet']['value'] = $wallet->operation;
        parent::drawBillet();
    }
858591
protected void drawBars(Canvas _Canvas) {
        for (StackedBarModel model : mData) {
            float lastTop;
            float lastBottom = mGraphHeight;

            for (int index = 0; index < model.getBars().size(); index++) {
                BarModel barModel = model.getBars().get(index);

                RectF bounds = barModel.getBarBounds();
                mGraphPaint.setColor(barModel.getColor());

                float height = (bounds.height() * mRevealValue);
                lastTop = lastBottom - height;

                _Canvas.drawRect(
                        bounds.left,
                        lastTop,
                        bounds.right,
                        lastBottom,
                        mGraphPaint
                );

                if (mShowValues && barModel.isShowValue()) {
                    _Canvas.drawText(
                            String.valueOf(barModel.getValue()),
                            bounds.centerX(),
                            (lastTop + height / 2) + barModel.getValueBounds().height()/2,
                            mTextPaint
                    );
                }

                lastBottom = lastTop;

                if (mShowSeparators && index < model.getBars().size() - 1) {
                    lastBottom -= mSeparatorWidth;
                }
            }

        }
    }
632580
protected function drawImage(Imagick $imagick):string{
		$draw = new ImagickDraw;

		foreach($this->matrix->matrix() as $y => $row){
			foreach($row as $x => $M_TYPE){
				$draw->setStrokeColor($this->moduleValues[$M_TYPE]);
				$draw->setFillColor($this->moduleValues[$M_TYPE]);
				$draw->rectangle(
					$x * $this->scale,
					$y * $this->scale,
					($x + 1) * $this->scale,
					($y + 1) * $this->scale
				);

			}
		}

		$imagick->drawImage($draw);

		return (string)$imagick;
	}