Author: Chuck Hagenbuch (chuck@horde.org)
Author: Michael J. Rubinsky (mrubinsk@horde.org)
Author: Jan Schneider (jan@horde.org)
コード例 #1
0
ファイル: TextWatermark.php プロジェクト: horde/horde
 /**
  * Applies the effect.
  */
 public function apply()
 {
     /* Determine placement on image */
     switch ($this->_params['valign']) {
         case 'bottom':
             $v = 'south';
             break;
         case 'center':
             $v = 'center';
             break;
         default:
             $v = 'north';
     }
     switch ($this->_params['halign']) {
         case 'right':
             $h = 'east';
             break;
         case 'center':
             $h = 'center';
             break;
         default:
             $h = 'west';
     }
     if ($v == 'center' && $h != 'center' || $v == 'center' && $h == 'center') {
         $gravity = $h;
     } elseif ($h == 'center' && $v != 'center') {
         $gravity = $v;
     } else {
         $gravity = $v . $h;
     }
     /* Determine font point size */
     $point = Horde_Image::getFontSize($this->_params['fontsize']);
     //@TODO:
     throw new Horde_Image_Exception('Not Yet Implemented.');
 }
コード例 #2
0
ファイル: TextWatermark.php プロジェクト: horde/horde
 /**
  * Applies the effect.
  */
 public function apply()
 {
     /* Determine placement on image */
     switch ($this->_params['valign']) {
         case 'bottom':
             $v = 'south';
             break;
         case 'center':
             $v = 'center';
             break;
         default:
             $v = 'north';
     }
     switch ($this->_params['halign']) {
         case 'right':
             $h = 'east';
             break;
         case 'center':
             $h = 'center';
             break;
         default:
             $h = 'west';
     }
     if ($v == 'center' && $h != 'center' || $v == 'center' && $h == 'center') {
         $gravity = $h;
     } elseif ($h == 'center' && $v != 'center') {
         $gravity = $v;
     } else {
         $gravity = $v . $h;
     }
     /* Determine font point size */
     $point = Horde_Image::getFontSize($this->_params['fontsize']);
     $this->_image->raw();
     $this->_image->addPostSrcOperation(' -font ' . $this->_params['font'] . ' -pointsize ' . $point . ' \\( +clone -resize 1x1 -fx 1-intensity -threshold 50% -scale 32x32 -write mpr:color +delete \\) -tile mpr:color -gravity ' . $gravity . ' -annotate +20+10 "' . $this->_params['text'] . '"');
     $this->_image->raw();
 }
コード例 #3
0
ファイル: Kronolith.php プロジェクト: AsylumCorp/horde
 /**
  * Returns the foreground color for a calendar or a background color.
  *
  * @param array|Horde_Share_Object|string $calendar  A color string, a
  *                                                   calendar share or a
  *                                                   hash from a remote
  *                                                   calender definition.
  *
  * @return string  A HTML color code.
  */
 public static function foregroundColor($calendar)
 {
     return Horde_Image::brightness(is_string($calendar) ? $calendar : self::backgroundColor($calendar)) < 128 ? '#fff' : '#000';
 }
コード例 #4
0
ファイル: Imagick.php プロジェクト: jubinpatel/horde
 /**
  * Draws a text string on the image in a specified location, with
  * the specified style information.
  *
  * @TODO: Need to differentiate between the stroke (border) and the fill color,
  *        but this is a BC break, since we were just not providing a border.
  *
  * @param string  $text       The text to draw.
  * @param integer $x          The left x coordinate of the start of the text string.
  * @param integer $y          The top y coordinate of the start of the text string.
  * @param string  $font       The font identifier you want to use for the text.
  * @param string  $color      The color that you want the text displayed in.
  * @param integer $direction  An integer that specifies the orientation of the text.
  * @param string  $fontsize   Size of the font (small, medium, large, giant)
  */
 public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small')
 {
     $fontsize = Horde_Image::getFontSize($fontsize);
     $pixel = new ImagickPixel($color);
     $draw = new ImagickDraw();
     $draw->setFillColor($pixel);
     if (!empty($font)) {
         $draw->setFont($font);
     }
     $draw->setFontSize($fontsize);
     $draw->setGravity(Imagick::GRAVITY_NORTHWEST);
     try {
         $res = $this->_imagick->annotateImage($draw, $x, $y, $direction, $string);
     } catch (ImagickException $e) {
         throw new Horde_Image_Exception($e);
     }
     $draw->destroy();
 }
