/** * 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 */ public static function color($red, $green, $blue) { $color = new asido_color(); $color->set($red, $green, $blue); return $color; }
/** * 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 */ public function frame(asido_tmp $tmp, $width, $height, asido_color $color = null) { // color ? // if (!isset($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; }
/** * Get canvas * * @param integer $width * @param integer $height * @param asido_color $color * @return asido_tmp * @access protected */ protected function __canvas($width, $height, asido_color $color) { $t = new asido_tmp(); $t->target = imageCreateTrueColor($width, $height); list($r, $g, $b) = $color->get(); imageFill($t->target, 1, 1, imageColorAllocate($t->target, $r, $g, $b)); $t->image_width = $width; $t->image_height = $height; return $t; }