| 149 | return true; |
| 150 | } |
| 151 | bool CvvImage::LoadRect( const char* filename, |
| 152 | int desired_color, CvRect r ) |
| 153 | { |
| 154 | if( r.width < 0 || r.height < 0 ) return false; |
| 155 | |
| 156 | IplImage* img = cvLoadImage( filename, desired_color ); |
| 157 | if( !img ) |
| 158 | return false; |
| 159 | if( r.width == 0 || r.height == 0 ) |
| 160 | { |
| 161 | r.width = img->width; |
| 162 | r.height = img->height; |
| 163 | r.x = r.y = 0; |
| 164 | } |
| 165 | if( r.x > img->width || r.y > img->height || |
| 166 | r.x + r.width < 0 || r.y + r.height < 0 ) |
| 167 | { |
| 168 | cvReleaseImage( &img ); |
| 169 | return false; |
| 170 | } |
| 171 | /* truncate r to source image */ |
| 172 | if( r.x < 0 ) |
| 173 | { |
| 174 | r.width += r.x; |
| 175 | r.x = 0; |
| 176 | } |
| 177 | if( r.y < 0 ) |
| 178 | { |
| 179 | r.height += r.y; |
| 180 | r.y = 0; |
| 181 | } |
| 182 | if( r.x + r.width > img->width ) |
| 183 | r.width = img->width - r.x; |
| 184 | |
| 185 | if( r.y + r.height > img->height ) |
| 186 | r.height = img->height - r.y; |
| 187 | cvSetImageROI( img, r ); |
| 188 | CopyOf( img, desired_color ); |
| 189 | cvReleaseImage( &img ); |
| 190 | return true; |
| 191 | } |
| 192 | bool CvvImage::Save( const char* filename ) |
| 193 | { |
| 194 | if( !m_img ) |
nothing calls this directly
no outgoing calls
no test coverage detected