4 # 2011 - Tomas Gavenciak <gavento@ucw.cz>
5 # 2014 - Cyril Hrubis <chrubis@ucw.cz>
11 class PixelSize(object):
12 def __init__(self
, size
, bit_endian
=None, suffix
=None):
16 self
.bit_endian
= bit_endian
17 assert self
.bit_endian
in [None, LE
, BE
]
18 assert (bit_endian
is not None) == self
.needs_bit_endian()
19 self
.bit_endian_const
= "GP_BIT_ENDIAN_" + (self
.bit_endian
or LE
)
24 self
.suffix
= "INVALID"
27 self
.suffix
= '%dBPP_%s' % (size
, bit_endian
)
29 self
.suffix
= '%dBPP' % (size
,)
31 def needs_bit_endian(self
):
32 return (self
.size
% 8) != 0
34 def description(self
):
36 return "pixel size %d, bit endian %s, suffix %s" % (self
.size
,
37 self
.bit_endian
, self
.suffix
)
39 return "pixel size %d, suffix %s" % (self
.size
, self
.suffix
)