示例#1
0
 /**
  * Creates a transparent (PNG, JPG) image with a <code>aWidth</code> and <code>aHeight</code>.
  *
  * @param int $aWidth The width of the image
  * @param int $aHeight The height of the image
  * @return resource
  */
 public static function createTransparentImage($width, $height)
 {
     $imgRes = self::createImage($width, $height);
     $color = ColorFactory::white(127);
     $transparent = self::allocateColor($imgRes, $color);
     imagefill($imgRes, 0, 0, $transparent);
     return $imgRes;
 }
 public function testPngBlue()
 {
     $original = $this->getOriginalImage(ImageType::PNG);
     $res = $this->applyFilter(new ImageFilterColorize(ColorFactory::blue()), $original, __METHOD__);
     $this->assertColorQ1($res, 'ff00ff');
     $this->assertColorQ2($res, '00ffff');
     $this->assertColorQ3($res, self::BLUE);
     // unchanged
     $this->assertColorQ4($res, self::WHITE);
 }
 /**
  * Creates a new ImageFilterRotate
  *
  * @param int $aAngle The degrees to rotate the image
  * @param String $aBgcolor The background color to apply
  *
  */
 public function __construct($angle = 90, $aBgcolor = null)
 {
     $this->angle = Args::int($ange, 'angle')->required()->min(-360)->max(360)->value(function ($val) {
         return $val < 0 ? 360 - $val : $val;
     });
     if ($aBgcolor === null) {
         $this->bgColor = ColorFactory::white();
     } else {
         $this->bgColor = $aBgcolor instanceof Color ? $aBgcolor : new Color($aBgcolor);
     }
 }
示例#4
0
 /**
  * Creates a transparent (PNG, JPG) image with a <code>aWidth</code> and <code>aHeight</code>.
  *
  * @param int $aWidth The width of the image
  * @param int $aHeight The height of the image
  * @return resource
  */
 public static function createTransparentImage($width, $height)
 {
     Args::int($width, 'width')->required()->min(0);
     Args::int($height, 'height')->required()->min(0);
     $color = ColorFactory::white(127);
     $imgRes = imagecreatetruecolor($width, $height);
     imageantialias($imgRes, true);
     imagealphablending($imgRes, true);
     imagesavealpha($imgRes, true);
     $transparent = self::allocateColor($imgRes, $color);
     imagefill($imgRes, 0, 0, $transparent);
     return $imgRes;
 }
 public function testWhite()
 {
     $this->assertColor(ColorFactory::white(), "ffffff");
 }