コード例 #1
0
ファイル: DriverTest.php プロジェクト: hilmysyarif/sic
 public function testNewImageGd()
 {
     $driver = new GdDriver(Mockery::mock('\\Intervention\\Image\\Gd\\Decoder'), Mockery::mock('\\Intervention\\Image\\Gd\\Encoder'));
     $image = $driver->newImage(300, 200, '00ff00');
     $this->assertInstanceOf('\\Intervention\\Image\\Image', $image);
     $this->assertInstanceOf('\\Intervention\\Image\\Gd\\Driver', $image->getDriver());
     $this->assertInternalType('resource', $image->getCore());
 }
コード例 #2
0
ファイル: Container.php プロジェクト: EdgarPost/image
 public static function initFromDecoded(Decoded $decoded)
 {
     $container = new self();
     $container->setLoops($decoded->getLoops());
     // create empty canvas
     $driver = new Driver();
     $canvas = $driver->newImage($decoded->getCanvasWidth(), $decoded->getCanvasHeight())->getCore();
     foreach ($decoded->getFrames() as $key => $frame) {
         // create resource from frame
         $encoder = new GifEncoder();
         $encoder->setFromDecoded($decoded, $key);
         $frame_resource = imagecreatefromstring($encoder->encode());
         // insert frame image data into canvas
         imagecopy($canvas, $frame_resource, $frame->getOffset()->left, $frame->getOffset()->top, 0, 0, $frame->getSize()->width, $frame->getSize()->height);
         // destory frame resource
         imagedestroy($frame_resource);
         // add frame to container
         $container->addFrame(new \Intervention\Image\Frame($canvas, $frame->getDelay()));
         // prepare next canvas
         $canvas = Helper::cloneResource($canvas);
     }
     return $container;
 }