Пример #1
0
typename
View::pitch_type
subview_pitch(
	View const &_view,
	typename View::bound_type const &_bound
)
{
	typedef typename View::pitch_type pitch_type;

	pitch_type ret{
		mizuiro::no_init{}
	};

	for(
		typename pitch_type::size_type index = 0;
		index < pitch_type::static_size;
		++index
	)
	{
		typename View::dim const edge_pos_end(
			mizuiro::image::detail::edge_pos_end(
				_bound,
				index
			)
		);

		ret[
			index
		] =
			_view.size()[
				index
			] > 1
			?
				mizuiro::image::detail::pitch_difference(
					mizuiro::image::move_iterator(
						_view,
						edge_pos_end
					),
					mizuiro::image::move_iterator(
						_view,
						mizuiro::image::detail::edge_pos_begin(
							_bound,
							index
						)
					)
				)
			:
				0
			;

		// if the end is one past the parent view's dim,
		// the pitch will be skipped by the iterator, so readd it
		if(
			edge_pos_end[
				index
			]
			==
			_view.size()[
				index
			]
		)
			ret[
				index
			]
				+=
				_view.pitch()[
					index
				];
	}

	return ret;
}