コード例 #5
0
 protected function _renderVarInput_colorpicker($form, &$var, &$vars)
 {
     global $registry, $browser;
     $varname = $this->_genID($var->getVarName(), false);
     $color = $var->getValue($vars);
     if ($color) {
         $style = ' style="background-color:' . $color . ';color:' . (Horde_Image::brightness($color) < 128 ? '#fff' : '#000') . '"';
     } else {
         $style = '';
     }
     $html = '<table cellspacing="0"><tr><td>' . '<input type="text" size="10" maxlength="7" name="' . htmlspecialchars($var->getVarName()) . '" id="' . $varname . '"' . $style . ' value="' . htmlspecialchars($color) . '" /></td>';
     if ($browser->hasFeature('javascript')) {
         $GLOBALS['injector']->getInstance('Horde_PageOutput')->addScriptFile('colorpicker.js', 'horde');
         $html .= '<td>' . Horde::link('#', Horde_Core_Translation::t("Color Picker"), '', '', 'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;') . Horde::img('colorpicker.png', Horde_Core_Translation::t("Color Picker"), 'height="16"') . '</a></td>';
     }
     return $html . '</tr></table>';
 }
コード例 #6
0
ファイル: Swf.php プロジェクト: horde/horde
 /**
  * Draws an arc.
  *
  * @param integer $x      The x co-ordinate of the centre.
  * @param integer $y      The y co-ordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string $color   The line color of the arc.
  * @param string $fill    The fill color of the arc.
  */
 public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
 {
     $s = new SWFShape();
     $color = $this->allocateColor($color);
     $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']);
     if ($fill != 'none') {
         $fillColor = $this->allocateColor($fill);
         $s->setRightFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']);
     }
     $pts = Horde_Image::arcPoints($r, $start, $end);
     $s->movePenTo($x, $y);
     $s->drawArc($r, $start + 90, $end + 90);
     $s->movePenTo($x, $y);
     $s->drawLineTo(round($pts['x1']) + $x, round($pts['y1']) + $y);
     $s->movePenTo($x, $y);
     $s->drawLineTo(round($pts['x2']) + $x, round($pts['y2']) + $y);
     $this->_movie->add($s);
 }
コード例 #7
0
ファイル: Svg.php プロジェクト: horde/horde
 /**
  * Draws an arc.
  *
  * @param integer $x      The x coordinate of the centre.
  * @param integer $y      The y coordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string $color   The line color of the arc.
  * @param string $fill    The fill color of the arc (defaults to none).
  */
 public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null)
 {
     if (!empty($fill)) {
         $style = 'fill:' . Horde_Image::getHexColor($fill) . '; ';
     } else {
         $style = 'fill:none;';
     }
     $style .= 'stroke:' . Horde_Image::getHexColor($color) . '; stroke-width:1';
     $mid = round(($start + $end) / 2);
     // Calculate the path entry.
     $path = '';
     // If filled, draw the outline.
     if (!empty($fill)) {
         // Start at the center of the ellipse the arc is on.
         $path .= "M {$x},{$y} ";
         // Draw out to ellipse edge.
         list($arcX, $arcY) = Horde_Image::circlePoint($start, $r * 2);
         $path .= 'L ' . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     }
     // Draw arcs.
     list($arcX, $arcY) = Horde_Image::circlePoint($mid, $r * 2);
     $path .= "A {$r},{$r} 0 0 1 " . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     list($arcX, $arcY) = Horde_Image::circlePoint($end, $r * 2);
     $path .= "A {$r},{$r} 0 0 1 " . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     // If filled, close the outline.
     if (!empty($fill)) {
         $path .= 'Z';
     }
     $path = trim($path);
     $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, 'style' => $style)));
 }
コード例 #8
0
ファイル: Task.php プロジェクト: GenerationLabs/horde
 /**
  * Returns the foreground color.
  *
  * @return string  A HTML color code.
  */
 public function foregroundColor()
 {
     return Horde_Image::brightness($this->backgroundColor()) < 128 ? '#fff' : '#000';
 }
コード例 #9
0
ファイル: Html.php プロジェクト: horde/horde
 protected function _renderVarDisplay_colorpicker($form, &$var, &$vars)
 {
     $color = $var->getValue($vars);
     return '<span style="background-color:' . $color . ';color:' . (Horde_Image::brightness($color) < 128 ? '#fff' : '#000') . '">' . $color . '</span>';
 }
