1
0
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:
Andrey Kamaev
2013-01-28 15:49:31 +04:00
parent 8521ac5d21
commit 255cd61a8c
5 changed files with 37 additions and 1 deletions
+4
View File
@@ -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 );