scale-hsla image filter: unlimit parameters

This commit is contained in:
Jiri Drbalek 2015-09-03 11:33:53 +00:00
parent ee65873159
commit 72222efad7
3 changed files with 36 additions and 17 deletions

View file

@ -12,6 +12,10 @@ Released: YYYY XX, 2015
(Packaged from xxxx)
#### Summary
- `scale-hsla` image filter: parameters are no longer limited by interval [0, 1] (https://github.com/mapnik/mapnik/pull/3054)
## 3.0.4
Released: August 26, 2015

View file

@ -116,19 +116,8 @@ struct scale_hsla : image_filter_base
l0(_l0),
l1(_l1),
a0(_a0),
a1(_a1) {
if (h0 < 0 || h0 > 1 ||
h1 < 0 || h1 > 1 ||
s0 < 0 || s0 > 1 ||
s1 < 0 || s1 > 1 ||
l0 < 0 || l0 > 1 ||
l1 < 0 || l1 > 1 ||
a0 < 0 || a0 > 1 ||
a1 < 0 || a1 > 1)
{
throw std::runtime_error("scale-hsla values must be between 0 and 1");
}
}
a1(_a1) { }
inline bool is_identity() const {
return (h0 == 0 &&
h1 == 1 &&

View file

@ -119,15 +119,12 @@ SECTION("test agg stack blur") {
} // END SECTION
SECTION("test scale-hsla") {
SECTION("test scale-hsla 1") {
mapnik::image_rgba8 im(3,3);
mapnik::fill(im,mapnik::color("blue"));
mapnik::set_pixel(im, 1, 1, mapnik::color("red"));
// Should throw because a value is greater then 1.0
REQUIRE_THROWS(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,0.0,1.0,0.0,0.5,0.0,0.5)"););
mapnik::filter::filter_image(im, "scale-hsla(0.0,0.5,0.0,1.0,0.0,0.5,0.0,0.5)");
CHECK(im(0,0) == 0x80004000);
@ -142,6 +139,35 @@ SECTION("test scale-hsla") {
} // END SECTION
SECTION("test scale-hsla 2") {
mapnik::image_rgba8 im(3,3);
mapnik::set_pixel(im, 0, 0, mapnik::color(255, 0, 0));
mapnik::set_pixel(im, 0, 1, mapnik::color(147, 112, 219));
mapnik::set_pixel(im, 0, 2, mapnik::color(128, 128, 128));
mapnik::set_pixel(im, 1, 0, mapnik::color(72, 209, 204));
mapnik::set_pixel(im, 1, 1, mapnik::color(218, 112, 214));
mapnik::set_pixel(im, 1, 2, mapnik::color(30, 144, 255));
mapnik::set_pixel(im, 2, 0, mapnik::color(238, 130, 238));
mapnik::set_pixel(im, 2, 1, mapnik::color(154, 205, 50));
mapnik::set_pixel(im, 2, 2, mapnik::color(160, 82, 45));
// Should not throw on values out of [0, 1]
// https://github.com/mapnik/mapnik/issues/3052
REQUIRE_NOTHROW(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,-1.0,1.0,-1.0,2.0,1.0,1.0)"););
CHECK(im(0,0) == 0xff0000ff);
CHECK(im(0,1) == 0xffefeff4);
CHECK(im(0,2) == 0xff818181);
CHECK(im(1,0) == 0xffb895a5);
CHECK(im(1,1) == 0xffededf3);
CHECK(im(1,2) == 0xffd75aff);
CHECK(im(2,0) == 0xffffffff);
CHECK(im(2,1) == 0xff649b64);
CHECK(im(2,2) == 0xff2e343b);
} // END SECTION
SECTION("test emboss") {
mapnik::image_rgba8 im(3,3);