コード例 #10
0
ファイル: Base.php プロジェクト: raz0rsdge/horde
 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'bgcolor':
             return $this->_bgcolor ? $this->_bgcolor : self::DEFAULT_BG;
         case 'bgdefault':
             return $this->bgcolor == self::DEFAULT_BG;
         case 'canset':
             return $this->_canset;
         case 'css':
             return $this->_css;
         case 'cssicon':
             return $this->_cssIcon ? $this->_cssIcon : $this->_css;
         case 'span':
             return $this->_css ? '<span class="iconImg msgflags ' . $this->css . '" title="' . htmlspecialchars($this->label) . '">&nbsp;</span>' : '';
         case 'fgcolor':
             return Horde_Image::brightness($this->bgcolor) < 128 ? '#f6f6f6' : '#000';
         case 'form_set':
             return $this->id;
         case 'form_unset':
             return '0\\' . $this->id;
         case 'hash':
             return hash('md5', $this->id);
         case 'id':
             return $this->_id;
         case 'label':
             return $this->getLabel();
     }
 }
コード例 #11
0
ファイル: barcode.php プロジェクト: Artea/freebeer
<?php

/**
 * $Horde: horde/util/barcode.php,v 1.6 2004/01/05 22:45:44 slusarz Exp $
 *
 * Copyright 2002-2004 Chuck Hagenbuch <*****@*****.**>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */
define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Image.php';
header('Pragma: public');
$image =& Horde_Image::factory(Util::getFormData('type', 'png'));
$image->headers();
echo $image->makeBarcode(Util::getFormData('barcode', 'test'));
コード例 #12
0
ファイル: pixel.php プロジェクト: Artea/freebeer
<?php

/**
 * $Horde: horde/services/images/pixel.php,v 1.10 2004/01/05 22:45:47 slusarz Exp $
 *
 * Copyright 2002-2004 Chuck Hagenbuch <*****@*****.**>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */
define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Image.php';
$gif =& Horde_Image::factory('gif', array('rgb' => Util::getFormData('c')));
header('Content-type: image/gif');
header('Expires: Wed, 21 Aug 1969 11:11:11 GMT');
header('Cache-Control: no-cache');
header('Cache-Control: must-revalidate');
echo $gif->makePixel();
コード例 #13
0
ファイル: Swf.php プロジェクト: jubinpatel/horde
 /**
  * Draw an arc.
  *
  * @param integer $x      The x co-ordinate of the centre.
  * @param integer $y      The y co-ordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string $color   The line color of the arc.
  * @param string $fill    The fill color of the arc.
  */
 function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
 {
     $s = new SWFShape();
     $color = $this->allocateColor($color);
     $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']);
     if ($fill != 'none') {
         $fillColor = $this->allocateColor($fill);
         $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']);
         $s->setRightFill($f);
     }
     if ($end - $start <= 45) {
         $pts = Horde_Image::arcPoints($r, $start, $end);
         $s->movePenTo($x, $y);
         $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y);
         $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y);
         $s->drawLineTo($x, $y);
     } else {
         $sections = ceil(($end - $start) / 45);
         for ($i = 0; $i < $sections; $i++) {
             $pts = Horde_Image::arcPoints($r, $start + $i * 45, $start + ($i + 1) * 45 > $end ? $end : $start + ($i + 1) * 45);
             // If we are on the first section, move the pen to the
             // centre and draw out to the edge.
             if ($i == 0 && $fill != 'none') {
                 $s->movePenTo($x, $y);
                 $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y);
             } else {
                 $s->movePenTo($pts['x1'] + $x, $pts['y1'] + $y);
             }
             // Draw the arc.
             $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y);
         }
         if ($fill != 'none') {
             // Draw a line from the edge back to the centre to close
             // off the segment.
             $s->drawLineTo($x, $y);
         }
     }
     return $this->_movie->add($s);
 }
コード例 #14
0
ファイル: CategoryManager.php プロジェクト: jubinpatel/horde
 /**
  * Returns the foreground color for each of the user's categories.
  *
  * @return array  A list of colors, key is the category name, value is the
  *                HTML color code.
  */
 public static function fgColors()
 {
     $colors = self::colors();
     $fgcolors = array();
     foreach ($colors as $name => $color) {
         $fgcolors[$name] = Horde_Image::brightness($color) < 128 ? '#f6f6f6' : '#000';
     }
     return $fgcolors;
 }
