TuttleOFX
1
|
00001 #ifndef _TERRY_DRAW_FILL_HPP_ 00002 #define _TERRY_DRAW_FILL_HPP_ 00003 00004 #include <terry/math/Rect.hpp> 00005 00006 #include <boost/gil/gil_config.hpp> 00007 #include <boost/gil/algorithm.hpp> 00008 00009 namespace terry { 00010 namespace draw { 00011 00012 template<class View> 00013 GIL_FORCEINLINE 00014 void fill_pixels( View& dstView, const typename View::value_type& pixelValue ) 00015 { 00016 typedef typename View::value_type Pixel; 00017 boost::gil::fill_pixels( dstView, pixelValue ); 00018 } 00019 00020 00021 /** 00022 * @brief fill all pixels inside the @p window, with the color @p pixelValue. 00023 * 00024 * @param[out] dstView Image view to fill. 00025 * @param[in] window Rectangle region of the image to fill. 00026 * @param[in] pixelValue Pixel value used to fill. 00027 */ 00028 template<class View> 00029 GIL_FORCEINLINE 00030 void fill_pixels( View& dstView, const Rect<std::ssize_t>& window, 00031 const typename View::value_type& pixelValue ) 00032 { 00033 typedef typename View::value_type Pixel; 00034 00035 View dst = subimage_view( dstView, window.x1, window.y1, 00036 window.x2-window.x1, window.y2-window.y1 ); 00037 boost::gil::fill_pixels( dst, pixelValue ); 00038 } 00039 00040 /** 00041 * @brief fill a range of pixels (on the same line or with an 1d_traversable image). 00042 * 00043 * @param[out] dstBegin Begining of the region to fill. The content is filled but the original iterator is not modified (not a reference parameter). 00044 * @param[in] dstEnd End of the region to fill. 00045 * @param[in] pixelValue Pixel value used to fill. 00046 */ 00047 template<class DIterator, class DPixel> 00048 GIL_FORCEINLINE 00049 void fill_pixels_range( DIterator dstBegin, const DIterator& dstEnd, const DPixel& pixelValue ) 00050 { 00051 do 00052 { 00053 *dstBegin = pixelValue; 00054 ++dstBegin; 00055 } 00056 while( dstBegin != dstEnd ); 00057 } 00058 00059 00060 00061 } 00062 } 00063 00064 #endif 00065