Quellcode durchsuchen

improved camera

tags/0.1.0
Robin Thoni vor 9 Jahren
Ursprung
Commit
a458c4a2f0

+ 21
- 3
app/Http/Business/Cameras/AbstractCamera.php Datei anzeigen

@@ -8,9 +8,10 @@
8 8
 
9 9
 namespace app\Http\Business\Cameras;
10 10
 
11
-
12 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 16
 abstract class AbstractCamera
16 17
 {
@@ -18,14 +19,31 @@ abstract class AbstractCamera
18 19
      * @var CamerasDbo
19 20
      */
20 21
     protected $_camera;
22
+    /**
23
+     * @var $_imagine Imagine
24
+     */
25
+    protected $_imagine;
26
+    /**
27
+     * @var $_image Image
28
+     */
29
+    protected $_image;
21 30
 
22 31
     public function __construct(CamerasDbo $camera)
23 32
     {
24 33
         $this->_camera = $camera;
34
+        $this->_imagine = new Imagine();
25 35
     }
26 36
 
27 37
     /**
28 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 Datei anzeigen

@@ -8,44 +8,25 @@
8 8
 
9 9
 namespace App\Http\Business\Cameras;
10 10
 
11
-
12 11
 use App\Http\DBO\CamerasDbo;
13
-use App\Http\DBO\CamerasImageDbo;
14 12
 use Imagine\Image\Box;
15 13
 use Imagine\Image\Palette\RGB;
16 14
 use Imagine\Image\Point;
17
-use Imagine\Imagick\Image;
18
-use Imagine\Imagick\Imagine;
19 15
 
20 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 19
     public function __construct(CamerasDbo $camera)
32 20
     {
33 21
         parent::__construct($camera);
34
-        $this->_imagine = new Imagine();
35 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 27
         $draw = $this->_image->draw();
45 28
         $palette = new RGB();
46 29
         $radius = rand(10, 42);
47 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
 }

Laden…
Abbrechen
Speichern