Initializes CvMat header, allocated by the user
| 133 | |
| 134 | // Initializes CvMat header, allocated by the user |
| 135 | CV_IMPL CvMat* |
| 136 | cvInitMatHeader( CvMat* arr, int rows, int cols, |
| 137 | int type, void* data, int step ) |
| 138 | { |
| 139 | if( !arr ) |
| 140 | CV_Error( CV_StsNullPtr, "" ); |
| 141 | |
| 142 | if( (unsigned)CV_MAT_DEPTH(type) > CV_DEPTH_MAX ) |
| 143 | CV_Error( CV_BadNumChannels, "" ); |
| 144 | |
| 145 | if( rows < 0 || cols <= 0 ) |
| 146 | CV_Error( CV_StsBadSize, "Non-positive cols or rows" ); |
| 147 | |
| 148 | type = CV_MAT_TYPE( type ); |
| 149 | arr->type = type | CV_MAT_MAGIC_VAL; |
| 150 | arr->rows = rows; |
| 151 | arr->cols = cols; |
| 152 | arr->data.ptr = (uchar*)data; |
| 153 | arr->refcount = 0; |
| 154 | arr->hdr_refcount = 0; |
| 155 | |
| 156 | int pix_size = CV_ELEM_SIZE(type); |
| 157 | int min_step = arr->cols*pix_size; |
| 158 | |
| 159 | if( step != CV_AUTOSTEP && step != 0 ) |
| 160 | { |
| 161 | if( step < min_step ) |
| 162 | CV_Error( CV_BadStep, "" ); |
| 163 | arr->step = step; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | arr->step = min_step; |
| 168 | } |
| 169 | |
| 170 | arr->type = CV_MAT_MAGIC_VAL | type | |
| 171 | (arr->rows == 1 || arr->step == min_step ? CV_MAT_CONT_FLAG : 0); |
| 172 | |
| 173 | icvCheckHuge( arr ); |
| 174 | return arr; |
| 175 | } |
| 176 | |
| 177 | |
| 178 | // Deallocates the CvMat structure and underlying data |
no test coverage detected