-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageBitmap.php
More file actions
36 lines (27 loc) · 780 Bytes
/
Copy pathImageBitmap.php
File metadata and controls
36 lines (27 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace LazyBitmap;
use LazyBitmap\Bitmap;
use LazyBitmap\Pixel;
class ImageBitmap extends Bitmap {
private $image;
private $width;
private $height;
public function __construct($source) {
$this->image = imagecreatefromstring(file_get_contents($source));
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
}
public function getPixel($x, $y) {
$index = imagecolorat($this->image, $x, $y);
$colors = imagecolorsforindex($this->image, $index);
$pixel = new Pixel;
$pixel->fromArray($colors);
return $pixel;
}
public function getWidth() {
return $this->width;
}
public function getHeight() {
return $this->height;
}
}