mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 23:03:03 +04:00
Improve error reporting of JPEG image encoder
OpenCV issue #2604 After this patch applied an attempt to encode empty images produces exception saying "Raw image encoder error: Empty JPEG image (DNL not supported)"
This commit is contained in:
@@ -426,6 +426,7 @@ bool imencode( const string& ext, InputArray _image,
|
||||
if( encoder->setDestination(buf) )
|
||||
{
|
||||
code = encoder->write(image, params);
|
||||
encoder->throwOnEror();
|
||||
CV_Assert( code );
|
||||
}
|
||||
else
|
||||
@@ -433,8 +434,11 @@ bool imencode( const string& ext, InputArray _image,
|
||||
string filename = tempfile();
|
||||
code = encoder->setDestination(filename);
|
||||
CV_Assert( code );
|
||||
|
||||
code = encoder->write(image, params);
|
||||
encoder->throwOnEror();
|
||||
CV_Assert( code );
|
||||
|
||||
FILE* f = fopen( filename.c_str(), "rb" );
|
||||
CV_Assert(f != 0);
|
||||
fseek( f, 0, SEEK_END );
|
||||
|
||||
Reference in New Issue
Block a user