/**
  * Tests ImageResource->setResource()
  */
 public function testSetResource()
 {
     $clone = $this->res->cloneResource();
     $originalRes = $this->res->getResource();
     $this->res->setResource($clone->getResource());
     $this->assertNotEquals($originalRes, $this->res->getResource());
 }
 /**
  * Applies the filter to the resource
  *
  * @param ImageResource $aResource
  */
 public function applyFilter(ImageResource $aResource)
 {
     //comic effect
     $width = $aResource->getX();
     $height = $aResource->getY();
     /* @var $imgK \imagemanipulation\ImageResource */
     $imgK = $aResource->cloneResource();
     $trueColorFilter = new ImageFilterTrueColor('ffffff', '000000');
     $trueColorFilter->applyFilter($imgK);
     imagecopymerge($aResource->getResource(), $imgK->getResource(), 0, 0, 0, 0, $width, $height, $this->opacity);
     imagedestroy($imgK->getResource());
 }
 /**
  * Applies the filter to the resource
  *
  * @param ImageResource $aResource
  */
 public function applyFilter(ImageResource $aResource)
 {
     $width = $aResource->getWidth();
     $height = $aResource->getHeight();
     $lineRes = imagecreatetruecolor($width, 1);
     $bgc = imagecolorallocatealpha($lineRes, $this->backgroundColor->getRed(), $this->backgroundColor->getGreen(), $this->backgroundColor->getBlue(), $this->backgroundColor->getAlpha());
     // Background color
     imagefilledrectangle($lineRes, 0, 0, $width, 1, $bgc);
     $rotated = $aResource->cloneResource();
     $rotateFilter = new ImageFilterRotate(180, $this->backgroundColor);
     $rotateFilter->applyFilter($rotated);
     $bg = imagecreatetruecolor($width, $this->height);
     imagecopyresampled($bg, $rotated->getResource(), 0, 0, 0, 0, $width, $height, $width, $height);
     $im = $bg;
     $bg = imagecreatetruecolor($width, $this->height);
     for ($x = 0; $x < $width; $x++) {
         imagecopy($bg, $im, $x, 0, $width - $x, 0, 1, $this->height);
     }
     $im = $bg;
     $in = 100 / $this->height;
     for ($i = 0; $i <= $this->height; $i++) {
         imagecopymerge($im, $lineRes, 0, $i, 0, 0, $width, 1, $this->startOpacity);
         if ($this->startOpacity < 100) {
             $this->startOpacity += $in;
         }
     }
     imagecopymerge($im, $lineRes, 0, 0, 0, 0, $width, $this->divLineHeight, 100);
     // Divider
     if ($this->includeOriginal) {
         // we need to include the original
         $mergeWidth = imagesx($im) + $aResource->getWidth();
         $mergeHeight = imagesy($im) + $aResource->getHeight();
         $imMerge = imagecreatetruecolor($width, $mergeHeight);
         imagecopy($imMerge, $aResource->getResource(), 0, 0, 0, 0, $width, $height);
         imagecopy($imMerge, $im, 0, $aResource->getHeight(), 0, 0, $width, $height);
         $aResource->setResource($imMerge);
     } else {
         $aResource->setResource($im);
     }
 }