@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package WideImage |
|
22 | - **/ |
|
20 | + * @package WideImage |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Font; |
25 | 24 | |
@@ -30,35 +29,35 @@ discard block |
||
30 | 29 | */ |
31 | 30 | class PS |
32 | 31 | { |
33 | - public $size; |
|
34 | - public $color; |
|
35 | - public $handle; |
|
32 | + public $size; |
|
33 | + public $color; |
|
34 | + public $handle; |
|
36 | 35 | |
37 | - public function __construct($file, $size, $color, $bgcolor = null) |
|
38 | - { |
|
39 | - $this->handle = imagepsloadfont($file); |
|
40 | - $this->size = $size; |
|
41 | - $this->color = $color; |
|
36 | + public function __construct($file, $size, $color, $bgcolor = null) |
|
37 | + { |
|
38 | + $this->handle = imagepsloadfont($file); |
|
39 | + $this->size = $size; |
|
40 | + $this->color = $color; |
|
42 | 41 | |
43 | - if ($bgcolor === null) { |
|
44 | - $this->bgcolor = $color; |
|
45 | - } else { |
|
46 | - $this->color = $color; |
|
47 | - } |
|
48 | - } |
|
42 | + if ($bgcolor === null) { |
|
43 | + $this->bgcolor = $color; |
|
44 | + } else { |
|
45 | + $this->color = $color; |
|
46 | + } |
|
47 | + } |
|
49 | 48 | |
50 | - public function writeText($image, $x, $y, $text, $angle = 0) |
|
51 | - { |
|
52 | - if ($image->isTrueColor()) { |
|
53 | - $image->alphaBlending(true); |
|
54 | - } |
|
49 | + public function writeText($image, $x, $y, $text, $angle = 0) |
|
50 | + { |
|
51 | + if ($image->isTrueColor()) { |
|
52 | + $image->alphaBlending(true); |
|
53 | + } |
|
55 | 54 | |
56 | - imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4); |
|
57 | - } |
|
55 | + imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4); |
|
56 | + } |
|
58 | 57 | |
59 | - public function __destruct() |
|
60 | - { |
|
61 | - imagepsfreefont($this->handle); |
|
62 | - $this->handle = null; |
|
63 | - } |
|
58 | + public function __destruct() |
|
59 | + { |
|
60 | + imagepsfreefont($this->handle); |
|
61 | + $this->handle = null; |
|
62 | + } |
|
64 | 63 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,40 +31,40 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class Rotate |
34 | 33 | { |
35 | - /** |
|
36 | - * Returns rotated image |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @param numeric $angle |
|
40 | - * @param int $bgColor |
|
41 | - * @param bool $ignoreTransparent |
|
42 | - * @return \WideImage\Image |
|
43 | - */ |
|
44 | - public function execute($image, $angle, $bgColor, $ignoreTransparent) |
|
45 | - { |
|
46 | - $angle = -floatval($angle); |
|
34 | + /** |
|
35 | + * Returns rotated image |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @param numeric $angle |
|
39 | + * @param int $bgColor |
|
40 | + * @param bool $ignoreTransparent |
|
41 | + * @return \WideImage\Image |
|
42 | + */ |
|
43 | + public function execute($image, $angle, $bgColor, $ignoreTransparent) |
|
44 | + { |
|
45 | + $angle = -floatval($angle); |
|
47 | 46 | |
48 | - if ($angle < 0) { |
|
49 | - $angle = 360 + $angle; |
|
50 | - } |
|
47 | + if ($angle < 0) { |
|
48 | + $angle = 360 + $angle; |
|
49 | + } |
|
51 | 50 | |
52 | - $angle = $angle % 360; |
|
51 | + $angle = $angle % 360; |
|
53 | 52 | |
54 | - if ($angle == 0) { |
|
55 | - return $image->copy(); |
|
56 | - } |
|
53 | + if ($angle == 0) { |
|
54 | + return $image->copy(); |
|
55 | + } |
|
57 | 56 | |
58 | - $image = $image->asTrueColor(); |
|
57 | + $image = $image->asTrueColor(); |
|
59 | 58 | |
60 | - if ($bgColor === null) { |
|
61 | - $bgColor = $image->getTransparentColor(); |
|
59 | + if ($bgColor === null) { |
|
60 | + $bgColor = $image->getTransparentColor(); |
|
62 | 61 | |
63 | - if ($bgColor == -1) { |
|
64 | - $bgColor = $image->allocateColorAlpha(255, 255, 255, 127); |
|
65 | - imagecolortransparent($image->getHandle(), $bgColor); |
|
66 | - } |
|
67 | - } |
|
62 | + if ($bgColor == -1) { |
|
63 | + $bgColor = $image->allocateColorAlpha(255, 255, 255, 127); |
|
64 | + imagecolortransparent($image->getHandle(), $bgColor); |
|
65 | + } |
|
66 | + } |
|
68 | 67 | |
69 | - return new TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); |
|
70 | - } |
|
68 | + return new TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); |
|
69 | + } |
|
71 | 70 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,41 +31,41 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class ApplyFilter |
34 | 33 | { |
35 | - /** |
|
36 | - * A list of filters that only accept one arguments for imagefilter() |
|
37 | - * |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - protected static $one_arg_filters = array(IMG_FILTER_SMOOTH, IMG_FILTER_CONTRAST, IMG_FILTER_BRIGHTNESS); |
|
34 | + /** |
|
35 | + * A list of filters that only accept one arguments for imagefilter() |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected static $one_arg_filters = array(IMG_FILTER_SMOOTH, IMG_FILTER_CONTRAST, IMG_FILTER_BRIGHTNESS); |
|
41 | 40 | |
42 | - /** |
|
43 | - * Executes imagefilter |
|
44 | - * |
|
45 | - * @param \WideImage\Image $image |
|
46 | - * @param int $filter |
|
47 | - * @param numeric $arg1 |
|
48 | - * @param numeric $arg2 |
|
49 | - * @param numeric $arg3 |
|
50 | - * @return \WideImage\TrueColorImage |
|
51 | - */ |
|
52 | - public function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) |
|
53 | - { |
|
54 | - $new = $image->asTrueColor(); |
|
41 | + /** |
|
42 | + * Executes imagefilter |
|
43 | + * |
|
44 | + * @param \WideImage\Image $image |
|
45 | + * @param int $filter |
|
46 | + * @param numeric $arg1 |
|
47 | + * @param numeric $arg2 |
|
48 | + * @param numeric $arg3 |
|
49 | + * @return \WideImage\TrueColorImage |
|
50 | + */ |
|
51 | + public function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null) |
|
52 | + { |
|
53 | + $new = $image->asTrueColor(); |
|
55 | 54 | |
56 | - if (in_array($filter, static::$one_arg_filters)) { |
|
57 | - $res = imagefilter($new->getHandle(), $filter, $arg1); |
|
58 | - } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) { |
|
59 | - $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
60 | - } elseif ($filter == IMG_FILTER_COLORIZE) { |
|
61 | - $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
62 | - } else { |
|
63 | - $res = imagefilter($new->getHandle(), $filter); |
|
64 | - } |
|
55 | + if (in_array($filter, static::$one_arg_filters)) { |
|
56 | + $res = imagefilter($new->getHandle(), $filter, $arg1); |
|
57 | + } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) { |
|
58 | + $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2); |
|
59 | + } elseif ($filter == IMG_FILTER_COLORIZE) { |
|
60 | + $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); |
|
61 | + } else { |
|
62 | + $res = imagefilter($new->getHandle(), $filter); |
|
63 | + } |
|
65 | 64 | |
66 | - if (!$res) { |
|
67 | - throw new GDFunctionResultException("imagefilter() returned false"); |
|
68 | - } |
|
65 | + if (!$res) { |
|
66 | + throw new GDFunctionResultException("imagefilter() returned false"); |
|
67 | + } |
|
69 | 68 | |
70 | - return $new; |
|
71 | - } |
|
69 | + return $new; |
|
70 | + } |
|
72 | 71 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -34,65 +33,65 @@ discard block |
||
34 | 33 | */ |
35 | 34 | class CopyChannelsPalette |
36 | 35 | { |
37 | - /** |
|
38 | - * Returns an image with only specified channels copied |
|
39 | - * |
|
40 | - * @param \WideImage\PaletteImage $img |
|
41 | - * @param array $channels |
|
42 | - * @return \WideImage\PaletteImage |
|
43 | - */ |
|
44 | - public function execute($img, $channels) |
|
45 | - { |
|
46 | - $blank = array('red' => 0, 'green' => 0, 'blue' => 0); |
|
36 | + /** |
|
37 | + * Returns an image with only specified channels copied |
|
38 | + * |
|
39 | + * @param \WideImage\PaletteImage $img |
|
40 | + * @param array $channels |
|
41 | + * @return \WideImage\PaletteImage |
|
42 | + */ |
|
43 | + public function execute($img, $channels) |
|
44 | + { |
|
45 | + $blank = array('red' => 0, 'green' => 0, 'blue' => 0); |
|
47 | 46 | |
48 | - if (isset($channels['alpha'])) { |
|
49 | - unset($channels['alpha']); |
|
50 | - } |
|
47 | + if (isset($channels['alpha'])) { |
|
48 | + unset($channels['alpha']); |
|
49 | + } |
|
51 | 50 | |
52 | - $width = $img->getWidth(); |
|
53 | - $height = $img->getHeight(); |
|
54 | - $copy = PaletteImage::create($width, $height); |
|
51 | + $width = $img->getWidth(); |
|
52 | + $height = $img->getHeight(); |
|
53 | + $copy = PaletteImage::create($width, $height); |
|
55 | 54 | |
56 | - if ($img->isTransparent()) { |
|
57 | - $otci = $img->getTransparentColor(); |
|
58 | - $TRGB = $img->getColorRGB($otci); |
|
59 | - $tci = $copy->allocateColor($TRGB); |
|
60 | - } else { |
|
61 | - $otci = null; |
|
62 | - $tci = null; |
|
63 | - } |
|
55 | + if ($img->isTransparent()) { |
|
56 | + $otci = $img->getTransparentColor(); |
|
57 | + $TRGB = $img->getColorRGB($otci); |
|
58 | + $tci = $copy->allocateColor($TRGB); |
|
59 | + } else { |
|
60 | + $otci = null; |
|
61 | + $tci = null; |
|
62 | + } |
|
64 | 63 | |
65 | - for ($x = 0; $x < $width; $x++) { |
|
66 | - for ($y = 0; $y < $height; $y++) { |
|
67 | - $ci = $img->getColorAt($x, $y); |
|
64 | + for ($x = 0; $x < $width; $x++) { |
|
65 | + for ($y = 0; $y < $height; $y++) { |
|
66 | + $ci = $img->getColorAt($x, $y); |
|
68 | 67 | |
69 | - if ($ci === $otci) { |
|
70 | - $copy->setColorAt($x, $y, $tci); |
|
71 | - continue; |
|
72 | - } |
|
68 | + if ($ci === $otci) { |
|
69 | + $copy->setColorAt($x, $y, $tci); |
|
70 | + continue; |
|
71 | + } |
|
73 | 72 | |
74 | - $RGB = $img->getColorRGB($ci); |
|
73 | + $RGB = $img->getColorRGB($ci); |
|
75 | 74 | |
76 | - $newRGB = $blank; |
|
75 | + $newRGB = $blank; |
|
77 | 76 | |
78 | - foreach ($channels as $channel) { |
|
79 | - $newRGB[$channel] = $RGB[$channel]; |
|
80 | - } |
|
77 | + foreach ($channels as $channel) { |
|
78 | + $newRGB[$channel] = $RGB[$channel]; |
|
79 | + } |
|
81 | 80 | |
82 | - $color = $copy->getExactColor($newRGB); |
|
81 | + $color = $copy->getExactColor($newRGB); |
|
83 | 82 | |
84 | - if ($color == -1) { |
|
85 | - $color = $copy->allocateColor($newRGB); |
|
86 | - } |
|
83 | + if ($color == -1) { |
|
84 | + $color = $copy->allocateColor($newRGB); |
|
85 | + } |
|
87 | 86 | |
88 | - $copy->setColorAt($x, $y, $color); |
|
89 | - } |
|
90 | - } |
|
87 | + $copy->setColorAt($x, $y, $color); |
|
88 | + } |
|
89 | + } |
|
91 | 90 | |
92 | - if ($img->isTransparent()) { |
|
93 | - $copy->setTransparentColor($tci); |
|
94 | - } |
|
91 | + if ($img->isTransparent()) { |
|
92 | + $copy->setTransparentColor($tci); |
|
93 | + } |
|
95 | 94 | |
96 | - return $copy; |
|
97 | - } |
|
95 | + return $copy; |
|
96 | + } |
|
98 | 97 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,45 +31,45 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class GetMask |
34 | 33 | { |
35 | - /** |
|
36 | - * Returns a mask |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @return \WideImage\Image |
|
40 | - */ |
|
41 | - public function execute($image) |
|
42 | - { |
|
43 | - $width = $image->getWidth(); |
|
44 | - $height = $image->getHeight(); |
|
34 | + /** |
|
35 | + * Returns a mask |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @return \WideImage\Image |
|
39 | + */ |
|
40 | + public function execute($image) |
|
41 | + { |
|
42 | + $width = $image->getWidth(); |
|
43 | + $height = $image->getHeight(); |
|
45 | 44 | |
46 | - $mask = TrueColorImage::create($width, $height); |
|
47 | - $mask->setTransparentColor(-1); |
|
48 | - $mask->alphaBlending(false); |
|
49 | - $mask->saveAlpha(false); |
|
45 | + $mask = TrueColorImage::create($width, $height); |
|
46 | + $mask->setTransparentColor(-1); |
|
47 | + $mask->alphaBlending(false); |
|
48 | + $mask->saveAlpha(false); |
|
50 | 49 | |
51 | - for ($i = 0; $i <= 255; $i++) { |
|
52 | - $greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i); |
|
53 | - } |
|
50 | + for ($i = 0; $i <= 255; $i++) { |
|
51 | + $greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i); |
|
52 | + } |
|
54 | 53 | |
55 | - imagefilledrectangle($mask->getHandle(), 0, 0, $width, $height, $greyscale[255]); |
|
54 | + imagefilledrectangle($mask->getHandle(), 0, 0, $width, $height, $greyscale[255]); |
|
56 | 55 | |
57 | - $transparentColor = $image->getTransparentColor(); |
|
58 | - $alphaToGreyRatio = 255 / 127; |
|
56 | + $transparentColor = $image->getTransparentColor(); |
|
57 | + $alphaToGreyRatio = 255 / 127; |
|
59 | 58 | |
60 | - for ($x = 0; $x < $width; $x++) { |
|
61 | - for ($y = 0; $y < $height; $y++) { |
|
62 | - $color = $image->getColorAt($x, $y); |
|
59 | + for ($x = 0; $x < $width; $x++) { |
|
60 | + for ($y = 0; $y < $height; $y++) { |
|
61 | + $color = $image->getColorAt($x, $y); |
|
63 | 62 | |
64 | - if ($color == $transparentColor) { |
|
65 | - $rgba['alpha'] = 127; |
|
66 | - } else { |
|
67 | - $rgba = $image->getColorRGB($color); |
|
68 | - } |
|
63 | + if ($color == $transparentColor) { |
|
64 | + $rgba['alpha'] = 127; |
|
65 | + } else { |
|
66 | + $rgba = $image->getColorRGB($color); |
|
67 | + } |
|
69 | 68 | |
70 | - imagesetpixel($mask->getHandle(), $x, $y, $greyscale[255 - round($rgba['alpha'] * $alphaToGreyRatio)]); |
|
71 | - } |
|
72 | - } |
|
69 | + imagesetpixel($mask->getHandle(), $x, $y, $greyscale[255 - round($rgba['alpha'] * $alphaToGreyRatio)]); |
|
70 | + } |
|
71 | + } |
|
73 | 72 | |
74 | - return $mask; |
|
75 | - } |
|
73 | + return $mask; |
|
74 | + } |
|
76 | 75 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,23 +31,23 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class ApplyConvolution |
34 | 33 | { |
35 | - /** |
|
36 | - * Executes imageconvolution() filter |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @param array $matrix |
|
40 | - * @param numeric $div |
|
41 | - * @param numeric $offset |
|
42 | - * @return \WideImage\Image |
|
43 | - */ |
|
44 | - public function execute($image, $matrix, $div, $offset) |
|
45 | - { |
|
46 | - $new = $image->asTrueColor(); |
|
34 | + /** |
|
35 | + * Executes imageconvolution() filter |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @param array $matrix |
|
39 | + * @param numeric $div |
|
40 | + * @param numeric $offset |
|
41 | + * @return \WideImage\Image |
|
42 | + */ |
|
43 | + public function execute($image, $matrix, $div, $offset) |
|
44 | + { |
|
45 | + $new = $image->asTrueColor(); |
|
47 | 46 | |
48 | - if (!imageconvolution($new->getHandle(), $matrix, $div, $offset)) { |
|
49 | - throw new GDFunctionResultException("imageconvolution() returned false"); |
|
50 | - } |
|
47 | + if (!imageconvolution($new->getHandle(), $matrix, $div, $offset)) { |
|
48 | + throw new GDFunctionResultException("imageconvolution() returned false"); |
|
49 | + } |
|
51 | 50 | |
52 | - return $new; |
|
53 | - } |
|
51 | + return $new; |
|
52 | + } |
|
54 | 53 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,21 +31,21 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class CorrectGamma |
34 | 33 | { |
35 | - /** |
|
36 | - * Executes imagegammacorrect() |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @param numeric $input_gamma |
|
40 | - * @param numeric $output_gamma |
|
41 | - * @return \WideImage\TrueColorImage |
|
42 | - */ |
|
43 | - public function execute($image, $input_gamma, $output_gamma) { |
|
44 | - $new = $image->copy(); |
|
34 | + /** |
|
35 | + * Executes imagegammacorrect() |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @param numeric $input_gamma |
|
39 | + * @param numeric $output_gamma |
|
40 | + * @return \WideImage\TrueColorImage |
|
41 | + */ |
|
42 | + public function execute($image, $input_gamma, $output_gamma) { |
|
43 | + $new = $image->copy(); |
|
45 | 44 | |
46 | - if (!imagegammacorrect($new->getHandle(), $input_gamma, $output_gamma)) { |
|
47 | - throw new GDFunctionResultException("imagegammacorrect() returned false"); |
|
48 | - } |
|
45 | + if (!imagegammacorrect($new->getHandle(), $input_gamma, $output_gamma)) { |
|
46 | + throw new GDFunctionResultException("imagegammacorrect() returned false"); |
|
47 | + } |
|
49 | 48 | |
50 | - return $new; |
|
51 | - } |
|
49 | + return $new; |
|
50 | + } |
|
52 | 51 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -33,42 +32,42 @@ discard block |
||
33 | 32 | * @package Internal/Operations |
34 | 33 | */ |
35 | 34 | class CopyChannelsTrueColor { |
36 | - /** |
|
37 | - * Returns an image with only specified channels copied |
|
38 | - * |
|
39 | - * @param \WideImage\Image $img |
|
40 | - * @param array $channels |
|
41 | - * @return \WideImage\Image |
|
42 | - */ |
|
43 | - public function execute($img, $channels) |
|
44 | - { |
|
45 | - $blank = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); |
|
35 | + /** |
|
36 | + * Returns an image with only specified channels copied |
|
37 | + * |
|
38 | + * @param \WideImage\Image $img |
|
39 | + * @param array $channels |
|
40 | + * @return \WideImage\Image |
|
41 | + */ |
|
42 | + public function execute($img, $channels) |
|
43 | + { |
|
44 | + $blank = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); |
|
46 | 45 | |
47 | - $width = $img->getWidth(); |
|
48 | - $height = $img->getHeight(); |
|
49 | - $copy = TrueColorImage::create($width, $height); |
|
46 | + $width = $img->getWidth(); |
|
47 | + $height = $img->getHeight(); |
|
48 | + $copy = TrueColorImage::create($width, $height); |
|
50 | 49 | |
51 | - if (count($channels) > 0) { |
|
52 | - for ($x = 0; $x < $width; $x++) { |
|
53 | - for ($y = 0; $y < $height; $y++) { |
|
54 | - $RGBA = $img->getRGBAt($x, $y); |
|
55 | - $newRGBA = $blank; |
|
50 | + if (count($channels) > 0) { |
|
51 | + for ($x = 0; $x < $width; $x++) { |
|
52 | + for ($y = 0; $y < $height; $y++) { |
|
53 | + $RGBA = $img->getRGBAt($x, $y); |
|
54 | + $newRGBA = $blank; |
|
56 | 55 | |
57 | - foreach ($channels as $channel) { |
|
58 | - $newRGBA[$channel] = $RGBA[$channel]; |
|
59 | - } |
|
56 | + foreach ($channels as $channel) { |
|
57 | + $newRGBA[$channel] = $RGBA[$channel]; |
|
58 | + } |
|
60 | 59 | |
61 | - $color = $copy->getExactColorAlpha($newRGBA); |
|
60 | + $color = $copy->getExactColorAlpha($newRGBA); |
|
62 | 61 | |
63 | - if ($color == -1) { |
|
64 | - $color = $copy->allocateColorAlpha($newRGBA); |
|
65 | - } |
|
62 | + if ($color == -1) { |
|
63 | + $color = $copy->allocateColorAlpha($newRGBA); |
|
64 | + } |
|
66 | 65 | |
67 | - $copy->setColorAt($x, $y, $color); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
66 | + $copy->setColorAt($x, $y, $color); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
71 | 70 | |
72 | - return $copy; |
|
73 | - } |
|
71 | + return $copy; |
|
72 | + } |
|
74 | 73 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | ##DOC-SIGNATURE## |
4 | 4 | |
5 | 5 | This file is part of WideImage. |
@@ -17,9 +17,8 @@ discard block |
||
17 | 17 | You should have received a copy of the GNU Lesser General Public License |
18 | 18 | along with WideImage; if not, write to the Free Software |
19 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | - |
|
21 | - * @package Internal/Operations |
|
22 | - **/ |
|
20 | + * @package Internal/Operations |
|
21 | + **/ |
|
23 | 22 | |
24 | 23 | namespace WideImage\Operation; |
25 | 24 | |
@@ -32,29 +31,29 @@ discard block |
||
32 | 31 | */ |
33 | 32 | class Flip |
34 | 33 | { |
35 | - /** |
|
36 | - * Returns a flipped image |
|
37 | - * |
|
38 | - * @param \WideImage\Image $image |
|
39 | - * @return \WideImage\Image |
|
40 | - */ |
|
41 | - public function execute($image) |
|
42 | - { |
|
43 | - $new = $image->copy(); |
|
34 | + /** |
|
35 | + * Returns a flipped image |
|
36 | + * |
|
37 | + * @param \WideImage\Image $image |
|
38 | + * @return \WideImage\Image |
|
39 | + */ |
|
40 | + public function execute($image) |
|
41 | + { |
|
42 | + $new = $image->copy(); |
|
44 | 43 | |
45 | - $width = $image->getWidth(); |
|
46 | - $height = $image->getHeight(); |
|
44 | + $width = $image->getWidth(); |
|
45 | + $height = $image->getHeight(); |
|
47 | 46 | |
48 | - if ($new->isTransparent()) { |
|
49 | - imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); |
|
50 | - } |
|
47 | + if ($new->isTransparent()) { |
|
48 | + imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); |
|
49 | + } |
|
51 | 50 | |
52 | - for ($y = 0; $y < $height; $y++) { |
|
53 | - if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) { |
|
54 | - throw new GDFunctionResultException("imagecopy() returned false"); |
|
55 | - } |
|
56 | - } |
|
51 | + for ($y = 0; $y < $height; $y++) { |
|
52 | + if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) { |
|
53 | + throw new GDFunctionResultException("imagecopy() returned false"); |
|
54 | + } |
|
55 | + } |
|
57 | 56 | |
58 | - return $new; |
|
59 | - } |
|
57 | + return $new; |
|
58 | + } |
|
60 | 59 | } |