提交 32b6ebb6 编写于 作者: A Alexander Alekhin

Merge pull request #14989 from alalek:issue_14978

......@@ -748,24 +748,28 @@ bool imwrite( const String& filename, InputArray _img,
static void*
imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
{
CV_Assert(!buf.empty() && buf.isContinuous());
CV_Assert(!buf.empty());
CV_Assert(buf.isContinuous());
CV_Assert(buf.checkVector(1, CV_8U) > 0);
Mat buf_row = buf.reshape(1, 1); // decoders expects single row, avoid issues with vector columns
IplImage* image = 0;
CvMat *matrix = 0;
Mat temp, *data = &temp;
String filename;
ImageDecoder decoder = findDecoder(buf);
ImageDecoder decoder = findDecoder(buf_row);
if( !decoder )
return 0;
if( !decoder->setSource(buf) )
if( !decoder->setSource(buf_row) )
{
filename = tempfile();
FILE* f = fopen( filename.c_str(), "wb" );
if( !f )
return 0;
size_t bufSize = buf.cols*buf.rows*buf.elemSize();
if( fwrite( buf.ptr(), 1, bufSize, f ) != bufSize )
size_t bufSize = buf_row.total()*buf.elemSize();
if (fwrite(buf_row.ptr(), 1, bufSize, f) != bufSize)
{
fclose( f );
CV_Error( CV_StsError, "failed to write image data to temporary file" );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册