--- imagedata.i 2006/10/02 20:24:07 1.3 +++ imagedata.i 2007/01/25 18:19:21 1.4 @@ -53,8 +53,10 @@ void CvMat_imageData_set(CvMat * self, PyObject* object) { char* py_string = PyString_AsString(object); + int depth = CV_MAT_DEPTH(self->type); + int cn = CV_MAT_CN(self->type); - if (self->type == CV_8UC3){ + if (depth == CV_8U && cn==3){ // RGB case // The data is reordered beause OpenCV uses BGR instead of RGB @@ -70,7 +72,7 @@ self->data.ptr[position+2] = py_string[sourcepos ]; } } - else if (self->type == CV_8UC1) + else if (depth == CV_8U && cn==1) { // Grayscale 8bit case @@ -86,10 +88,9 @@ ); } } - else if (self->type == CV_32FC1 ) + else if ( depth == CV_32F ) { // Float 32bit case - for (long line = 0; line < self->rows; ++line) { // here we don not have to care about alignment as the Floats are