/**
* Apply the drop_shadow effect.
*
- * @return mixed true | PEAR_Error
+ * @return boolean
*/
public function apply()
{
$tempImageWidth = $imgX + abs($offset['x']);
$tempImageHeight = $imgY + abs($offset['y']);
- $gdimg_dropshadow_temp = $this->_image->create($tempImageWidth,
- $tempImageHeight);
- if (!is_a($gdimg_dropshadow_temp, 'PEAR_Error')) {
- $this->_image->call('imageAlphaBlending',
- array($gdimg_dropshadow_temp, false));
-
- $this->_image->call('imageSaveAlpha',
- array($gdimg_dropshadow_temp, true));
-
- $transparent1 = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, 0, 0, 0, 127));
-
- if (is_a($transparent1, 'PEAR_Error')) {
- return $transparent1;
+ $gdimg_dropshadow_temp = $this->_image->create($tempImageWidth, $tempImageHeight);
+ $this->_image->call('imageAlphaBlending', array($gdimg_dropshadow_temp, false));
+ $this->_image->call('imageSaveAlpha', array($gdimg_dropshadow_temp, true));
+ $transparent1 = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, 0, 0, 0, 127));
+ $this->_image->call('imageFill', array($gdimg_dropshadow_temp, 0, 0, $transparent1));
+ for ($x = 0; $x < $imgX; $x++) {
+ for ($y = 0; $y < $imgY; $y++) {
+ $colorat = $this->_image->call('imageColorAt', array($gdimg, $x, $y));
+ $PixelMap[$x][$y] = $this->_image->call('imageColorsForIndex', array($gdimg, $colorat));
}
+ }
- $this->_image->call('imageFill',
- array($gdimg_dropshadow_temp, 0, 0, $transparent1));
-
- for ($x = 0; $x < $imgX; $x++) {
- for ($y = 0; $y < $imgY; $y++) {
- $colorat = $this->_image->call('imageColorAt', array($gdimg, $x, $y));
- $PixelMap[$x][$y] = $this->_image->call('imageColorsForIndex',
- array($gdimg, $colorat));
- }
- }
-
- /* Creates the shadow */
- $r = hexdec(substr($hexcolor, 0, 2));
- $g = hexdec(substr($hexcolor, 2, 2));
- $b = hexdec(substr($hexcolor, 4, 2));
-
- /* Essentially masks the original image and creates the shadow */
- for ($x = 0; $x < $tempImageWidth; $x++) {
- for ($y = 0; $y < $tempImageHeight; $y++) {
- if (!isset($PixelMap[$x][$y]['alpha']) ||
- ($PixelMap[$x][$y]['alpha'] > 0)) {
- if (isset($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']) && ($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha'] < 127)) {
- $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $r, $g, $b, $PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']));
- $this->_image->call('imageSetPixel',
- array($gdimg_dropshadow_temp, $x, $y, $thisColor));
- }
+ /* Creates the shadow */
+ $r = hexdec(substr($hexcolor, 0, 2));
+ $g = hexdec(substr($hexcolor, 2, 2));
+ $b = hexdec(substr($hexcolor, 4, 2));
+
+ /* Essentially masks the original image and creates the shadow */
+ for ($x = 0; $x < $tempImageWidth; $x++) {
+ for ($y = 0; $y < $tempImageHeight; $y++) {
+ if (!isset($PixelMap[$x][$y]['alpha']) ||
+ ($PixelMap[$x][$y]['alpha'] > 0)) {
+ if (isset($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']) && ($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha'] < 127)) {
+ $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $r, $g, $b, $PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']));
+ $this->_image->call('imageSetPixel',
+ array($gdimg_dropshadow_temp, $x, $y, $thisColor));
}
- }
- }
- /* Overlays the original image */
- $this->_image->call('imageAlphaBlending',
- array($gdimg_dropshadow_temp, true));
-
- for ($x = 0; $x < $imgX; $x++) {
- for ($y = 0; $y < $imgY; $y++) {
- if ($PixelMap[$x][$y]['alpha'] < 127) {
- $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']));
- $this->_image->call('imageSetPixel',
- array($gdimg_dropshadow_temp, $x, $y, $thisColor));
}
+ }
+ }
+ /* Overlays the original image */
+ $this->_image->call('imageAlphaBlending',
+ array($gdimg_dropshadow_temp, true));
+
+ for ($x = 0; $x < $imgX; $x++) {
+ for ($y = 0; $y < $imgY; $y++) {
+ if ($PixelMap[$x][$y]['alpha'] < 127) {
+ $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']));
+ $this->_image->call('imageSetPixel',
+ array($gdimg_dropshadow_temp, $x, $y, $thisColor));
}
}
+ }
- $this->_image->call('imageSaveAlpha',
- array($gdimg, true));
- $this->_image->call('imageAlphaBlending',
- array($gdimg, false));
+ $this->_image->call('imageSaveAlpha',
+ array($gdimg, true));
+ $this->_image->call('imageAlphaBlending',
+ array($gdimg, false));
- // Merge the shadow and the original into the original.
- $this->_image->call('imageCopyResampled',
- array($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, $imgX, $imgY, $this->_image->call('imageSX', array($gdimg_dropshadow_temp)), $this->_image->call('imageSY', array($gdimg_dropshadow_temp))));
+ // Merge the shadow and the original into the original.
+ $this->_image->call('imageCopyResampled',
+ array($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, $imgX, $imgY, $this->_image->call('imageSX', array($gdimg_dropshadow_temp)), $this->_image->call('imageSY', array($gdimg_dropshadow_temp))));
+
+ $this->_image->call('imageDestroy', array($gdimg_dropshadow_temp));
- $this->_image->call('imageDestroy', array($gdimg_dropshadow_temp));
- }
return true;
}
/**
* Apply the round_corners effect.
*
- * @return mixed true | PEAR_Error
+ * @return boolean
*/
public function apply()
{
$gdimg = $this->_image->_im;
$imgX = round($this->_image->call('imageSX', array($gdimg)));
$imgY = round($this->_image->call('imageSY', array($gdimg)));
+ $gdimg_cornermask_triple = $this->_image->create(round($radius_x * 6), round($radius_y * 6));
+ $gdimg_cornermask = $this->_image->create($imgX, $imgY);
+ $color_transparent = $this->_image->call('imageColorAllocate',
+ array($gdimg_cornermask_triple,
+ 255,
+ 255,
+ 255));
- $gdimg_cornermask_triple = $this->_image->create(round($radius_x * 6),
- round($radius_y * 6));
- if (!is_a($gdimg_cornermask_triple, 'PEAR_Error')) {
+ $this->_image->call('imageFilledEllipse',
+ array($gdimg_cornermask_triple,
+ $radius_x * 3,
+ $radius_y * 3,
+ $radius_x * 4,
+ $radius_y * 4,
+ $color_transparent));
- $gdimg_cornermask = $this->_image->create($imgX, $imgY);
- if (!is_a($gdimg_cornermask, 'PEAR_Error')) {
- $color_transparent = $this->_image->call('imageColorAllocate',
- array($gdimg_cornermask_triple,
- 255,
- 255,
- 255));
+ $this->_image->call('imageFilledRectangle',
+ array($gdimg_cornermask,
+ 0,
+ 0,
+ $imgX,
+ $imgY,
+ $color_transparent));
- $this->_image->call('imageFilledEllipse',
- array($gdimg_cornermask_triple,
- $radius_x * 3,
- $radius_y * 3,
- $radius_x * 4,
- $radius_y * 4,
- $color_transparent));
+ $this->_image->call('imageCopyResampled',
+ array($gdimg_cornermask,
+ $gdimg_cornermask_triple,
+ 0,
+ 0,
+ $radius_x,
+ $radius_y,
+ $radius_x,
+ $radius_y,
+ $radius_x * 2,
+ $radius_y * 2));
- $this->_image->call('imageFilledRectangle',
- array($gdimg_cornermask,
- 0,
- 0,
- $imgX,
- $imgY,
- $color_transparent));
+ $this->_image->call('imageCopyResampled',
+ array($gdimg_cornermask,
+ $gdimg_cornermask_triple,
+ 0,
+ $imgY - $radius_y,
+ $radius_x,
+ $radius_y * 3,
+ $radius_x,
+ $radius_y,
+ $radius_x * 2,
+ $radius_y * 2));
- $this->_image->call('imageCopyResampled',
- array($gdimg_cornermask,
- $gdimg_cornermask_triple,
- 0,
- 0,
- $radius_x,
- $radius_y,
- $radius_x,
- $radius_y,
- $radius_x * 2,
- $radius_y * 2));
+ $this->_image->call('imageCopyResampled',
+ array($gdimg_cornermask,
+ $gdimg_cornermask_triple,
+ $imgX - $radius_x,
+ $imgY - $radius_y,
+ $radius_x * 3,
+ $radius_y * 3,
+ $radius_x,
+ $radius_y,
+ $radius_x * 2,
+ $radius_y * 2));
- $this->_image->call('imageCopyResampled',
- array($gdimg_cornermask,
- $gdimg_cornermask_triple,
- 0,
- $imgY - $radius_y,
- $radius_x,
- $radius_y * 3,
- $radius_x,
- $radius_y,
- $radius_x * 2,
- $radius_y * 2));
+ $this->_image->call('imageCopyResampled',
+ array($gdimg_cornermask,
+ $gdimg_cornermask_triple,
+ $imgX - $radius_x,
+ 0,
+ $radius_x * 3,
+ $radius_y,
+ $radius_x,
+ $radius_y,
+ $radius_x * 2,
+ $radius_y * 2));
- $this->_image->call('imageCopyResampled',
- array($gdimg_cornermask,
- $gdimg_cornermask_triple,
- $imgX - $radius_x,
- $imgY - $radius_y,
- $radius_x * 3,
- $radius_y * 3,
- $radius_x,
- $radius_y,
- $radius_x * 2,
- $radius_y * 2));
-
- $this->_image->call('imageCopyResampled',
- array($gdimg_cornermask,
- $gdimg_cornermask_triple,
- $imgX - $radius_x,
- 0,
- $radius_x * 3,
- $radius_y,
- $radius_x,
- $radius_y,
- $radius_x * 2,
- $radius_y * 2));
-
- $result = $this->_image->applyMask($gdimg_cornermask);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
- $this->_image->call('imageDestroy', array($gdimg_cornermask));
- return true;
- } else {
- return $gdimg_cornermas; // PEAR_Error
- }
- $this->_image->call('imageDestroy',
- array($gdimg_cornermask_triple));
- } else {
- return $gdimg_cornermas_triple; // PEAR_Error
- }
+ $result = $this->_image->_applyMask($gdimg_cornermask);
+ $this->_image->call('imageDestroy', array($gdimg_cornermask));
+ $this->_image->call('imageDestroy', array($gdimg_cornermask_triple));
+
+ return true;
}
}
\ No newline at end of file
*/
public function apply()
{
- $color = $this->_image->call('imageColorClosest',
- array($this->_image->_im, 255, 255, 255));
- if (is_a($color, 'PEAR_Error')) {
- return $color;
- }
- $shadow = $this->_image->call('imageColorClosest',
- array($this->_image->_im, 0, 0, 0));
- if (is_a($shadow, 'PEAR_Error')) {
- return $shadow;
- }
+ $color = $this->_image->call('imageColorClosest', array($this->_image->_im, 255, 255, 255));
+ $shadow = $this->_image->call('imageColorClosest', array($this->_image->_im, 0, 0, 0));
// Shadow offset in pixels.
$drop = 1;
$f = $this->_image->getFont($this->_params['fontsize']);
$fontwidth = $this->_image->call('imageFontWidth', array($f));
- if (is_a($fontwidth, 'PEAR_Error')) {
- return $fontwidth;
- }
$fontheight = $this->_image->call('imageFontHeight', array($f));
- if (is_a($fontheight, 'PEAR_Error')) {
- return $fontheight;
- }
// So that shadow is not off the image with right align and bottom valign.
$margin = floor($padding + $drop) / 2;
default:
foreach ($lines as $line) {
- if (is_a($result = $this->_image->call('imageString', array($this->_image->_im, $f, $margin + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) {
- return $result;
- }
- $result = $this->_image->call('imageString', array($this->_image->_im, $f, $margin, $y, $line, $color));
+ $this->_image->call('imageString', array($this->_image->_im, $f, $margin + $drop, ($y + $drop), $line, $shadow));
+ $this->_image->call('imageString', array($this->_image->_im, $f, $margin, $y, $line, $color));
$y += $fontheight;
}
break;
}
-
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
}
}
\ No newline at end of file