diff --git a/CHANGELOG.md b/CHANGELOG.md index fb4054414..241c53458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index 67e03da62..7e04df87a 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -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 && diff --git a/test/unit/imaging/image_filter.cpp b/test/unit/imaging/image_filter.cpp index f07836d6f..78fa42503 100644 --- a/test/unit/imaging/image_filter.cpp +++ b/test/unit/imaging/image_filter.cpp @@ -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);