| 2994 | |
| 2995 | |
| 2996 | CV_IMPL void |
| 2997 | cvSetImageROI( IplImage* image, CvRect rect ) |
| 2998 | { |
| 2999 | if( !image ) |
| 3000 | CV_Error( CV_HeaderIsNull, "" ); |
| 3001 | |
| 3002 | // allow zero ROI width or height |
| 3003 | CV_Assert( rect.width >= 0 && rect.height >= 0 && |
| 3004 | rect.x < image->width && rect.y < image->height && |
| 3005 | rect.x + rect.width >= (int)(rect.width > 0) && |
| 3006 | rect.y + rect.height >= (int)(rect.height > 0) ); |
| 3007 | |
| 3008 | rect.width += rect.x; |
| 3009 | rect.height += rect.y; |
| 3010 | |
| 3011 | rect.x = std::max(rect.x, 0); |
| 3012 | rect.y = std::max(rect.y, 0); |
| 3013 | rect.width = std::min(rect.width, image->width); |
| 3014 | rect.height = std::min(rect.height, image->height); |
| 3015 | |
| 3016 | rect.width -= rect.x; |
| 3017 | rect.height -= rect.y; |
| 3018 | |
| 3019 | if( image->roi ) |
| 3020 | { |
| 3021 | image->roi->xOffset = rect.x; |
| 3022 | image->roi->yOffset = rect.y; |
| 3023 | image->roi->width = rect.width; |
| 3024 | image->roi->height = rect.height; |
| 3025 | } |
| 3026 | else |
| 3027 | image->roi = icvCreateROI( 0, rect.x, rect.y, rect.width, rect.height ); |
| 3028 | } |
| 3029 | |
| 3030 | |
| 3031 | CV_IMPL void |
no test coverage detected