コード例 #15
0
ファイル: Gd.php プロジェクト: jubinpatel/horde
 /**
  * Applies the specified mask to the image.
  *
  * @param resource $gdimg_mask  The gd image resource representing the mask
  *
  * @return boolean
  */
 public function applyMask($gdimg_mask)
 {
     $imgX = round($this->call('imageSX', array($this->_im)));
     $imgY = round($this->call('imageSY', array($this->_im)));
     $gdimg_mask_resized = $this->create($imgX, $imgY);
     $result = $this->call('imageCopyResampled', array($gdimg_mask_resized, $gdimg_mask, 0, 0, 0, 0, $imgX, $imgY, $this->call('imageSX', array($gdimg_mask)), $this->call('imageSY', array($gdimg_mask))));
     $gdimg_mask_blendtemp = $this->create($imgX, $imgY);
     $mbtX = $this->call('imageSX', array($gdimg_mask_blendtemp));
     $mbtY = $this->call('imageSY', array($gdimg_mask_blendtemp));
     $color_background = $this->call('imageColorAllocate', array($gdimg_mask_blendtemp, 0, 0, 0));
     $this->call('imageFilledRectangle', array($gdimg_mask_blendtemp, 0, 0, $mbtX, $mbtY, $color_background));
     $this->call('imageAlphaBlending', array($gdimg_mask_blendtemp, false));
     $this->call('imageSaveAlpha', array($gdimg_mask_blendtemp, true));
     for ($x = 0; $x < $imgX; $x++) {
         for ($y = 0; $y < $imgY; $y++) {
             $colorat = $this->call('imageColorAt', array($this->_im, $x, $y));
             $realPixel = $this->call('imageColorsForIndex', array($this->_im, $colorat));
             $colorat = $this->call('imageColorAt', array($gdimg_mask_resized, $x, $y));
             $maskPixel = Horde_Image::grayscalePixel($this->call('imageColorsForIndex', array($gdimg_mask_resized, $colorat)));
             $maskAlpha = 127 - floor($maskPixel['red'] / 2) * (1 - $realPixel['alpha'] / 127);
             $newcolor = $this->_allocateColorAlpha($gdimg_mask_blendtemp, $realPixel['red'], $realPixel['green'], $realPixel['blue'], intval($maskAlpha));
             $this->call('imageSetPixel', array($gdimg_mask_blendtemp, $x, $y, $newcolor));
         }
     }
     $this->call('imageAlphaBlending', array($this->_im, false));
     $this->call('imageSaveAlpha', array($this->_im, true));
     $this->call('imageCopy', array($this->_im, $gdimg_mask_blendtemp, 0, 0, 0, 0, $mbtX, $mbtY));
     $this->call('imageDestroy', array($gdimg_mask_blendtemp));
     $this->call('imageDestroy', array($gdimg_mask_resized));
     return true;
 }
コード例 #16
0
ファイル: Png.php プロジェクト: horde/horde
 /**
  * Draws a rectangle.
  *
  * @param integer $x       The left x-coordinate of the rectangle.
  * @param integer $y       The top y-coordinate of the rectangle.
  * @param integer $width   The width of the rectangle.
  * @param integer $height  The height of the rectangle.
  * @param string $color    The line color of the rectangle.
  * @param string $fill     The color to fill the rectangle.
  */
 public function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none')
 {
     list($r, $g, $b) = Horde_Image::getRGB($color);
     if ($fill != 'none') {
         list($fR, $fG, $fB) = Horde_Image::getRGB($fill);
     }
     $x2 = $x + $width;
     $y2 = $y + $height;
     for ($h = $y; $h <= $y2; $h++) {
         for ($w = $x; $w <= $x2; $w++) {
             // See if we're on an edge.
             if ($w == $x || $h == $y || $w == $x2 || $h == $y2) {
                 $this->_img[$h][$w] = array('r' => $r, 'g' => $g, 'b' => $b);
             } elseif ($fill != 'none') {
                 $this->_img[$h][$w] = array('r' => $fR, 'g' => $fG, 'b' => $fB);
             }
         }
     }
 }
