diff -urNp old/modules/imgcodecs/src/grfmt_pxm.cpp new/modules/imgcodecs/src/grfmt_pxm.cpp --- old/modules/imgcodecs/src/grfmt_pxm.cpp 2018-04-10 12:40:15.926177118 +0200 +++ new/modules/imgcodecs/src/grfmt_pxm.cpp 2018-04-10 12:42:39.932022243 +0200 @@ -309,7 +309,7 @@ bool PxMDecoder::readData( Mat& img ) } } else - memcpy( data, src, CV_ELEM_SIZE1(m_type)*m_width); + memcpy( data, src, img.elemSize1()*m_width); } else {