protected function SetIndexDarkColor($which_color, $alpha = 0) { list($r, $g, $b, $a) = $this->SetRGBColor($which_color, $alpha); if (!isset($r)) { return NULL; } $r = max(0, $r - 0x30); $g = max(0, $g - 0x30); $b = max(0, $b - 0x30); return ImageColorResolveAlpha($this->img, $r, $g, $b, $a); }
/** * Output the element to the canvas * @see Image_Graph_Common * @access private */ function _done() { if (is_a($this->_fillStyle, "Image_Graph_Fill")) { $this->_fillStyle->_reset(); } if ($this->_background != null) { $this->_debug("Drawing background"); ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $this->_getBackground()); } if ($this->_identify) { $this->_debug("Identifying"); $red = rand(0, 255); $green = rand(0, 255); $blue = rand(0, 255); $color = ImageColorAllocate($this->_canvas(), $red, $green, $blue); if (isset($GLOBALS['_Image_Graph_gd2'])) { $alphaColor = ImageColorResolveAlpha($this->_canvas(), $red, $green, $blue, 200); } else { $alphaColor = $color; } ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $color); ImageFilledRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, $alphaColor); if ($this->_identifyText) { $text = eregi_replace("<[^>]*>([^<]*)", "\\1", $this->_identification()); if (ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text) > $this->width()) { $x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2)); $y = max($this->_top, min($this->_bottom, $this->_bottom - ($this->height() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2)); ImageStringUp($this->_canvas(), FONT, $x, $y, $text, $color); } else { $x = max($this->_left, min($this->_right, $this->_left + ($this->width() - ImageFontWidth(IMAGE_GRAPH_FONT) * strlen($text)) / 2)); $y = max($this->_top, min($this->_bottom, $this->_top + ($this->height() - ImageFontHeight(IMAGE_GRAPH_FONT)) / 2)); ImageString($this->_canvas(), FONT, $x, $y, $text, $color); } } } if ($this->_borderStyle != null) { $this->_debug("Drawing border"); ImageRectangle($this->_canvas(), $this->_left, $this->_top, $this->_right, $this->_bottom, ((is_a($this->_borderStyle, "Image_Graph_Color")) ? $this->_borderStyle->_index : $this->_borderStyle->_getLineStyle())); } parent::_done(); if ($this->_shadow) { $this->_displayShadow(); } }
/** * Output the plotarea to the canvas * @access private */ function _done() { if ($this->_axisX != null) { $this->add($this->_axisX); } if ($this->_axisY != null) { $this->add($this->_axisY); } if ($this->_identify) { $red = rand(0, 255); $green = rand(0, 255); $blue = rand(0, 255); $color = ImageColorAllocate($this->_canvas(), $red, $green, $blue); if (isset($GLOBALS['_Image_Graph_gd2'])) { $alphaColor = ImageColorResolveAlpha($this->_canvas(), $red, $green, $blue, 200); } else { $alphaColor = $color; } ImageRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $color); ImageFilledRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $alphaColor); } if ($this->_fillStyle) { ImageFilledRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $this->_getFillStyle()); } parent::_done(); if ($this->_plotBorderStyle) { ImageRectangle($this->_canvas(), $this->_plotLeft, $this->_plotTop, $this->_plotRight, $this->_plotBottom, $this->_plotBorderStyle->_getLineStyle()); } }
/** * Sets the parent. The parent chain should ultimately be a GraPHP object * @see Image_Graph_Common * @param Image_Graph_Common Parent The parent * @access private */ function _setParent(& $parent) { parent::_setParent($parent); if ((!$this->_alpha) or (!$GLOBALS['_Image_Graph_gd2'])) { $this->_index = ImageColorAllocate($this->_canvas(), $this->_red, $this->_green, $this->_blue); } else { $this->_index = ImageColorResolveAlpha($this->_canvas(), $this->_red, $this->_green, $this->_blue, $this->_alpha); } }
<?php Header('Content-Type: image/png'); $height = 600; $txt = 'Carl hacking'; $size = ImageTTFBbox(25, 0, 'timesi', $txt); $txt_w = abs($size[2] - $size[0]); $txt_h = abs($size[6] - $size[1]); $bg = ImageCreateFromJpeg('chs.jpg'); $img_width = imagesx($bg); $img_height = imagesy($bg); $width = $height / $img_height * $img_width; $sizing = "Original image size {$img_width} x {$img_height}\r\n"; $sizing .= " New image size {$width} x {$height}"; $im = ImageCreateTrueColor($width, $height); ImageCopyResampled($im, $bg, 0, 0, 0, 0, $width, $height, $img_width, $img_height); $white = ImageColorAllocate($im, 255, 255, 255); $black = ImageColorAllocate($im, 0, 0, 0); $col = ImageColorResolveAlpha($im, 10, 10, 10, 50); ImageFilledRectangle($im, 10, 5, 470, 90, 0x30ffffff); ImageTTFText($im, 25, 0, 20, 40, $black, 'timesi', $sizing); ImageDestroy($bg); $box = ($width - $txt_w) / 2; ImageFilledRectangle($im, $box - 10, $height - $txt_h - 30, $width - $box, $height - 5, $col); $yellow = ImageColorAllocate($im, 255, 255, 10); ImageTTFText($im, 25, 0, $box, $height - $txt_h - 5, $yellow, 'timesi', $txt); ImagePNG($im);
/** * Query SQL for all accessible category data * * @return Nothing */ function deliverThumb() { global $mainframe, $limitstart; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $usersConfig = &JComponentHelper::getParams( 'com_users' ); //$currentSession = JSession::getInstance('none',array()); //$currentSession->destroy(); $id = JRequest::getCmd( 'id', 0 ); $db->SetQuery('SELECT * FROM #__hwdvidsvideos WHERE id = '.(int)$id); $db->Query(); $row = $db->loadObject(); $url = JURI::root()."hwdvideos/thumbs/".$row->video_id.".".$row->thumbnail; if (headers_sent($filename, $linenum)) { //problem } header('Location: '.$url); exit; $BASEPATH = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'; $BASEURL = JURI::root().'hwdvideos'.DS.'thumbs'; $path = $BASEPATH.DS.$row->video_id.'.jpg'; $url = $BASEURL.DS.$row->video_id.'.jpg'; $watermark = $row->video_length; $image=imagecreatefromjpeg($path); header('Content-Type: image/jpeg'); imagejpeg($image); exit; if ($c->thumb_ts == 0 || !function_exists('imagettftext') || empty($row->video_length) || $row->video_length == "0:00:00" || $row->video_length == "0:00:02") { $image=imagecreatefromjpeg($path); header('Content-Type: image/jpeg'); imagejpeg($image); exit; } else { list($width, $height) = getimagesize($path); $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($path); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); imagedestroy($image); $x_1 = $width - 55; $x_s = $x_1+3; $y_1 = 0; $x_2 = $width; $y_2 = 15; $bk = ImageColorResolveAlpha($image_p, 68, 68, 68, 50); $fg = imagecolorallocate($image_p, 255, 255, 255); imagefilledrectangle($image_p, $x_1, $y_1, $x_2, $y_2, $bk); // draw transparent box $font = JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'assets'.DS.'captcha'.DS.'monofont.ttf'; $font_size = 13; imagettftext($image_p, $font_size, 0, $x_s, 13, $fg, $font, $watermark); header('Content-type: image/jpeg'); imagejpeg ($image_p); imagedestroy($image_p); exit; } }