filters/gp_filter_resize_alloc: Check w and h
[gfxprim.git] / gen / include / pixelsize.py
blob6548a0f349cb08a7f9de099d4ae8758c9677ebf7
2 # gfxprim.pixelsize
4 # 2011 - Tomas Gavenciak <gavento@ucw.cz>
5 # 2014 - Cyril Hrubis <chrubis@ucw.cz>
8 LE = "LE"
9 BE = "BE"
11 class PixelSize(object):
12 def __init__(self, size, bit_endian=None, suffix=None):
13 self.size = size
14 assert self.size >= 0
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)
21 self.suffix = suffix
22 if not self.suffix:
23 if self.size == 0:
24 self.suffix = "INVALID"
25 else:
26 if bit_endian:
27 self.suffix = '%dBPP_%s' % (size, bit_endian)
28 else:
29 self.suffix = '%dBPP' % (size,)
31 def needs_bit_endian(self):
32 return (self.size % 8) != 0
34 def description(self):
35 if self.bit_endian:
36 return "pixel size %d, bit endian %s, suffix %s" % (self.size,
37 self.bit_endian, self.suffix)
38 else:
39 return "pixel size %d, suffix %s" % (self.size, self.suffix)