-/*
- Copyright 2005-2007 Adobe Systems Incorporated
-
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-
- See http://opensource.adobe.com/gil for most recent version including documentation.
-*/
-
-/*************************************************************************************************/
-
-/// \file
-/// \brief Test file for convolve_rows() and convolve_cols() in the numeric extension
-/// \author Lubomir Bourdev and Hailin Jin
-/// \date February 27, 2007
-
+//
+// Copyright 2005-2007 Adobe Systems Incorporated
+//
+// Distributed under the Boost Software License, Version 1.0
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+//
#include <boost/gil/image.hpp>
#include <boost/gil/typedefs.hpp>
-#include <boost/gil/extension/io/jpeg_io.hpp>
+#include <boost/gil/extension/io/jpeg.hpp>
+
+// Example for convolve_rows() and convolve_cols() in the numeric extension
using namespace boost::gil;
// Models a Unary Function
template <typename P> // Models PixelValueConcept
-struct mandelbrot_fn {
- typedef point2<ptrdiff_t> point_t;
-
- typedef mandelbrot_fn const_t;
- typedef P value_type;
- typedef value_type reference;
- typedef value_type const_reference;
- typedef point_t argument_type;
- typedef reference result_type;
- BOOST_STATIC_CONSTANT(bool, is_mutable=false);
+struct mandelbrot_fn
+{
+ using point_t = boost::gil::point_t;
+ using const_t = mandelbrot_fn;
+ using value_type = P;
+ using reference = value_type;
+ using const_reference = value_type;
+ using argument_type = point_t;
+ using result_type = reference;
+ static constexpr bool is_mutable =false;
value_type _in_color,_out_color;
point_t _img_size;
result_type operator()(const point_t& p) const {
// normalize the coords to (-2..1, -1.5..1.5)
// (actually make y -1.0..2 so it is asymmetric, so we can verify some view factory methods)
- double t=get_num_iter(point2<double>(p.x/(double)_img_size.x*3-2, p.y/(double)_img_size.y*3-1.0f));//1.5f));
+ double t=get_num_iter(point<double>(p.x/(double)_img_size.x*3-2, p.y/(double)_img_size.y*3-1.0f));//1.5f));
t=pow(t,0.2);
value_type ret;
}
private:
- double get_num_iter(const point2<double>& p) const {
- point2<double> Z(0,0);
+ double get_num_iter(const point<double>& p) const {
+ point<double> Z(0,0);
for (int i=0; i<MAX_ITER; ++i) {
- Z = point2<double>(Z.x*Z.x - Z.y*Z.y + p.x, 2*Z.x*Z.y + p.y);
+ Z = point<double>(Z.x*Z.x - Z.y*Z.y + p.x, 2*Z.x*Z.y + p.y);
if (Z.x*Z.x + Z.y*Z.y > 4)
return i/(double)MAX_ITER;
}
}
};
-int main() {
- typedef mandelbrot_fn<rgb8_pixel_t> deref_t;
- typedef deref_t::point_t point_t;
- typedef virtual_2d_locator<deref_t,false> locator_t;
- typedef image_view<locator_t> my_virt_view_t;
+int main()
+{
+ using deref_t = mandelbrot_fn<rgb8_pixel_t>;
+ using point_t = deref_t::point_t;
+ using locator_t = virtual_2d_locator<deref_t,false>;
+ using my_virt_view_t = image_view<locator_t>;
- boost::function_requires<PixelLocatorConcept<locator_t> >();
- gil_function_requires<StepIteratorConcept<locator_t::x_iterator> >();
+ boost::function_requires<PixelLocatorConcept<locator_t>>();
+ gil_function_requires<StepIteratorConcept<locator_t::x_iterator>>();
point_t dims(200,200);
my_virt_view_t mandel(dims, locator_t(point_t(0,0), point_t(1,1), deref_t(dims, rgb8_pixel_t(255,0,255), rgb8_pixel_t(0,255,0))));
- jpeg_write_view("out-mandelbrot.jpg",mandel);
+ write_view("out-mandelbrot.jpg",mandel, jpeg_tag{});
return 0;
}
-