/** Turn bitmap into receipt string @param $arg string filename OR Bitmap obj @return receipt-formatted string */ function RenderBitmap($arg, $align = 'C') { $slip = ""; if (!class_exists('Bitmap')) { return ""; } $bmp = null; if (is_object($arg) && is_a($arg, 'Bitmap')) { $bmp = $arg; } else { if (file_exists($arg)) { $bmp = new Bitmap(); $bmp->load($arg); } } // argument was invalid if ($bmp === null) { return ""; } $bmpData = $bmp->getRawData(); $bmpWidth = $bmp->getWidth(); $bmpHeight = $bmp->getHeight(); $bmpRawBytes = (int) (($bmpWidth + 7) / 8); $stripes = $this->TransposeBitmapData($bmpData, $bmpWidth); for ($i = 0; $i < count($stripes); $i++) { $stripes[$i] = $this->InlineBitmap($stripes[$i], $bmpWidth); } if ($align == 'C') { $slip .= $this->AlignCenter(); } if (count($stripes) > 1) { $slip .= $this->LineSpacing(0); } $slip .= implode("\n", $stripes); if (count($stripes) > 1) { $slip .= $this->ResetLineSpacing(); } if ($align == 'C') { $slip .= "\n"; } $slip .= $this->AlignLeft(); return $slip; }
/** * Insert a 24bit bitmap image in a worksheet. * * @param integer $row The row we are going to insert the bitmap into * @param integer $col The column we are going to insert the bitmap into * @param string $path The bitmap filename * @param integer $x The horizontal position (offset) of the image inside the cell. * @param integer $y The vertical position (offset) of the image inside the cell. * @param integer $scaleX The horizontal scale * @param integer $scaleY The vertical scale */ public function insertBitmap($row, $col, $path, $x = 0, $y = 0, $scaleX = 1, $scaleY = 1) { $bmp = new Bitmap($path); $width = $bmp->getWidth(); $height = $bmp->getHeight(); // BITMAPCOREINFO $data = $this->getRecord('BitmapCoreHeader', array($width, $height)); $data .= $bmp->getDataWithoutHeader(); // Scale the frame of the image. $width *= $scaleX; $height *= $scaleY; $this->positionImage($col, $row, $x, $y, $width, $height); $this->appendRecord('Imdata', array($data)); }