added compression strategy as a parameter (another request from ticket #1452)
This commit is contained in:
@@ -312,6 +312,7 @@ void PngEncoder::flushBuf(void*)
|
||||
bool PngEncoder::write( const Mat& img, const vector<int>& params )
|
||||
{
|
||||
int compression_level = 0;
|
||||
int compression_strategy = Z_RLE;
|
||||
|
||||
for( size_t i = 0; i < params.size(); i += 2 )
|
||||
{
|
||||
@@ -320,6 +321,11 @@ bool PngEncoder::write( const Mat& img, const vector<int>& params )
|
||||
compression_level = params[i+1];
|
||||
compression_level = MIN(MAX(compression_level, 0), MAX_MEM_LEVEL);
|
||||
}
|
||||
if( params[i] == CV_IMWRITE_PNG_STRATEGY )
|
||||
{
|
||||
compression_strategy = params[i+1];
|
||||
compression_strategy = MIN(MAX(compression_strategy, 0), Z_FIXED);
|
||||
}
|
||||
}
|
||||
|
||||
png_structp png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 );
|
||||
@@ -366,7 +372,7 @@ bool PngEncoder::write( const Mat& img, const vector<int>& params )
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB);
|
||||
png_set_compression_level(png_ptr, Z_BEST_SPEED);
|
||||
}
|
||||
png_set_compression_strategy(png_ptr, Z_FILTERED);
|
||||
png_set_compression_strategy(png_ptr, compression_strategy);
|
||||
|
||||
png_set_IHDR( png_ptr, info_ptr, width, height, depth == CV_8U ? 8 : 16,
|
||||
channels == 1 ? PNG_COLOR_TYPE_GRAY :
|
||||
|
||||
Reference in New Issue
Block a user