mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #16309 from ganesh-k13:bugfix/imdecode-resize
* Added flag handlers for imread and imdecode | Issue 16203 Undo imread change Added Imread resize tests Added imdecode flags check Added imdecode tests for resize Removed trailing whitespace Removed IMREAD_IGNORE_ORIENTATION check Added else condition Removed IMREAD_IGNORE_ORIENTATION check in decode Added HAVE_JPEG guards Added static_cast for Win32 Added resize for non jpegs Added tests for non jpeg resize case Fixed resize value in assert Changed tests to Value-Parameterized Tests Changed tests to Value-Parameterized Tests | handled >> in cpp Changed tests to Value-Parameterized Tests | removed trailing whitespace * imgcodecs: update test
This commit is contained in:
committed by
Alexander Alekhin
parent
00830d9dd8
commit
80ade96c8c
@@ -423,12 +423,12 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
|
||||
int scale_denom = 1;
|
||||
if( flags > IMREAD_LOAD_GDAL )
|
||||
{
|
||||
if( flags & IMREAD_REDUCED_GRAYSCALE_2 )
|
||||
scale_denom = 2;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_4 )
|
||||
scale_denom = 4;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_8 )
|
||||
scale_denom = 8;
|
||||
if( flags & IMREAD_REDUCED_GRAYSCALE_2 )
|
||||
scale_denom = 2;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_4 )
|
||||
scale_denom = 4;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_8 )
|
||||
scale_denom = 8;
|
||||
}
|
||||
|
||||
/// set the scale_denom in the driver
|
||||
@@ -766,6 +766,20 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
|
||||
if( !decoder )
|
||||
return 0;
|
||||
|
||||
int scale_denom = 1;
|
||||
if( flags > IMREAD_LOAD_GDAL )
|
||||
{
|
||||
if( flags & IMREAD_REDUCED_GRAYSCALE_2 )
|
||||
scale_denom = 2;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_4 )
|
||||
scale_denom = 4;
|
||||
else if( flags & IMREAD_REDUCED_GRAYSCALE_8 )
|
||||
scale_denom = 8;
|
||||
}
|
||||
|
||||
/// set the scale_denom in the driver
|
||||
decoder->setScale( scale_denom );
|
||||
|
||||
if( !decoder->setSource(buf_row) )
|
||||
{
|
||||
filename = tempfile();
|
||||
@@ -861,7 +875,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
|
||||
{
|
||||
std::cerr << "imdecode_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
|
||||
}
|
||||
decoder.release();
|
||||
|
||||
if (!filename.empty())
|
||||
{
|
||||
if (0 != remove(filename.c_str()))
|
||||
@@ -879,6 +893,13 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( decoder->setScale( scale_denom ) > 1 ) // if decoder is JpegDecoder then decoder->setScale always returns 1
|
||||
{
|
||||
resize( *mat, *mat, Size( size.width / scale_denom, size.height / scale_denom ), 0, 0, INTER_LINEAR_EXACT);
|
||||
}
|
||||
|
||||
decoder.release();
|
||||
|
||||
return hdrtype == LOAD_CVMAT ? (void*)matrix :
|
||||
hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user