#include "gdcmPixelFormat.h"
struct frame_info {
gdcm::PixelFormat pixeltype;
};
int TestPixelFormat(int , char *[])
{
using gdcm::PixelFormat;
gdcm::PixelFormat pf;
pf.SetScalarType( gdcm::PixelFormat::UNKNOWN );
if( pf.GetScalarType() != gdcm::PixelFormat::UNKNOWN )
{
return 1;
}
pf.SetScalarType( gdcm::PixelFormat::UINT32 );
static const int64_t values[][2] = {
{ 0LL,255LL },
{ 0LL,4095LL },
{ 0LL,65535LL },
{ 0LL,4294967295LL },
{ -128LL,127LL },
{ -2048LL,2047LL },
{ -32768LL,32767LL },
{ -2147483648LL,2147483647LL },
};
static const size_t n = sizeof( values ) / sizeof( *values );
size_t c = 0;
pf.SetBitsStored( 8 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 12 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 16 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 32 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
pf.SetPixelRepresentation( 1 );
++c;
pf.SetBitsStored( 8 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 12 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 16 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
pf.SetBitsStored( 32 );
if( pf.GetMin() != values[c][0] || pf.GetMax() != values[c][1] )
{
std::cerr << pf.GetMin() << "," << pf.GetMax() << std::endl;
return 1;
}
++c;
if ( c != n ) return 1;
for(unsigned int i = 0; i < PixelFormat::UNKNOWN; ++i)
{
PixelFormat::ScalarType st = (PixelFormat::ScalarType)i;
pf.SetScalarType( st );
gdcm::PixelFormat pf2 = st;
std::cout << pf << std::endl;
std::cout << pf.GetPixelRepresentation() << std::endl;
std::cout << pf.GetScalarTypeAsString() << std::endl;
if( pf2 != pf ) return 1;
}
gdcm::PixelFormat pf3 = PixelFormat::UINT8;
if( pf3.GetBitsStored() != 8 ) return 1;
pf3.SetBitsStored( 32 );
if( pf3.GetBitsStored() != 8 ) return 1;
pf3.SetHighBit( 8 );
if( pf3.GetHighBit() != 7 ) return 1;
gdcm::PixelFormat pf4 = PixelFormat::UINT16;
pf4.SetBitsStored(8);
if( pf4.GetScalarType() != gdcm::PixelFormat::UINT16 ) return 1;
pf4.SetPixelRepresentation(1);
if( pf4.GetScalarType() != gdcm::PixelFormat::INT16 ) return 1;
frame_info fi = {};
(void)fi;
return 0;
}