|
40 | 40 | //M*/
|
41 | 41 | #include "precomp.hpp"
|
42 | 42 |
|
| 43 | +#include <stdint.h> |
| 44 | + |
43 | 45 | namespace cv
|
44 | 46 | {
|
45 | 47 |
|
@@ -1069,22 +1071,36 @@ EllipseEx( Mat& img, Point2l center, Size2l axes,
|
1069 | 1071 | * Polygons filling *
|
1070 | 1072 | \****************************************************************************************/
|
1071 | 1073 |
|
1072 |
| -/* helper macros: filling horizontal row */ |
1073 |
| -#define ICV_HLINE( ptr, xl, xr, color, pix_size ) \ |
1074 |
| -{ \ |
1075 |
| - uchar* hline_ptr = (uchar*)(ptr) + (xl)*(pix_size); \ |
1076 |
| - uchar* hline_max_ptr = (uchar*)(ptr) + (xr)*(pix_size); \ |
1077 |
| - \ |
1078 |
| - for( ; hline_ptr <= hline_max_ptr; hline_ptr += (pix_size))\ |
1079 |
| - { \ |
1080 |
| - int hline_j; \ |
1081 |
| - for( hline_j = 0; hline_j < (pix_size); hline_j++ ) \ |
1082 |
| - { \ |
1083 |
| - hline_ptr[hline_j] = ((uchar*)color)[hline_j]; \ |
1084 |
| - } \ |
1085 |
| - } \ |
| 1074 | +static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, int pix_size) |
| 1075 | +{ |
| 1076 | + uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size); |
| 1077 | + uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size); |
| 1078 | + uchar* hline_ptr = hline_min_ptr; |
| 1079 | + if (pix_size == 1) |
| 1080 | + memset(hline_min_ptr, *color, hline_end_ptr-hline_min_ptr); |
| 1081 | + else//if (pix_size != 1) |
| 1082 | + { |
| 1083 | + if (hline_min_ptr < hline_end_ptr) |
| 1084 | + { |
| 1085 | + memcpy(hline_ptr, color, pix_size); |
| 1086 | + hline_ptr += pix_size; |
| 1087 | + }//end if (hline_min_ptr < hline_end_ptr) |
| 1088 | + size_t sizeToCopy = pix_size; |
| 1089 | + while(hline_ptr < hline_end_ptr) |
| 1090 | + { |
| 1091 | + memcpy(hline_ptr, hline_min_ptr, sizeToCopy); |
| 1092 | + hline_ptr += sizeToCopy; |
| 1093 | + sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr)); |
| 1094 | + }//end while(hline_ptr < hline_end_ptr) |
| 1095 | + }//end if (pix_size != 1) |
1086 | 1096 | }
|
| 1097 | +//end ICV_HLINE_X() |
1087 | 1098 |
|
| 1099 | +static inline void ICV_HLINE(uchar* ptr, int xl, int xr, const void* color, int pix_size) |
| 1100 | +{ |
| 1101 | + ICV_HLINE_X(ptr, xl, xr, reinterpret_cast<const uchar*>(color), pix_size); |
| 1102 | +} |
| 1103 | +//end ICV_HLINE() |
1088 | 1104 |
|
1089 | 1105 | /* filling convex polygon. v - array of vertices, ntps - number of points */
|
1090 | 1106 | static void
|
|
0 commit comments