diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 4f930f879..a3432f40f 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -122,11 +122,21 @@ bool is_solid(mapnik::image_any const& im) return mapnik::is_solid(im); } -void background(mapnik::image_any & im, mapnik::color const& c) +void fill_color(mapnik::image_any & im, mapnik::color const& c) { mapnik::fill(im, c); } +void fill_int(mapnik::image_any & im, int val) +{ + mapnik::fill(im, val); +} + +void fill_double(mapnik::image_any & im, double val) +{ + mapnik::fill(im, val); +} + std::shared_ptr cast(mapnik::image_any const& im, mapnik::image_dtype type, double offset, double scaling) { return std::make_shared(std::move(mapnik::image_cast(im, type, offset, scaling))); @@ -392,7 +402,9 @@ void export_image() .def("view",&get_view) .def("painted",&image_any::painted) .def("is_solid",&is_solid) - .def("background",&background, "Set the background color of the image.") + .def("fill",&fill_color) + .def("fill",&fill_int) + .def("fill",&fill_double) .def("set_grayscale_to_alpha",&set_grayscale_to_alpha, "Set the grayscale values to the alpha channel of the Image") .def("set_grayscale_to_alpha",&set_grayscale_to_alpha_c, "Set the grayscale values to the alpha channel of the Image") .def("set_color_to_alpha",&set_color_to_alpha, "Set a given color to the alpha channel of the Image") diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 09e522798..3747999e7 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -134,8 +134,20 @@ MAPNIK_DECL void set_grayscale_to_alpha (T & image, color const& c); template MAPNIK_DECL void set_color_to_alpha (T & image, color const& c); -template -MAPNIK_DECL void fill (T1 & data, T2 const& c); +template +MAPNIK_DECL void fill (image_any & data, T const&); + +template +MAPNIK_DECL void fill (image_rgba8 & data, T const&); + +template +MAPNIK_DECL void fill (image_gray8 & data, T const&); + +template +MAPNIK_DECL void fill (image_gray16 & data, T const&); + +template +MAPNIK_DECL void fill (image_gray32f & data, T const&); template MAPNIK_DECL void set_rectangle (T & dst, T const& src, int x = 0, int y = 0); diff --git a/src/image_util.cpp b/src/image_util.cpp index ede5f7bf7..a4fce8bde 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // agg #include "agg_rendering_buffer.h" @@ -661,7 +662,7 @@ struct visitor_set_grayscale_to_alpha template void operator() (T & data) { - std::clog << "Warning: set_grayscale_to_alpha with " + std::string(typeid(data).name()) + " is not supported, image was not modified" << std::endl; + MAPNIK_LOG_WARN(image_util) << "Warning: set_grayscale_to_alpha with " + std::string(typeid(data).name()) + " is not supported, image was not modified"; } }; @@ -695,7 +696,7 @@ struct visitor_set_grayscale_to_alpha_c template void operator() (T & data) { - std::clog << "Warning: set_grayscale_to_alpha with " + std::string(typeid(data).name()) + " is not supported, image was not modified" << std::endl; + MAPNIK_LOG_WARN(image_util) << "Warning: set_grayscale_to_alpha with " + std::string(typeid(data).name()) + " is not supported, image was not modified"; } private: @@ -855,7 +856,19 @@ struct visitor_fill void operator() (T2 & data) { using pixel_type = typename T2::pixel_type; - pixel_type val = static_cast(val_); + pixel_type val; + try + { + val = numeric_cast(val_); + } + catch(negative_overflow&) + { + val = std::numeric_limits::min(); + } + catch(positive_overflow&) + { + val = std::numeric_limits::max(); + } data.set(val); } @@ -891,11 +904,10 @@ struct visitor_fill } // end detail ns -// For all the generic data types. -template -MAPNIK_DECL void fill (T1 & data, T2 const& val) +template +MAPNIK_DECL void fill (image_any & data, T const& val) { - util::apply_visitor(detail::visitor_fill(val), data); + util::apply_visitor(detail::visitor_fill(val), data); } template MAPNIK_DECL void fill(image_any &, color const&); @@ -908,31 +920,74 @@ template MAPNIK_DECL void fill(image_any &, int8_t const&); template MAPNIK_DECL void fill(image_any &, float const&); template MAPNIK_DECL void fill(image_any &, double const&); - -// Temporary remove these later! -template <> -MAPNIK_DECL void fill (image_rgba8 & data , color const& val) +template +MAPNIK_DECL void fill (image_rgba8 & data, T const& val) { - detail::visitor_fill visitor(val); - visitor(data); + detail::visitor_fill visitor(val); + return visitor(data); } -// Temporary remove these later! -template <> -MAPNIK_DECL void fill (image_rgba8 & data , uint32_t const& val) +template MAPNIK_DECL void fill(image_rgba8 &, color const&); +template MAPNIK_DECL void fill(image_rgba8 &, uint32_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, int32_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, uint16_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, int16_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, uint8_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, int8_t const&); +template MAPNIK_DECL void fill(image_rgba8 &, float const&); +template MAPNIK_DECL void fill(image_rgba8 &, double const&); + +template +MAPNIK_DECL void fill (image_gray8 & data, T const& val) { - detail::visitor_fill visitor(val); - visitor(data); + detail::visitor_fill visitor(val); + return visitor(data); } -// Temporary remove these later! -template <> -MAPNIK_DECL void fill (image_rgba8 & data , int32_t const& val) +template MAPNIK_DECL void fill(image_gray8 &, color const&); +template MAPNIK_DECL void fill(image_gray8 &, uint32_t const&); +template MAPNIK_DECL void fill(image_gray8 &, int32_t const&); +template MAPNIK_DECL void fill(image_gray8 &, uint16_t const&); +template MAPNIK_DECL void fill(image_gray8 &, int16_t const&); +template MAPNIK_DECL void fill(image_gray8 &, uint8_t const&); +template MAPNIK_DECL void fill(image_gray8 &, int8_t const&); +template MAPNIK_DECL void fill(image_gray8 &, float const&); +template MAPNIK_DECL void fill(image_gray8 &, double const&); + +template +MAPNIK_DECL void fill (image_gray16 & data, T const& val) { - detail::visitor_fill visitor(val); - visitor(data); + detail::visitor_fill visitor(val); + return visitor(data); } +template MAPNIK_DECL void fill(image_gray16 &, color const&); +template MAPNIK_DECL void fill(image_gray16 &, uint32_t const&); +template MAPNIK_DECL void fill(image_gray16 &, int32_t const&); +template MAPNIK_DECL void fill(image_gray16 &, uint16_t const&); +template MAPNIK_DECL void fill(image_gray16 &, int16_t const&); +template MAPNIK_DECL void fill(image_gray16 &, uint8_t const&); +template MAPNIK_DECL void fill(image_gray16 &, int8_t const&); +template MAPNIK_DECL void fill(image_gray16 &, float const&); +template MAPNIK_DECL void fill(image_gray16 &, double const&); + +template +MAPNIK_DECL void fill (image_gray32f & data, T const& val) +{ + detail::visitor_fill visitor(val); + return visitor(data); +} + +template MAPNIK_DECL void fill(image_gray32f &, color const&); +template MAPNIK_DECL void fill(image_gray32f &, uint32_t const&); +template MAPNIK_DECL void fill(image_gray32f &, int32_t const&); +template MAPNIK_DECL void fill(image_gray32f &, uint16_t const&); +template MAPNIK_DECL void fill(image_gray32f &, int16_t const&); +template MAPNIK_DECL void fill(image_gray32f &, uint8_t const&); +template MAPNIK_DECL void fill(image_gray32f &, int8_t const&); +template MAPNIK_DECL void fill(image_gray32f &, float const&); +template MAPNIK_DECL void fill(image_gray32f &, double const&); + namespace detail { struct visitor_set_rectangle @@ -1463,7 +1518,6 @@ MAPNIK_DECL unsigned compare(T const& im1, T const& im2, double threshold, bool) using pixel_type = typename T::pixel_type; if (im1.width() != im2.width() || im1.height() != im2.height()) { - std::clog << "Warning the two images compared are not the same sizes." << std::endl; return im1.width() * im1.height(); } unsigned difference = 0; @@ -1499,7 +1553,6 @@ MAPNIK_DECL unsigned compare(image_rgba8 const& im1, image_rgba8 co using pixel_type = image_rgba8::pixel_type; if (im1.width() != im2.width() || im1.height() != im2.height()) { - std::clog << "Warning: The two images compared are not the same sizes." << std::endl; return im1.width() * im1.height(); } unsigned difference = 0; @@ -1549,7 +1602,6 @@ struct visitor_compare { if (!im2_.is()) { - std::clog << "Warning: Comparing different image types." << std::endl; return im1.width() * im1.height(); } return mapnik::compare(im1, util::get(im2_), threshold_, alpha_); diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index 2e7c1a9a2..adfa8679f 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -609,7 +609,7 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0, ImageData & image) { if (!detail::tiff_reader_traits::read_tile(tif, x, y, buf.get(), tile_width_, tile_height_)) { - std::clog << "read_tile(...) failed at " << x << "/" << y << " for " << width_ << "/" << height_ << "\n"; + MAPNIK_LOG_DEBUG(tiff_reader) << "read_tile(...) failed at " << x << "/" << y << " for " << width_ << "/" << height_ << "\n"; break; } int tx0 = std::max(x0, static_cast(x)); @@ -649,7 +649,7 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_rgba8& image) if (!TIFFReadRGBAStrip(tif,y,strip.getData())) { - std::clog << "TIFFReadRGBAStrip failed at " << y << " for " << width_ << "/" << height_ << "\n"; + MAPNIK_LOG_DEBUG(tiff_reader) << "TIFFReadRGBAStrip failed at " << y << " for " << width_ << "/" << height_ << "\n"; break; } // This is in reverse becauase the TIFFReadRGBAStrip reads inverted diff --git a/tests/python_tests/buffer_clear_test.py b/tests/python_tests/buffer_clear_test.py index c48130731..6cffc1c4b 100644 --- a/tests/python_tests/buffer_clear_test.py +++ b/tests/python_tests/buffer_clear_test.py @@ -15,7 +15,7 @@ def test_clearing_image_data(): bytes = im.tostring() eq_(im.tostring(),bytes) # set background, then clear - im.background(mapnik.Color('green')) + im.fill(mapnik.Color('green')) eq_(im.tostring()!=bytes,True) # clear image, should now equal original im.clear() diff --git a/tests/python_tests/cast_test.py b/tests/python_tests/cast_test.py index 955a3fed2..b469859ab 100644 --- a/tests/python_tests/cast_test.py +++ b/tests/python_tests/cast_test.py @@ -1,11 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os, mapnik -from timeit import Timer, time from nose.tools import * -from utilities import execution_path, run_all, get_unique_colors +from utilities import execution_path, run_all def setup(): # All of the paths used are relative, if we run the tests diff --git a/tests/python_tests/compare_test.py b/tests/python_tests/compare_test.py new file mode 100644 index 000000000..1e9688869 --- /dev/null +++ b/tests/python_tests/compare_test.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os, mapnik +from nose.tools import * +from utilities import execution_path, run_all + +def setup(): + # All of the paths used are relative, if we run the tests + # from another directory we need to chdir() + os.chdir(execution_path('.')) + +def test_compare_rgba8(): + im = mapnik.Image(2,2,mapnik.ImageType.rgba8) + im.fill(mapnik.Color(0,0,0,0)) + eq_(im.compare(im), 0) + im2 = mapnik.Image(2,2,mapnik.ImageType.rgba8) + im2.fill(mapnik.Color(0,0,0,0)) + eq_(im.compare(im2), 0) + eq_(im2.compare(im), 0) + im2.fill(mapnik.Color(0,0,0,12)) + eq_(im.compare(im2), 4) + eq_(im.compare(im2, 0, False), 0) + im3 = mapnik.Image(2,2,mapnik.ImageType.rgba8) + im3.set_pixel(0,0, mapnik.Color(0,0,0,0)) + im3.set_pixel(0,1, mapnik.Color(1,1,1,1)) + im3.set_pixel(1,0, mapnik.Color(2,2,2,2)) + im3.set_pixel(1,1, mapnik.Color(3,3,3,3)) + eq_(im.compare(im3),3) + eq_(im.compare(im3,1),2) + eq_(im.compare(im3,2),1) + eq_(im.compare(im3,3),0) + +def test_compare_dimensions(): + im = mapnik.Image(2,2) + im2 = mapnik.Image(3,3) + eq_(im.compare(im2), 4) + eq_(im2.compare(im), 9) + +def test_compare_gray8(): + im = mapnik.Image(2,2,mapnik.ImageType.gray8) + im.fill(0) + eq_(im.compare(im), 0) + im2 = mapnik.Image(2,2,mapnik.ImageType.gray8) + im2.fill(0) + eq_(im.compare(im2), 0) + eq_(im2.compare(im), 0) + eq_(im.compare(im2, 0, False), 0) + im3 = mapnik.Image(2,2,mapnik.ImageType.gray8) + im3.set_pixel(0,0,0) + im3.set_pixel(0,1,1) + im3.set_pixel(1,0,2) + im3.set_pixel(1,1,3) + eq_(im.compare(im3),3) + eq_(im.compare(im3,1),2) + eq_(im.compare(im3,2),1) + eq_(im.compare(im3,3),0) + +def test_compare_gray16(): + im = mapnik.Image(2,2,mapnik.ImageType.gray16) + im.fill(0) + eq_(im.compare(im), 0) + im2 = mapnik.Image(2,2,mapnik.ImageType.gray16) + im2.fill(0) + eq_(im.compare(im2), 0) + eq_(im2.compare(im), 0) + eq_(im.compare(im2, 0, False), 0) + im3 = mapnik.Image(2,2,mapnik.ImageType.gray16) + im3.set_pixel(0,0,0) + im3.set_pixel(0,1,1) + im3.set_pixel(1,0,2) + im3.set_pixel(1,1,3) + eq_(im.compare(im3),3) + eq_(im.compare(im3,1),2) + eq_(im.compare(im3,2),1) + eq_(im.compare(im3,3),0) + +def test_compare_gray32f(): + im = mapnik.Image(2,2,mapnik.ImageType.gray32f) + im.fill(0.5) + eq_(im.compare(im), 0) + im2 = mapnik.Image(2,2,mapnik.ImageType.gray32f) + im2.fill(0.5) + eq_(im.compare(im2), 0) + eq_(im2.compare(im), 0) + eq_(im.compare(im2, 0, False), 0) + im3 = mapnik.Image(2,2,mapnik.ImageType.gray32f) + im3.set_pixel(0,0,0.5) + im3.set_pixel(0,1,1.5) + im3.set_pixel(1,0,2.5) + im3.set_pixel(1,1,3.5) + eq_(im.compare(im3),3) + eq_(im.compare(im3,1.0),2) + eq_(im.compare(im3,2.0),1) + eq_(im.compare(im3,3.0),0) + +if __name__ == "__main__": + setup() + exit(run_all(eval(x) for x in dir() if x.startswith("test_"))) diff --git a/tests/python_tests/compositing_test.py b/tests/python_tests/compositing_test.py index fc05525e6..b535311de 100644 --- a/tests/python_tests/compositing_test.py +++ b/tests/python_tests/compositing_test.py @@ -241,10 +241,10 @@ def test_background_image_with_alpha_and_background_color_against_composited_con mapnik.render(m,im) # create and composite the expected result im1 = mapnik.Image(10,10) - im1.background(mapnik.Color('rgba(255,255,255,.5)')) + im1.fill(mapnik.Color('rgba(255,255,255,.5)')) im1.premultiply() im2 = mapnik.Image(10,10) - im2.background(mapnik.Color('rgba(255,255,0,.5)')) + im2.fill(mapnik.Color('rgba(255,255,0,.5)')) im2.premultiply() im1.composite(im2) im1.demultiply() diff --git a/tests/python_tests/grayscale_test.py b/tests/python_tests/grayscale_test.py index cce8c6e31..35f541a87 100644 --- a/tests/python_tests/grayscale_test.py +++ b/tests/python_tests/grayscale_test.py @@ -4,7 +4,7 @@ from utilities import execution_path, run_all def test_grayscale_conversion(): im = mapnik.Image(2,2) - im.background(mapnik.Color('white')) + im.fill(mapnik.Color('white')) im.set_grayscale_to_alpha() pixel = im.get_pixel(0,0) eq_((pixel >> 24) & 0xff,255); diff --git a/tests/python_tests/image_encoding_speed_test.py b/tests/python_tests/image_encoding_speed_test.py index 6fa9f8f06..2b790e913 100644 --- a/tests/python_tests/image_encoding_speed_test.py +++ b/tests/python_tests/image_encoding_speed_test.py @@ -88,7 +88,7 @@ def do_encoding(): def solid(): return eval('image.tostring("%s")' % c) solid_im = mapnik.Image(512,512) - solid_im.background(mapnik.Color("#f2efe9")) + solid_im.fill(mapnik.Color("#f2efe9")) for c in combinations: t = Timer(solid) run(solid,solid_im,c,t) diff --git a/tests/python_tests/image_test.py b/tests/python_tests/image_test.py index a30a86719..dee26e2c5 100644 --- a/tests/python_tests/image_test.py +++ b/tests/python_tests/image_test.py @@ -30,7 +30,7 @@ def test_image_premultiply(): def test_image_premultiply_values(): im = mapnik.Image(256,256) - im.background(mapnik.Color(16, 33, 255, 128)) + im.fill(mapnik.Color(16, 33, 255, 128)) im.premultiply() c = im.get_pixel_color(0,0) eq_(c.r, 8) @@ -48,7 +48,7 @@ def test_image_premultiply_values(): def test_background(): im = mapnik.Image(256,256) eq_(im.premultiplied(), False) - im.background(mapnik.Color(32,64,125,128)) + im.fill(mapnik.Color(32,64,125,128)) eq_(im.premultiplied(), False) c = im.get_pixel_color(0,0) eq_(c.get_premultiplied(), False) @@ -57,7 +57,7 @@ def test_background(): eq_(c.b,125) eq_(c.a,128) # Now again with a premultiplied alpha - im.background(mapnik.Color(32,64,125,128,True)) + im.fill(mapnik.Color(32,64,125,128,True)) eq_(im.premultiplied(), True) c = im.get_pixel_color(0,0) eq_(c.get_premultiplied(), True) @@ -127,6 +127,15 @@ def test_set_and_get_pixel(): eq_(c0_pre.b, c1.b) eq_(c0_pre.a, c1.a) +def test_pixel_floats(): + im = mapnik.Image(4,4,mapnik.ImageType.gray32f) + val_list = [0.9, 0.99, 0.999, 0.9999, 0.99999, 1, 1.0001, 1.001, 1.01, 1.1] + for v in val_list: + im.set_pixel(0,0, v) + assert_almost_equal(im.get_pixel(0,0), v) + im.set_pixel(0,0, -v) + assert_almost_equal(im.get_pixel(0,0), -v) + def test_pixel_overflow(): im = mapnik.Image(4,4,mapnik.ImageType.gray8) im.set_pixel(0,0,256) @@ -171,7 +180,7 @@ def test_get_pixel_color_out_of_range_2(): def test_set_color_to_alpha(): im = mapnik.Image(256,256) - im.background(mapnik.Color('rgba(12,12,12,255)')) + im.fill(mapnik.Color('rgba(12,12,12,255)')) eq_(get_unique_colors(im), ['rgba(12,12,12,255)']) im.set_color_to_alpha(mapnik.Color('rgba(12,12,12,0)')) eq_(get_unique_colors(im), ['rgba(0,0,0,0)']) @@ -184,7 +193,7 @@ def test_negative_image_dimensions(): def test_jpeg_round_trip(): filepath = '/tmp/mapnik-jpeg-io.jpeg' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(1,2,3,.5)')) + im.fill(mapnik.Color('rgba(1,2,3,.5)')) im.save(filepath,'jpeg') im2 = mapnik.Image.open(filepath) im3 = mapnik.Image.fromstring(open(filepath,'r').read()) @@ -200,7 +209,7 @@ def test_jpeg_round_trip(): def test_png_round_trip(): filepath = '/tmp/mapnik-png-io.png' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(1,2,3,.5)')) + im.fill(mapnik.Color('rgba(1,2,3,.5)')) im.save(filepath,'png') im2 = mapnik.Image.open(filepath) im3 = mapnik.Image.fromstring(open(filepath,'r').read()) diff --git a/tests/python_tests/image_tiff_test.py b/tests/python_tests/image_tiff_test.py index a2c524f90..4dbcf3223 100644 --- a/tests/python_tests/image_tiff_test.py +++ b/tests/python_tests/image_tiff_test.py @@ -19,7 +19,7 @@ def setup(): def test_tiff_round_trip_scanline(): filepath = '/tmp/mapnik-tiff-io-scanline.tiff' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(12,255,128,.5)')) + im.fill(mapnik.Color('rgba(12,255,128,.5)')) org_str = hashstr(im.tostring()) im.save(filepath,'tiff:method=scanline') im2 = mapnik.Image.open(filepath) @@ -42,7 +42,7 @@ def test_tiff_round_trip_scanline(): def test_tiff_round_trip_stripped(): filepath = '/tmp/mapnik-tiff-io-stripped.tiff' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(12,255,128,.5)')) + im.fill(mapnik.Color('rgba(12,255,128,.5)')) org_str = hashstr(im.tostring()) im.save(filepath,'tiff:method=stripped') im2 = mapnik.Image.open(filepath) @@ -68,7 +68,7 @@ def test_tiff_round_trip_rows_stripped(): filepath = '/tmp/mapnik-tiff-io-rows_stripped.tiff' filepath2 = '/tmp/mapnik-tiff-io-rows_stripped2.tiff' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(12,255,128,.5)')) + im.fill(mapnik.Color('rgba(12,255,128,.5)')) c = im.get_pixel_color(0,0) eq_(c.r, 12) eq_(c.g, 255) @@ -105,7 +105,7 @@ def test_tiff_round_trip_buffered_tiled(): filepath2 = '/tmp/mapnik-tiff-io-buffered-tiled2.tiff' filepath3 = '/tmp/mapnik-tiff-io-buffered-tiled3.tiff' im = mapnik.Image(255,267) - im.background(mapnik.Color('rgba(33,255,128,.5)')) + im.fill(mapnik.Color('rgba(33,255,128,.5)')) c = im.get_pixel_color(0,0) eq_(c.r, 33) eq_(c.g, 255) @@ -142,7 +142,7 @@ def test_tiff_round_trip_buffered_tiled(): def test_tiff_round_trip_tiled(): filepath = '/tmp/mapnik-tiff-io-tiled.tiff' im = mapnik.Image(256,256) - im.background(mapnik.Color('rgba(1,255,128,.5)')) + im.fill(mapnik.Color('rgba(1,255,128,.5)')) im.save(filepath,'tiff:method=tiled') im2 = mapnik.Image.open(filepath) im3 = mapnik.Image.fromstring(open(filepath,'r').read()) diff --git a/tests/python_tests/png_encoding_test.py b/tests/python_tests/png_encoding_test.py index 89bb02ad8..cbb5b4d4c 100644 --- a/tests/python_tests/png_encoding_test.py +++ b/tests/python_tests/png_encoding_test.py @@ -61,7 +61,7 @@ if mapnik.has_png(): '%s (actual) not == to %s (expected)' % (actual,expected)) # solid image - im.background(mapnik.Color('green')) + im.fill(mapnik.Color('green')) for opt in opts: expected = gen_filepath('blank',opt) actual = os.path.join(tmp_dir,os.path.basename(expected)) @@ -91,7 +91,7 @@ if mapnik.has_png(): def test_transparency_levels(): # create partial transparency image im = mapnik.Image(256,256) - im.background(mapnik.Color('rgba(255,255,255,.5)')) + im.fill(mapnik.Color('rgba(255,255,255,.5)')) c2 = mapnik.Color('rgba(255,255,0,.2)') c3 = mapnik.Color('rgb(0,255,255)') for y in range(0,im.height()/2): diff --git a/tests/python_tests/render_test.py b/tests/python_tests/render_test.py index 5fa4dd463..abdb0a518 100644 --- a/tests/python_tests/render_test.py +++ b/tests/python_tests/render_test.py @@ -25,7 +25,7 @@ def test_simplest_render(): def test_render_image_to_string(): im = mapnik.Image(256, 256) - im.background(mapnik.Color('black')) + im.fill(mapnik.Color('black')) eq_(im.painted(),False) eq_(im.is_solid(),True) s = im.tostring() @@ -33,7 +33,7 @@ def test_render_image_to_string(): def test_non_solid_image(): im = mapnik.Image(256, 256) - im.background(mapnik.Color('black')) + im.fill(mapnik.Color('black')) eq_(im.painted(),False) eq_(im.is_solid(),True) # set one pixel to a different color @@ -43,7 +43,7 @@ def test_non_solid_image(): def test_non_solid_image_view(): im = mapnik.Image(256, 256) - im.background(mapnik.Color('black')) + im.fill(mapnik.Color('black')) view = im.view(0,0,256,256) eq_(view.is_solid(),True) # set one pixel to a different color @@ -61,13 +61,13 @@ def test_setting_alpha(): im1 = mapnik.Image(w,h) # white, half transparent c1 = mapnik.Color('rgba(255,255,255,.5)') - im1.background(c1) + im1.fill(c1) eq_(im1.painted(),False) eq_(im1.is_solid(),True) # pure white im2 = mapnik.Image(w,h) c2 = mapnik.Color('rgba(255,255,255,1)') - im2.background(c2) + im2.fill(c2) im2.set_alpha(c1.a/255.0) eq_(im2.painted(),False) eq_(im2.is_solid(),True) @@ -75,7 +75,7 @@ def test_setting_alpha(): def test_render_image_to_file(): im = mapnik.Image(256, 256) - im.background(mapnik.Color('black')) + im.fill(mapnik.Color('black')) if mapnik.has_jpeg(): im.save('test.jpg') im.save('test.png', 'png') diff --git a/tests/python_tests/webp_encoding_test.py b/tests/python_tests/webp_encoding_test.py index 8f2ebf630..642f37210 100644 --- a/tests/python_tests/webp_encoding_test.py +++ b/tests/python_tests/webp_encoding_test.py @@ -84,7 +84,7 @@ if mapnik.has_webp(): for opt in opts: im = mapnik.Image(256,256) - im.background(mapnik.Color('green')) + im.fill(mapnik.Color('green')) expected = gen_filepath('solid',opt) actual = os.path.join(tmp_dir,os.path.basename(expected)) if generate or not os.path.exists(expected): @@ -125,7 +125,7 @@ if mapnik.has_webp(): try: # create partial transparency image im = mapnik.Image(256,256) - im.background(mapnik.Color('rgba(255,255,255,.5)')) + im.fill(mapnik.Color('rgba(255,255,255,.5)')) c2 = mapnik.Color('rgba(255,255,0,.2)') c3 = mapnik.Color('rgb(0,255,255)') for y in range(0,im.height()/2):