Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/OpenEXR/IlmImf/ImfHeader.cpp view on Meta::CPAN
{
THROW (IEX_NAMESPACE::ArgExc, "The width of the data window exceeds the "
"maximum width of " << maxImageWidth << "pixels.");
}
if (maxImageHeight > 0 &&
maxImageHeight < dataWindow.max.y - dataWindow.min.y + 1)
{
THROW (IEX_NAMESPACE::ArgExc, "The width of the data window exceeds the "
"maximum width of " << maxImageHeight << "pixels.");
}
// chunk table must be smaller than the maximum image area
// (only reachable for unknown types or damaged files: will have thrown earlier
// for regular image types)
if( maxImageHeight>0 && maxImageWidth>0 &&
hasChunkCount() && chunkCount()>Int64(maxImageWidth)*Int64(maxImageHeight))
{
THROW (IEX_NAMESPACE::ArgExc, "chunkCount exceeds maximum area of "
<< Int64(maxImageWidth)*Int64(maxImageHeight) << " pixels." );
}
//
// The pixel aspect ratio must be greater than 0.
// In applications, numbers like the the display or
// data window dimensions are likely to be multiplied
// or divided by the pixel aspect ratio; to avoid
// arithmetic exceptions, we limit the pixel aspect
// ratio to a range that is smaller than theoretically
// possible (real aspect ratios are likely to be close
// to 1.0 anyway).
//
float pixelAspectRatio = this->pixelAspectRatio();
const float MIN_PIXEL_ASPECT_RATIO = 1e-6f;
const float MAX_PIXEL_ASPECT_RATIO = 1e+6f;
if (pixelAspectRatio < MIN_PIXEL_ASPECT_RATIO ||
pixelAspectRatio > MAX_PIXEL_ASPECT_RATIO)
{
throw IEX_NAMESPACE::ArgExc ("Invalid pixel aspect ratio in image header.");
}
//
// The screen window width must not be less than 0.
// The size of the screen window can vary over a wide
// range (fish-eye lens to astronomical telescope),
// so we can't limit the screen window width to a
// small range.
//
float screenWindowWidth = this->screenWindowWidth();
if (screenWindowWidth < 0)
throw IEX_NAMESPACE::ArgExc ("Invalid screen window width in image header.");
//
// If the file has multiple parts, verify that each header has attribute
// name and type.
// (TODO) We may want to check more stuff here.
//
if (isMultipartFile)
{
if (!hasName())
{
throw IEX_NAMESPACE::ArgExc ("Headers in a multipart file should"
" have name attribute.");
}
if (!hasType())
{
throw IEX_NAMESPACE::ArgExc ("Headers in a multipart file should"
" have type attribute.");
}
}
const std::string & part_type=hasType() ? type() : "";
if(part_type!="" && !isSupportedType(part_type))
{
//
// skip remaining sanity checks with unsupported types - they may not hold
//
return;
}
//
// If the file is tiled, verify that the tile description has reasonable
// values and check to see if the lineOrder is one of the predefined 3.
// If the file is not tiled, then the lineOrder can only be INCREASING_Y
// or DECREASING_Y.
//
LineOrder lineOrder = this->lineOrder();
if (isTiled)
{
if (!hasTileDescription())
{
throw IEX_NAMESPACE::ArgExc ("Tiled image has no tile "
"description attribute.");
}
const TileDescription &tileDesc = tileDescription();
if (tileDesc.xSize <= 0 || tileDesc.ySize <= 0)
throw IEX_NAMESPACE::ArgExc ("Invalid tile size in image header.");
if (maxTileWidth > 0 &&
maxTileWidth < int(tileDesc.xSize))
{
THROW (IEX_NAMESPACE::ArgExc, "The width of the tiles exceeds the maximum "
"width of " << maxTileWidth << "pixels.");
}
if (maxTileHeight > 0 &&
maxTileHeight < int(tileDesc.ySize))
{
THROW (IEX_NAMESPACE::ArgExc, "The width of the tiles exceeds the maximum "
"width of " << maxTileHeight << "pixels.");
}
if (tileDesc.mode != ONE_LEVEL &&
tileDesc.mode != MIPMAP_LEVELS &&
tileDesc.mode != RIPMAP_LEVELS)
throw IEX_NAMESPACE::ArgExc ("Invalid level mode in image header.");
if (tileDesc.roundingMode != ROUND_UP &&
tileDesc.roundingMode != ROUND_DOWN)
throw IEX_NAMESPACE::ArgExc ("Invalid level rounding mode in image header.");
if (lineOrder != INCREASING_Y &&
lineOrder != DECREASING_Y &&
lineOrder != RANDOM_Y)
throw IEX_NAMESPACE::ArgExc ("Invalid line order in image header.");
}
else
{
if (lineOrder != INCREASING_Y &&
lineOrder != DECREASING_Y)
throw IEX_NAMESPACE::ArgExc ("Invalid line order in image header.");
}
//
// The compression method must be one of the predefined values.
//
( run in 1.183 second using v1.01-cache-2.11-cpan-119454b85a5 )