Example #1
0
 function GetImgByIdx($aIdx)
 {
     if (array_key_exists($aIdx, $this->iFlagData)) {
         $d = $this->iFlagData[$aIdx][1];
         return Image::CreateFromString($d);
     } else {
         JpGraphError::RaiseL(5002, $aIdx);
     }
 }
 function GetImgByIdx($aIdx)
 {
     if (array_key_exists($aIdx, $this->iFlagData)) {
         $d = $this->iFlagData[$aIdx][1];
         return Image::CreateFromString($d);
     } else {
         JpGraphError::Raise("Flag index \" {$aIdx}\" does not exist.");
     }
 }
 function GetImg($aMark, $aIdx)
 {
     $n = $this->an[$aMark];
     if (is_string($aIdx)) {
         if (!in_array($aIdx, $this->colors)) {
             JpGraphError::RaiseL(23001, $this->name, $aIdx);
         }
         $idx = $this->index[$aIdx];
     } elseif (!is_integer($aIdx) || is_integer($aIdx) && $aIdx > $this->maxidx) {
         JpGraphError::RaiseL(23002, $this->name);
     } else {
         $idx = $aIdx;
     }
     return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
 }
 function GetImg($aMark, $aIdx)
 {
     $n = $this->an[$aMark];
     if (is_string($aIdx)) {
         if (!in_array($aIdx, $this->colors)) {
             JpGraphError::RaiseL(23001, $this->name, $aIdx);
             //('This marker "'.($this->name).'" does not exist in color: '.$aIdx);
         }
         $idx = $this->index[$aIdx];
     } elseif (!is_integer($aIdx) || is_integer($aIdx) && $aIdx > $this->maxidx) {
         JpGraphError::RaiseL(23002, $this->name);
         //('Mark color index too large for marker "'.($this->name).'"');
     } else {
         $idx = $aIdx;
     }
     return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
 }
Example #5
0
 function Raise($aMsg, $aHalt = true)
 {
     $img_iconerror = 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV' . 'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/' . 'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY' . 'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea' . 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx' . 'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4' . '2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+' . 'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6' . 'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3' . 'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0' . '6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS' . 'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk' . 'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc' . 'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx' . 'qL72fwAAAABJRU5ErkJggg==';
     $supported = imagetypes();
     if (ob_get_length() || headers_sent() || !($supported & IMG_PNG)) {
         // Special case for headers already sent or that the installation doesn't support
         // the PNG format (which the error icon is encoded in).
         // Dont return an image since it can't be displayed
         die("<b>JpGraph Error:</b> " . $aMsg);
     }
     $aMsg = wordwrap($aMsg, 55);
     $lines = substr_count($aMsg, "\n");
     // Create the error icon GD
     $erricon = Image::CreateFromString(base64_decode($img_iconerror));
     // Create an image that contains the error text.
     $w = 400;
     $h = 100 + 15 * max(0, $lines - 3);
     /*
     $h=100;
     if( strlen($aMsg) > 60 ) 
         $h = 150;
     */
     $img = new Image($w, $h);
     // Drop shadow
     $img->SetColor("gray");
     $img->FilledRectangle(5, 5, $w - 1, $h - 1, 10);
     $img->SetColor("gray:0.7");
     $img->FilledRectangle(5, 5, $w - 3, $h - 3, 10);
     // Window background
     $img->SetColor("lightblue");
     $img->FilledRectangle(1, 1, $w - 5, $h - 5);
     $img->CopyCanvasH($img->img, $erricon, 5, 30, 0, 0, 40, 40);
     // Window border
     $img->SetColor("black");
     $img->Rectangle(1, 1, $w - 5, $h - 5);
     $img->Rectangle(0, 0, $w - 4, $h - 4);
     // Window top row
     $img->SetColor("darkred");
     for ($y = 3; $y < 18; $y += 2) {
         $img->Line(1, $y, $w - 6, $y);
     }
     // "White shadow"
     $img->SetColor("white");
     // Left window edge
     $img->Line(2, 2, 2, $h - 5);
     $img->Line(2, 2, $w - 6, 2);
     // "Gray button shadow"
     $img->SetColor("darkgray");
     // Gray window shadow
     $img->Line(2, $h - 6, $w - 5, $h - 6);
     $img->Line(3, $h - 7, $w - 5, $h - 7);
     // Window title
     $m = floor($w / 2 - 5);
     $l = 100;
     $img->SetColor("lightgray:1.3");
     $img->FilledRectangle($m - $l, 2, $m + $l, 16);
     // Stroke text
     $img->SetColor("darkred");
     $img->SetFont(FF_FONT2, FS_BOLD);
     $img->StrokeText($m - 50, 15, "JpGraph Error");
     $img->SetColor("black");
     $img->SetFont(FF_FONT1, FS_NORMAL);
     $txt = new Text($aMsg, 52, 25);
     $txt->Align("left", "top");
     $txt->Stroke($img);
     $img->Headers();
     $img->Stream();
     die;
 }