コード例 #17
0
ファイル: Imagick.php プロジェクト: raz0rsdge/horde
 /**
  * Draws an arc.
  *
  * @param integer $x      The x coordinate of the centre.
  * @param integer $y      The y coordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string $color   The line color of the arc.
  * @param string $fill    The fill color of the arc (defaults to none).
  */
 public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
 {
     $points = Horde_Image::arcPoints($r, $start, $end);
     $points['x1'] += $x;
     $points['x2'] += $x;
     $points['x3'] += $x;
     $points['y1'] += $y;
     $points['y2'] += $y;
     $points['y3'] += $y;
     try {
         $draw = new ImagickDraw();
         $draw->setStrokeColor(new ImagickPixel($color));
         $draw->setFillColor(new ImagickPixel($fill));
         $draw->arc($x - $r, $y - $r, $x + $r, $y + $r, $start, $end);
     } catch (ImagickDrawException $e) {
         throw new Horde_Image_Exception($e);
     } catch (ImagickPixelException $e) {
         throw new Horde_Image_Exception($e);
     }
     // If filled, draw the outline.
     if (!empty($fill)) {
         $mid = round(($start + $end) / 2);
         list($x1, $y1) = Horde_Image::circlePoint($start, $r * 2);
         list($x2, $y2) = Horde_Image::circlePoint($mid, $r * 2);
         list($x3, $y3) = Horde_Image::circlePoint($end, $r * 2);
         $verts = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
         if ($mid > 90) {
             $verts1 = array(array('x' => $x + round($x2), 'y' => $y + round($y2)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
             $verts2 = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x2), 'y' => $y + round($y2)));
             $this->polygon($verts1, $fill, $fill);
             $this->polygon($verts2, $fill, $fill);
         } else {
             $this->polygon($verts, $fill, $fill);
         }
         $this->polyline($verts, $color);
     }
     try {
         $this->_imagick->drawImage($draw);
     } catch (ImagickException $e) {
         throw new Horde_Image_Exception($e);
     }
     $draw->destroy();
 }
コード例 #18
0
ファイル: Im.php プロジェクト: horde/horde
 /**
  * Draws an arc.
  *
  * @param integer $x      The x coordinate of the centre.
  * @param integer $y      The y coordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string  $color  The line color of the arc.
  * @param string  $fill   The fill color of the arc (defaults to none).
  */
 public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none')
 {
     // Split up arcs greater than 180 degrees into two pieces.
     $this->_postSrcOperations[] = "-stroke {$color} -fill {$fill}";
     $mid = round(($start + $end) / 2);
     $x = round($x);
     $y = round($y);
     $r = round($r);
     if ($mid > 90) {
         $this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$start},{$mid}\"";
         $this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$mid},{$end}\"";
     } else {
         $this->_postSrcOperations[] = "-draw \"ellipse {$x},{$y} {$r},{$r} {$start},{$end}\"";
     }
     // If filled, draw the outline.
     if (!empty($fill)) {
         list($x1, $y1) = Horde_Image::circlePoint($start, $r * 2);
         list($x2, $y2) = Horde_Image::circlePoint($mid, $r * 2);
         list($x3, $y3) = Horde_Image::circlePoint($end, $r * 2);
         $verts = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
         if ($mid > 90) {
             $verts1 = array(array('x' => $x + round($x2), 'y' => $y + round($y2)), array('x' => $x, 'y' => $y), array('x' => $x + round($x1), 'y' => $y + round($y1)));
             $verts2 = array(array('x' => $x + round($x3), 'y' => $y + round($y3)), array('x' => $x, 'y' => $y), array('x' => $x + round($x2), 'y' => $y + round($y2)));
             $this->polygon($verts1, $fill, $fill);
             $this->polygon($verts2, $fill, $fill);
         } else {
             $this->polygon($verts, $fill, $fill);
         }
         $this->polyline($verts, $color);
         $this->_postSrcOperations[] = '-stroke none -fill none';
     }
 }
コード例 #19
0
ファイル: Image.php プロジェクト: horde/horde
 /**
  * Turns an RGB value into grayscale.
  *
  * @param integer[] $originalPixel  A hash with 'red', 'green', and 'blue'
  *                                  values.
  *
  * @return integer[]  A hash with 'red', 'green', and 'blue' values for the
  *                    corresponding gray color.
  */
 public static function grayscalePixel($originalPixel)
 {
     $gray = Horde_Image::grayscaleValue($originalPixel['red'], $originalPixel['green'], $originalPixel['blue']);
     return array('red' => $gray, 'green' => $gray, 'blue' => $gray);
 }
