Browse Source

improved camera

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
a458c4a2f0

+ 21
- 3
app/Http/Business/Cameras/AbstractCamera.php View File

8
 
8
 
9
 namespace app\Http\Business\Cameras;
9
 namespace app\Http\Business\Cameras;
10
 
10
 
11
-
12
 use App\Http\DBO\CamerasDbo;
11
 use App\Http\DBO\CamerasDbo;
13
-use app\Http\DBO\CamerasImageDbo;
12
+use App\Http\DBO\CamerasImageDbo;
13
+use Imagine\Imagick\Image;
14
+use Imagine\Imagick\Imagine;
14
 
15
 
15
 abstract class AbstractCamera
16
 abstract class AbstractCamera
16
 {
17
 {
18
      * @var CamerasDbo
19
      * @var CamerasDbo
19
      */
20
      */
20
     protected $_camera;
21
     protected $_camera;
22
+    /**
23
+     * @var $_imagine Imagine
24
+     */
25
+    protected $_imagine;
26
+    /**
27
+     * @var $_image Image
28
+     */
29
+    protected $_image;
21
 
30
 
22
     public function __construct(CamerasDbo $camera)
31
     public function __construct(CamerasDbo $camera)
23
     {
32
     {
24
         $this->_camera = $camera;
33
         $this->_camera = $camera;
34
+        $this->_imagine = new Imagine();
25
     }
35
     }
26
 
36
 
27
     /**
37
     /**
28
      * @return CamerasImageDbo
38
      * @return CamerasImageDbo
29
      */
39
      */
30
-    public abstract function getImage();
40
+    public function getImage()
41
+    {
42
+        $this->prepareImage();
43
+        $imageDbo = new CamerasImageDbo();
44
+        $imageDbo->setImage(base64_encode($this->_image->get("jpeg")));
45
+        return $imageDbo;
46
+    }
47
+
48
+    public abstract function prepareImage();
31
 }
49
 }

+ 1
- 20
app/Http/Business/Cameras/DummyCamera.php View File

8
 
8
 
9
 namespace App\Http\Business\Cameras;
9
 namespace App\Http\Business\Cameras;
10
 
10
 
11
-
12
 use App\Http\DBO\CamerasDbo;
11
 use App\Http\DBO\CamerasDbo;
13
-use App\Http\DBO\CamerasImageDbo;
14
 use Imagine\Image\Box;
12
 use Imagine\Image\Box;
15
 use Imagine\Image\Palette\RGB;
13
 use Imagine\Image\Palette\RGB;
16
 use Imagine\Image\Point;
14
 use Imagine\Image\Point;
17
-use Imagine\Imagick\Image;
18
-use Imagine\Imagick\Imagine;
19
 
15
 
20
 class DummyCamera extends AbstractCamera
16
 class DummyCamera extends AbstractCamera
21
 {
17
 {
22
-    /**
23
-     * @var $_image Image
24
-     */
25
-    private $_image;
26
-    /**
27
-     * @var $_imagine Imagine
28
-     */
29
-    private $_imagine;
30
 
18
 
31
     public function __construct(CamerasDbo $camera)
19
     public function __construct(CamerasDbo $camera)
32
     {
20
     {
33
         parent::__construct($camera);
21
         parent::__construct($camera);
34
-        $this->_imagine = new Imagine();
35
         $this->_image = $this->_imagine->open("../resources/images/dummy_camera.jpg");
22
         $this->_image = $this->_imagine->open("../resources/images/dummy_camera.jpg");
36
     }
23
     }
37
 
24
 
38
-    /**
39
-     * @return CamerasImageDbo
40
-     */
41
-    public function getImage()
25
+    public function prepareImage()
42
     {
26
     {
43
-        $imageDbo = new CamerasImageDbo();
44
         $draw = $this->_image->draw();
27
         $draw = $this->_image->draw();
45
         $palette = new RGB();
28
         $palette = new RGB();
46
         $radius = rand(10, 42);
29
         $radius = rand(10, 42);
47
         $draw->ellipse(new Point(42, 42), new Box($radius, $radius), $palette->color('#ff0000'));
30
         $draw->ellipse(new Point(42, 42), new Box($radius, $radius), $palette->color('#ff0000'));
48
-        $imageDbo->setImage(base64_encode($this->_image->get("jpeg")));
49
-        return $imageDbo;
50
     }
31
     }
51
 }
32
 }

Loading…
Cancel
Save