Example #6
0
 static function LoadBkgImage($aImgFormat = '', $aFile = '', $aImgStr = '')
 {
     if ($aImgStr != '') {
         return Image::CreateFromString($aImgStr);
     }
     // Remove case sensitivity and setup appropriate function to create image
     // Get file extension. This should be the LAST '.' separated part of the filename
     $e = explode('.', $aFile);
     $ext = strtolower($e[count($e) - 1]);
     if ($ext == "jpeg") {
         $ext = "jpg";
     }
     if (trim($ext) == '') {
         $ext = 'png';
         // Assume PNG if no extension specified
     }
     if ($aImgFormat == '') {
         $imgtag = $ext;
     } else {
         $imgtag = $aImgFormat;
     }
     $supported = imagetypes();
     if ($ext == 'jpg' && !($supported & IMG_JPG) || $ext == 'gif' && !($supported & IMG_GIF) || $ext == 'png' && !($supported & IMG_PNG) || $ext == 'bmp' && !($supported & IMG_WBMP) || $ext == 'xpm' && !($supported & IMG_XPM)) {
         JpGraphError::RaiseL(25037, $aFile);
         //('The image format of your background image ('.$aFile.') is not supported in your system configuration. ');
     }
     if ($imgtag == "jpg" || $imgtag == "jpeg") {
         $f = "imagecreatefromjpeg";
         $imgtag = "jpg";
     } else {
         $f = "imagecreatefrom" . $imgtag;
     }
     // Compare specified image type and file extension
     if ($imgtag != $ext) {
         //$t = "Background image seems to be of different type (has different file extension) than specified imagetype. Specified: '".$aImgFormat."'File: '".$aFile."'";
         JpGraphError::RaiseL(25038, $aImgFormat, $aFile);
     }
     $img = @$f($aFile);
     if (!$img) {
         JpGraphError::RaiseL(25039, $aFile);
         //(" Can't read background image: '".$aFile."'");
     }
     return $img;
 }
 function GetImg($aIdx)
 {
     if ($aIdx < 0 || $aIdx >= $this->iLen) {
         JpGraphError::RaiseL(6010, $aIdx);
         //('Illegal icon index for Gantt builtin icon ['.$aIdx.']');
     }
     return Image::CreateFromString(base64_decode($this->iBuiltinIcon[$aIdx][1]));
 }