コード例 #20
0
ファイル: Sidebar.php プロジェクト: raz0rsdge/horde
 /**
  * Adds a row to the sidebar.
  *
  * If containers/sections are not added explicitly to the view
  * through the "containers" property, these rows will be used
  * instead.
  *
  * @param array $row         A hash with the row information. Possible
  *                           values:
  *   - label: (string) The row text.
  *   - selected: (boolean) Whether to mark the row as active.
  *   - style: (string) Additional CSS styles to apply to the row.
  *   - url (string) URL to link the row to.
  *   - type (string, optional) The row type, defaults to "tree". Further
  *     $row properties depending on the type:
  *     - tree:
  *       - cssClass: (string) CSS class for the icon.
  *       - id: (string) DOM ID for the row link.
  *     - checkbox:
  *     - radiobox:
  *       - color: (string, optional) Background color.
  *       - edit: (string, optional) URL for extra edit icon.
  * @param string $container  If using multiple sidebar sections, the ID of
  *                           the section to add the row to. Sections will
  *                           be rendered in the order of their first usage.
  */
 public function addRow(array $row, $container = '')
 {
     if (!isset($this->containers[$container])) {
         $this->containers[$container] = array('rows' => array());
         if ($container) {
             $this->containers[$container]['id'] = $container;
         }
     }
     $boxrow = isset($row['type']) && ($row['type'] == 'checkbox' || $row['type'] == 'radiobox');
     $label = htmlspecialchars($row['label']);
     if (isset($row['url'])) {
         $url = empty($row['url']) ? new Horde_Url() : $row['url'];
         if ($boxrow) {
             $attributes = array();
         } else {
             $ak = Horde::getAccessKey($label);
             $attributes = $ak ? array('accesskey' => $ak) : array();
         }
         foreach (array('onclick', 'target', 'class') as $attribute) {
             if (!empty($row[$attribute])) {
                 $attributes[$attribute] = $row[$attribute];
             }
         }
         if ($boxrow) {
             $class = 'horde-resource-' . (empty($row['selected']) ? 'off' : 'on');
             if ($row['type'] == 'radiobox') {
                 $class .= ' horde-radiobox';
             }
             if (empty($attributes['class'])) {
                 $attributes['class'] = $class;
             } else {
                 $attributes['class'] .= ' ' . $class;
             }
             $row['link'] = $url->link($attributes) . $label . '</a>';
         } else {
             $row['link'] = $url->link($attributes) . Horde::highlightAccessKey($label, $ak) . '</a>';
         }
     } else {
         $row['link'] = '<span class="horde-resource-none">' . $label . '</span>';
     }
     if ($boxrow) {
         $this->containers[$container]['type'] = $row['type'];
         if (!isset($row['style'])) {
             $row['style'] = '';
         }
         if (!isset($row['color'])) {
             $row['color'] = '#dddddd';
         }
         $foreground = '000';
         if (Horde_Image::brightness($row['color']) < 128) {
             $foreground = 'fff';
         }
         if (strlen($row['style'])) {
             $row['style'] .= ';';
         }
         $row['style'] .= 'background-color:' . $row['color'] . ';color:#' . $foreground;
         if (isset($row['edit'])) {
             $row['editLink'] = $row['edit']->link(array('title' => _("Edit"), 'class' => 'horde-resource-edit-' . $foreground)) . '&#9658;' . '</a>';
         }
     }
     $this->containers[$container]['rows'][] = $row;
 }
コード例 #21
0
ファイル: view.php プロジェクト: Artea/freebeer
                copy($tmpdir . '/' . $file, $file_name);
            }
        }
        if (!file_exists($file_name)) {
            Horde::logMessage(sprintf('Image not found [%s]', $file_name), __FILE__, __LINE__, PEAR_LOG_ERR);
            exit;
        }
        $size = filesize($file_name);
        $fp = @fopen($file_name, 'r');
        $file_data = fread($fp, $size);
        fclose($fp);
        break;
}
/* Load the image object. */
require_once HORDE_LIBS . 'Horde/Image.php';
$image =& Horde_Image::singleton('gd');
$image->loadString($file, $file_data);
/* Check if no editing action required and send the image to browser. */
if (empty($action)) {
    $image->display();
    exit;
}
/* Image editing required. */
switch ($action) {
    case 'rotate':
        $image->rotate(Util::getFormData('v'));
        break;
    case 'flip':
        $image->flip();
        break;
    case 'mirror':