|
|
@ -598,6 +598,7 @@ bool JpegEncoder::write( const Mat& img, const std::vector<int>& params ) |
|
|
|
cinfo.in_color_space = channels > 1 ? JCS_RGB : JCS_GRAYSCALE; |
|
|
|
cinfo.in_color_space = channels > 1 ? JCS_RGB : JCS_GRAYSCALE; |
|
|
|
|
|
|
|
|
|
|
|
int quality = 95; |
|
|
|
int quality = 95; |
|
|
|
|
|
|
|
int progressive = 0; |
|
|
|
|
|
|
|
|
|
|
|
for( size_t i = 0; i < params.size(); i += 2 ) |
|
|
|
for( size_t i = 0; i < params.size(); i += 2 ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -606,11 +607,18 @@ bool JpegEncoder::write( const Mat& img, const std::vector<int>& params ) |
|
|
|
quality = params[i+1]; |
|
|
|
quality = params[i+1]; |
|
|
|
quality = MIN(MAX(quality, 0), 100); |
|
|
|
quality = MIN(MAX(quality, 0), 100); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( params[i] == CV_IMWRITE_JPEG_PROGRESSIVE ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
progressive = params[i+1]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
jpeg_set_defaults( &cinfo ); |
|
|
|
jpeg_set_defaults( &cinfo ); |
|
|
|
jpeg_set_quality( &cinfo, quality, |
|
|
|
jpeg_set_quality( &cinfo, quality, |
|
|
|
TRUE /* limit to baseline-JPEG values */ ); |
|
|
|
TRUE /* limit to baseline-JPEG values */ ); |
|
|
|
|
|
|
|
if( progressive ) |
|
|
|
|
|
|
|
jpeg_simple_progression( &cinfo ); |
|
|
|
jpeg_start_compress( &cinfo, TRUE ); |
|
|
|
jpeg_start_compress( &cinfo, TRUE ); |
|
|
|
|
|
|
|
|
|
|
|
if( channels > 1 ) |
|
|
|
if( channels > 1 ) |
|
|
|