mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #13382 from LaurentBerger:imreadsize
* try to solve #13381 * Add note
This commit is contained in:
parent
40a53e3d64
commit
f1dc26d7ce
@ -171,6 +171,8 @@ Currently, the following file formats are supported:
|
||||
[Vector](http://www.gdal.org/ogr_formats.html).
|
||||
- If EXIF information are embedded in the image file, the EXIF orientation will be taken into account
|
||||
and thus the image will be rotated accordingly except if the flag @ref IMREAD_IGNORE_ORIENTATION is passed.
|
||||
- By default number of pixels must be less than 2^30. Limit can be set using system
|
||||
variable OPENCV_IO_MAX_IMAGE_PIXELS
|
||||
|
||||
@param filename Name of file to be loaded.
|
||||
@param flags Flag that can take values of cv::ImreadModes
|
||||
|
@ -51,6 +51,8 @@
|
||||
#undef max
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <opencv2/core/utils/configuration.private.hpp>
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* Image Codecs *
|
||||
@ -58,18 +60,17 @@
|
||||
|
||||
namespace cv {
|
||||
|
||||
// TODO Add runtime configuration
|
||||
#define CV_IO_MAX_IMAGE_PARAMS (50)
|
||||
#define CV_IO_MAX_IMAGE_WIDTH (1<<20)
|
||||
#define CV_IO_MAX_IMAGE_HEIGHT (1<<20)
|
||||
#define CV_IO_MAX_IMAGE_PIXELS (1<<30) // 1 Gigapixel
|
||||
static const size_t CV_IO_MAX_IMAGE_PARAMS = cv::utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_PARAMS", 50);
|
||||
static const size_t CV_IO_MAX_IMAGE_WIDTH = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_WIDTH", 1 << 20);
|
||||
static const size_t CV_IO_MAX_IMAGE_HEIGHT = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_HEIGHT", 1 << 20);
|
||||
static const size_t CV_IO_MAX_IMAGE_PIXELS = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_PIXELS", 1 << 30);
|
||||
|
||||
static Size validateInputImageSize(const Size& size)
|
||||
{
|
||||
CV_Assert(size.width > 0);
|
||||
CV_Assert(size.width <= CV_IO_MAX_IMAGE_WIDTH);
|
||||
CV_Assert(static_cast<size_t>(size.width) <= CV_IO_MAX_IMAGE_WIDTH);
|
||||
CV_Assert(size.height > 0);
|
||||
CV_Assert(size.height <= CV_IO_MAX_IMAGE_HEIGHT);
|
||||
CV_Assert(static_cast<size_t>(size.height) <= CV_IO_MAX_IMAGE_HEIGHT);
|
||||
uint64 pixels = (uint64)size.width * (uint64)size.height;
|
||||
CV_Assert(pixels <= CV_IO_MAX_IMAGE_PIXELS);
|
||||
return size;
|
||||
@ -998,7 +999,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
|
||||
if( _params )
|
||||
{
|
||||
for( ; _params[i] > 0; i += 2 )
|
||||
CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
|
||||
CV_Assert(static_cast<size_t>(i) < cv::CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
|
||||
}
|
||||
return cv::imwrite_(filename, cv::cvarrToMat(arr),
|
||||
i > 0 ? std::vector<int>(_params, _params+i) : std::vector<int>(),
|
||||
@ -1029,7 +1030,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
|
||||
if( _params )
|
||||
{
|
||||
for( ; _params[i] > 0; i += 2 )
|
||||
CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
|
||||
CV_Assert(static_cast<size_t>(i) < cv::CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
|
||||
}
|
||||
cv::Mat img = cv::cvarrToMat(arr);
|
||||
if( CV_IS_IMAGE(arr) && ((const IplImage*)arr)->origin == IPL_ORIGIN_BL )
|
||||
|
Loading…
Reference in New Issue
Block a user