Add error message for portable map when pixel format is not supported

This commit is contained in:
2019-04-10 22:15:04 +01:00
parent 8620e3ddf2
commit 0989810e1f
+12 -7
View File
@@ -52,15 +52,11 @@ bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput )
{
m_bIsInput = bInput;
m_pFile = NULL;
m_pFile = fopen( strFilename.c_str(), bInput ? "rb" : "wb" );
if( m_pFile == NULL )
{
return false;
}
m_strFormatName = "PGM";
m_strCodecName = "Raw Video";
if( m_bIsInput )
{
m_pFile = fopen( strFilename.c_str(), "rb" );
char line[101];
while( fgets( line, 100, m_pFile ) && line[0] == '#' )
;
@@ -69,7 +65,7 @@ bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput )
;
sscanf( line, "%u %u", &m_uiWidth, &m_uiHeight );
if( m_iMagicNumber == 1 || m_iMagicNumber == 4 )
if( m_iMagicNumber == 1 )
{
m_uiBitsPerPixel = 1;
m_iMaxValue = 1;
@@ -90,11 +86,13 @@ bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput )
m_iMaxValue = ( 1 << m_uiBitsPerPixel ) - 1;
if( m_uiBitsPerPixel == 1 )
{
m_iMagicNumber = 4;
m_iMagicNumber = 1;
m_iPixelFormat = CalypFrame::findPixelFormat("GRAY");
}
else if( colorSpace == CLP_COLOR_GRAY )
{
m_iMagicNumber = 5;
m_iPixelFormat = CalypFrame::findPixelFormat("GRAY");
}
else if( colorSpace == CLP_COLOR_RGB )
{
@@ -104,12 +102,19 @@ bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput )
else
{
closeHandler();
throw CalypFailure( "CalypStream", "Invalid format for portable map" );
return false;
}
m_pFile = fopen( strFilename.c_str(), "wb" );
}
m_iEndianness = CLP_BIG_ENDIAN;
m_dFrameRate = 1;
m_uiTotalNumberFrames = 1;
if( m_pFile == NULL )
{
closeHandler();
return false;
}
return true;
}