resize.cpp 894 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // Copyright 2005-2007 Adobe Systems Incorporated
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #include <boost/gil.hpp>
  9. #include <boost/gil/extension/io/jpeg.hpp>
  10. #include <boost/gil/extension/numeric/sampler.hpp>
  11. #include <boost/gil/extension/numeric/resample.hpp>
  12. // Example for resize_view() in the numeric extension
  13. int main()
  14. {
  15. namespace bg = boost::gil;
  16. bg::rgb8_image_t img;
  17. bg::read_image("test.jpg", img, bg::jpeg_tag{});
  18. // test resize_view
  19. // Scale the image to 100x100 pixels using bilinear resampling
  20. bg::rgb8_image_t square100x100(100, 100);
  21. bg::resize_view(bg::const_view(img), bg::view(square100x100), bg::bilinear_sampler{});
  22. bg::write_view("out-resize.jpg", bg::const_view(square100x100), bg::jpeg_tag{});
  23. return 0;
  24. }