Skip to content

Commit b35d978

Browse files
committed
add tests for write_to_array
1 parent bb4b4c9 commit b35d978

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

package.xml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
1515
<email>jcupitt@php.net</email>
1616
<active>yes</active>
1717
</lead>
18-
<date>2019-9-19</date>
18+
<date>2019-09-26</date>
1919
<version>
20-
<release>1.0.11</release>
20+
<release>1.0.10</release>
2121
<api>1.0.0</api>
2222
</version>
2323
<stability>
@@ -27,6 +27,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license filesource="LICENSE.txt">MIT</license>
2828
<notes>
2929
* Add vips_image_write_to_array() [jcupitt]
30+
* Update links for new home [jcupitt]
31+
* Fix win32 build [TBK]
3032
</notes>
3133
<contents>
3234
<dir name="/">
@@ -98,20 +100,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
98100
</extsrcrelease>
99101
<changelog>
100102

101-
<release>
102-
<stability><release>stable</release><api>stable</api></stability>
103-
<version><release>1.0.11</release><api>1.0.0</api></version>
104-
<date>2019-9-18</date>
105-
<notes>
106-
* Add vips_image_write_to_array() [jcupitt]
107-
</notes>
108-
</release>
109-
110103
<release>
111104
<stability><release>stable</release><api>stable</api></stability>
112105
<version><release>1.0.10</release><api>1.0.0</api></version>
113106
<date>2018-12-12</date>
114107
<notes>
108+
* Add vips_image_write_to_array() [jcupitt]
115109
* Update links for new home [jcupitt]
116110
* Fix win32 build [TBK]
117111
</notes>

tests/041.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
write_to_array works
3+
--SKIPIF--
4+
<?php if (!extension_loaded("vips")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$filename = dirname(__FILE__) . "/images/img_0076.jpg";
8+
$x = vips_image_new_from_file($filename)["out"];
9+
$bands = vips_image_get($x, "bands")["out"];
10+
$line = vips_call("crop", $x, 50, 50, 10, 1)["out"];
11+
$array = vips_image_write_to_array($line);
12+
# print_r($array);
13+
14+
if (count($array) == 10 * $bands) {
15+
echo "pass array_size\n";
16+
}
17+
18+
$pixel = vips_call("crop", $x, 50, 50, 1, 1)["out"];
19+
$r = vips_call("extract_band", $pixel, 0)["out"];
20+
$r = vips_call("avg", $r)["out"];
21+
$g = vips_call("extract_band", $pixel, 1)["out"];
22+
$g = vips_call("avg", $g)["out"];
23+
$b = vips_call("extract_band", $pixel, 2)["out"];
24+
$b = vips_call("avg", $b)["out"];
25+
# echo "r = " . $r . ", g = " . $g . ", b = " . $b . "\n";
26+
27+
if ($array[0] == $r && $array[1] == $g && $array[2] == $b) {
28+
echo "pass pixel_value\n";
29+
}
30+
31+
?>
32+
--EXPECT--
33+
pass array_size
34+
pass pixel_value

vips-1.0.10.tgz

367 Bytes
Binary file not shown.

vips.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ PHP_FUNCTION(vips_image_write_to_memory)
14621462
/* }}} */
14631463

14641464
#define ADD_ELEMENTS(TYPE, APPEND, N) { \
1465-
TYPE *p = arr; \
1465+
TYPE *p = (TYPE *) arr; \
14661466
size_t i; \
14671467
\
14681468
for (i = 0; i < (N); i++) \

0 commit comments

Comments
 (0)