Example #8
0
 function _Stroke($aImg, $x = null, $y = null, $aReturnWidthHeight = false)
 {
     if ($this->iFile != '' && $this->iCountryFlag != '') {
         JpGraphError::RaiseL(8003);
         //('It is not possible to specify both an image file and a country flag for the same icon.');
     }
     if ($this->iFile != '') {
         $gdimg = Graph::LoadBkgImage('', $this->iFile);
     } elseif ($this->iImgString != '') {
         $gdimg = Image::CreateFromString($this->iImgString);
     } else {
         if (!class_exists('FlagImages', false)) {
             JpGraphError::RaiseL(8004);
             //('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
         }
         $fobj = new FlagImages($this->iCountryStdSize);
         $dummy = '';
         $gdimg = $fobj->GetImgByName($this->iCountryFlag, $dummy);
     }
     $iconw = imagesx($gdimg);
     $iconh = imagesy($gdimg);
     if ($aReturnWidthHeight) {
         return array(round($iconw * $this->iScale), round($iconh * $this->iScale));
     }
     if ($x !== null && $y !== null) {
         $this->iX = $x;
         $this->iY = $y;
     }
     if ($this->iX >= 0 && $this->iX <= 1.0) {
         $w = imagesx($aImg->img);
         $this->iX = round($w * $this->iX);
     }
     if ($this->iY >= 0 && $this->iY <= 1.0) {
         $h = imagesy($aImg->img);
         $this->iY = round($h * $this->iY);
     }
     if ($this->iHorAnchor == 'center') {
         $this->iX -= round($iconw * $this->iScale / 2);
     }
     if ($this->iHorAnchor == 'right') {
         $this->iX -= round($iconw * $this->iScale);
     }
     if ($this->iVertAnchor == 'center') {
         $this->iY -= round($iconh * $this->iScale / 2);
     }
     if ($this->iVertAnchor == 'bottom') {
         $this->iY -= round($iconh * $this->iScale);
     }
     $aImg->CopyMerge($gdimg, $this->iX, $this->iY, 0, 0, round($iconw * $this->iScale), round($iconh * $this->iScale), $iconw, $iconh, $this->iMix);
 }
 function Raise($aMsg, $aHalt = true)
 {
     $img_iconerror = 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV' . 'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/' . 'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY' . 'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea' . 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx' . 'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4' . '2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+' . 'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6' . 'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3' . 'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0' . '6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS' . 'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk' . 'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc' . 'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx' . 'qL72fwAAAABJRU5ErkJggg==';
     if (function_exists("imagetypes")) {
         $supported = imagetypes();
     } else {
         $supported = 0;
     }
     if (!function_exists('imagecreatefromstring')) {
         $supported = 0;
     }
     if (ob_get_length() || headers_sent() || !($supported & IMG_PNG)) {
         die($this->iTitle . ' ' . $aMsg);
     }
     $aMsg = wordwrap($aMsg, 55);
     $lines = substr_count($aMsg, "\n");
     $erricon = Image::CreateFromString(base64_decode($img_iconerror));
     $w = 400;
     $h = 100 + 15 * max(0, $lines - 3);
     $img = new Image($w, $h);
     $img->SetColor("gray");
     $img->FilledRectangle(5, 5, $w - 1, $h - 1, 10);
     $img->SetColor("gray:0.7");
     $img->FilledRectangle(5, 5, $w - 3, $h - 3, 10);
     $img->SetColor("lightblue");
     $img->FilledRectangle(1, 1, $w - 5, $h - 5);
     $img->CopyCanvasH($img->img, $erricon, 5, 30, 0, 0, 40, 40);
     $img->SetColor("black");
     $img->Rectangle(1, 1, $w - 5, $h - 5);
     $img->Rectangle(0, 0, $w - 4, $h - 4);
     $img->SetColor("darkred");
     for ($y = 3; $y < 18; $y += 2) {
         $img->Line(1, $y, $w - 6, $y);
     }
     $img->SetColor("white");
     $img->Line(2, 2, 2, $h - 5);
     $img->Line(2, 2, $w - 6, 2);
     $img->SetColor("darkgray");
     $img->Line(2, $h - 6, $w - 5, $h - 6);
     $img->Line(3, $h - 7, $w - 5, $h - 7);
     $m = floor($w / 2 - 5);
     $l = 100;
     $img->SetColor("lightgray:1.3");
     $img->FilledRectangle($m - $l, 2, $m + $l, 16);
     $img->SetColor("darkred");
     $img->SetFont(FF_FONT2, FS_BOLD);
     $img->StrokeText($m - 50, 15, $this->iTitle);
     $img->SetColor("black");
     $img->SetFont(FF_FONT1, FS_NORMAL);
     $txt = new Text($aMsg, 52, 25);
     $txt->Align("left", "top");
     $txt->Stroke($img);
     if ($this->iDest) {
         $img->Stream($this->iDest);
     } else {
         $img->Headers();
         $img->Stream();
     }
     if ($aHalt) {
         die;
     }
 }
