/**
	* Resize an image by "framing" it with the provided width and height
	*
	* @param Asido_Tmp &$tmp
	* @param integer $width
	* @param integer $height
	* @param Asido_Color $color
	* @return boolean
	* @access public
	*/
	function frame(&$tmp, $width, $height, $color=null) {
		
		// color ?
		//
		if (!is_a($color, 'Asido_Color')) {
			$color = new Asido_Color;
			$color->set(255, 255, 255);
			}
		
		// resize it
		//
		if (!$this->resize($tmp, $width, $height, ASIDO_RESIZE_FIT)) {
			return false;
			}
		
		// get canvas
		//
		if (!$t2 = $this->__canvas($width, $height, $color)) {
			trigger_error(
				sprintf(
					'Unable to get a canvas '
						. ' with %s pixels '
						. ' width and %s '
						. ' pixels height',
					$width, $height
					),
				E_USER_WARNING
				);
			return false;
			}
		
		// target
		//
		$t3 = new Asido_TMP;
		$t3->source =& $tmp->target;
		$t3->image_width = $tmp->image_width;
		$t3->image_height = $tmp->image_height;
		
		// apply the image
		//
		if (!$this->__copy(
			$t2, $t3,
			round(($t2->image_width - $t3->image_width)/2),
			round(($t2->image_height - $t3->image_height)/2)
			)) {
			trigger_error(
				'Failed to copy to the passepartout image',
				E_USER_WARNING
				);
			return false;
			}
		
		// cook the result
		//
		$this->__destroy_target($tmp);
		$tmp->target = $t2->target;
		$tmp->image_width = $t2->image_width;
		$tmp->image_height = $t2->image_height;
		
		return true;
		}
Example #2
0
 /**
  * Return an color object ({@link Asido_Color}) with the provided RGB channels
  *
  * @param integer $red	the value has to be from 0 to 255
  * @param integer $green	the value has to be from 0 to 255
  * @param integer $blue	the value has to be from 0 to 255
  * @return Asido_Color
  * @access public
  * @static
  */
 function color($red, $green, $blue)
 {
     $color = new Asido_Color();
     $color->set($red, $green, $blue);
     return $color;
 }