Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. -- Jamroot --
  2.  
  3. lib mapnik : : <name>mapnik <search>/opt/mapnik/lib ;
  4.  
  5. exe for_each_pixel :
  6. main.cpp
  7. .//mapnik
  8. :
  9. <include>/usr/local/include/boost-1_35/
  10. <include>/usr/local/include
  11. <include>/opt/mapnik/include
  12. ;
  13.  
  14. -- c++ --
  15.  
  16. #include <boost/gil/gil_all.hpp>
  17. #include <iostream>
  18. #include <mapnik/image_data.hpp>
  19. #include <mapnik/image_util.hpp>
  20.  
  21. struct coloriser
  22. {
  23. explicit coloriser(mapnik::Color & c)
  24. : c_(c) {}
  25.  
  26. coloriser& coloriser::operator=(const coloriser& rhs)
  27. {
  28. if ( this == &rhs) return *this;
  29. c_ = rhs.c_;
  30. return *this;
  31. }
  32.  
  33. template <typename PixelType>
  34. void operator() (PixelType & p)
  35. {
  36. // use c to modify p
  37. p[0] = c_.red();
  38. p[1] = c_.green();
  39. p[2] = c_.blue();
  40. }
  41. mapnik::Color & c_;
  42. };
  43.  
  44.  
  45. int main(int argc, char** argv)
  46. {
  47. if ( argc != 2)
  48. {
  49. std::cout << "Usage: ./for_each_pixel <pngfile>\n";
  50. return EXIT_FAILURE;
  51. }
  52. std::cout << "for_each_pixel\n";
  53.  
  54. mapnik::ImageData32 data(400,400);
  55. data.set(0xff000044);
  56.  
  57. boost::gil::rgba8_view_t view = interleaved_view(data.width(),data.height(),
  58. (boost::gil::rgba8_pixel_t*)data.getData(),
  59. data.width() * 4);
  60.  
  61. mapnik::Color c(0,255,0);
  62. coloriser op(c);
  63. for_each_pixel(view,op);
  64. mapnik::save_to_file<mapnik::ImageData32>(data,"test.png","png");
  65. return EXIT_SUCCESS;
  66. }
Add Comment
Please, Sign In to add comment