Example #10
0
 function GetImg($aIdx)
 {
     if ($aIdx < 0 || $aIdx >= $this->iLen) {
         JpGraphError::RaiseL(6010, $aIdx);
     }
     return Image::CreateFromString(base64_decode($this->iBuiltinIcon[$aIdx][1]));
 }
Example #11
0
 function LoadBkgImage($aImgFormat = '', $aFile = '', $aImgStr = '')
 {
     if ($aImgStr != '') {
         return Image::CreateFromString($aImgStr);
     }
     $e = explode('.', $aFile);
     $ext = strtolower($e[count($e) - 1]);
     if ($ext == "jpeg") {
         $ext = "jpg";
     }
     if (trim($ext) == '') {
         $ext = 'png';
     }
     if ($aImgFormat == '') {
         $imgtag = $ext;
     } else {
         $imgtag = $aImgFormat;
     }
     $supported = imagetypes();
     if ($ext == 'jpg' && !($supported & IMG_JPG) || $ext == 'gif' && !($supported & IMG_GIF) || $ext == 'png' && !($supported & IMG_PNG) || $ext == 'bmp' && !($supported & IMG_WBMP) || $ext == 'xpm' && !($supported & IMG_XPM)) {
         JpGraphError::RaiseL(25037, $aFile);
     }
     if ($imgtag == "jpg" || $imgtag == "jpeg") {
         $f = "imagecreatefromjpeg";
         $imgtag = "jpg";
     } else {
         $f = "imagecreatefrom" . $imgtag;
     }
     if ($imgtag != $ext) {
         JpGraphError::RaiseL(25038, $aImgFormat, $aFile);
     }
     $img = @$f($aFile);
     if (!$img) {
         JpGraphError::RaiseL(25039, $aFile);
     }
     return $img;
 }
Example #12
0
 function _Stroke(&$aImg, $x = null, $y = null, $aReturnWidthHeight = false)
 {
     if ($this->iFile != '' && $this->iCountryFlag != '') {
         JpGraphError::RaiseL(8003);
     }
     if ($this->iFile != '') {
         $gdimg = Graph::LoadBkgImage('', $this->iFile);
     } elseif ($this->iImgString != '') {
         $gdimg = Image::CreateFromString($this->iImgString);
     } else {
         if (!class_exists('FlagImages')) {
             JpGraphError::RaiseL(8004);
         }
         $fobj = new FlagImages($this->iCountryStdSize);
         $dummy = '';
         $gdimg = $fobj->GetImgByName($this->iCountryFlag, $dummy);
     }
     $iconw = imagesx($gdimg);
     $iconh = imagesy($gdimg);
     if ($aReturnWidthHeight) {
         return array(round($iconw * $this->iScale), round($iconh * $this->iScale));
     }
     if ($x !== null && $y !== null) {
         $this->iX = $x;
         $this->iY = $y;
     }
     if ($this->iX >= 0 && $this->iX <= 1.0) {
         $w = imagesx($aImg->img);
         $this->iX = round($w * $this->iX);
     }
     if ($this->iY >= 0 && $this->iY <= 1.0) {
         $h = imagesy($aImg->img);
         $this->iY = round($h * $this->iY);
     }
     if ($this->iHorAnchor == 'center') {
         $this->iX -= round($iconw * $this->iScale / 2);
     }
     if ($this->iHorAnchor == 'right') {
         $this->iX -= round($iconw * $this->iScale);
     }
     if ($this->iVertAnchor == 'center') {
         $this->iY -= round($iconh * $this->iScale / 2);
     }
     if ($this->iVertAnchor == 'bottom') {
         $this->iY -= round($iconh * $this->iScale);
     }
     $aImg->CopyMerge($gdimg, $this->iX, $this->iY, 0, 0, round($iconw * $this->iScale), round($iconh * $this->iScale), $iconw, $iconh, $this->iMix);
 }