1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #27551 from sturkmen72:png-improvements

Add enum IMWRITE_PNG_ZLIBBUFFER_SIZE #27551

### Pull Request Readiness Checklist

This patch enables users to set the internal zlib compression buffer size for PNG encoding

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Suleyman TURKMEN
2025-07-18 20:41:12 +03:00
committed by GitHub
parent e2d87defd1
commit ab8a1fa280
3 changed files with 28 additions and 16 deletions
+20 -10
View File
@@ -947,26 +947,36 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
for( size_t i = 0; i < params.size(); i += 2 )
{
if( params[i] == IMWRITE_PNG_COMPRESSION )
switch (params[i])
{
case IMWRITE_PNG_COMPRESSION:
m_compression_strategy = IMWRITE_PNG_STRATEGY_DEFAULT; // Default strategy
m_compression_level = params[i+1];
m_compression_level = MIN(MAX(m_compression_level, 0), Z_BEST_COMPRESSION);
set_compression_level = true;
}
if( params[i] == IMWRITE_PNG_STRATEGY )
{
break;
case IMWRITE_PNG_STRATEGY:
m_compression_strategy = params[i+1];
m_compression_strategy = MIN(MAX(m_compression_strategy, 0), Z_FIXED);
}
if( params[i] == IMWRITE_PNG_BILEVEL )
{
break;
case IMWRITE_PNG_BILEVEL:
m_isBilevel = params[i+1] != 0;
}
if( params[i] == IMWRITE_PNG_FILTER )
{
break;
case IMWRITE_PNG_FILTER:
m_filter = params[i+1];
set_filter = true;
break;
case IMWRITE_PNG_ZLIBBUFFER_SIZE:
png_set_compression_buffer_size(png_ptr, params[i+1]);
break;
default:
CV_LOG_WARNING(NULL, "An unknown or unsupported ImwriteFlags value was specified and has been ignored.");
break;
}
}