Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Jamroot --
- lib mapnik : : <name>mapnik <search>/opt/mapnik/lib ;
- exe for_each_pixel :
- main.cpp
- .//mapnik
- :
- <include>/usr/local/include/boost-1_35/
- <include>/usr/local/include
- <include>/opt/mapnik/include
- ;
- -- c++ --
- #include <boost/gil/gil_all.hpp>
- #include <iostream>
- #include <mapnik/image_data.hpp>
- #include <mapnik/image_util.hpp>
- struct coloriser
- {
- explicit coloriser(mapnik::Color & c)
- : c_(c) {}
- coloriser& coloriser::operator=(const coloriser& rhs)
- {
- if ( this == &rhs) return *this;
- c_ = rhs.c_;
- return *this;
- }
- template <typename PixelType>
- void operator() (PixelType & p)
- {
- // use c to modify p
- p[0] = c_.red();
- p[1] = c_.green();
- p[2] = c_.blue();
- }
- mapnik::Color & c_;
- };
- int main(int argc, char** argv)
- {
- if ( argc != 2)
- {
- std::cout << "Usage: ./for_each_pixel <pngfile>\n";
- return EXIT_FAILURE;
- }
- std::cout << "for_each_pixel\n";
- mapnik::ImageData32 data(400,400);
- data.set(0xff000044);
- boost::gil::rgba8_view_t view = interleaved_view(data.width(),data.height(),
- (boost::gil::rgba8_pixel_t*)data.getData(),
- data.width() * 4);
- mapnik::Color c(0,255,0);
- coloriser op(c);
- for_each_pixel(view,op);
- mapnik::save_to_file<mapnik::ImageData32>(data,"test.png","png");
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment