Ejemplo n.º 1
0
 def _test_conversion(self, format_name: str, inputs, outputs):
     pf = Dictionary.get_proxy(format_name)
     for input, output in zip(inputs, outputs):
         packed = np.frombuffer(input, dtype=np.uint8)
         unpacked_elements = pf.expand(packed)
         self.assertEqual(len(outputs), unpacked_elements.size)
         for i, element in enumerate(unpacked_elements):
             self.assertEqual(output[i], element)
Ejemplo n.º 2
0
 def _test_issue_146_packed_12(self):
     _1st = 0xff
     _3rd = 0xff
     ba = bytes([_1st, 0xff, _3rd])
     packed = np.frombuffer(ba, dtype=np.uint8)
     pf = Dictionary.get_proxy('Mono12p')
     unpacked = pf.expand(packed)
     self.assertEqual(0xf * 256 + _1st, unpacked[0])
     self.assertEqual(_3rd * 16 + 0xf, unpacked[1])
Ejemplo n.º 3
0
 def _test_issue_146_packed_10(self):
     element = 0xff
     ba = bytes([element, element, element, element])
     packed = np.frombuffer(ba, dtype=np.uint8)
     pf = Dictionary.get_proxy('Mono10p')
     unpacked = pf.expand(packed)
     self.assertEqual(0x3ff, unpacked[0])
     self.assertEqual(0x3ff, unpacked[1])
     self.assertEqual(0x7ff, unpacked[2])
Ejemplo n.º 4
0
 def _test_issue_146_group_packed_12(self):
     _1st = 0xff
     _3rd = 0xff
     ba = bytes([_1st, 0xff, _3rd])
     packed = np.frombuffer(ba, dtype=np.uint8)
     pf = Dictionary.get_proxy('BayerRG12Packed')
     unpacked = pf.expand(packed)
     self.assertEqual(_1st * 16 + 0xf, unpacked[0])
     self.assertEqual(_3rd * 16 + 0xf, unpacked[1])
Ejemplo n.º 5
0
 def _test_issue_146_mono_unpacked_multibytes(self):
     names = ['Mono10', 'Mono12']
     maximums = [0x4, 0x10]
     for index, name in enumerate(names):
         pf = Dictionary.get_proxy(name)
         for i in range(maximums[index]):
             for j in range(0x100):
                 ba = bytes([j, i, j, i])
                 packed = np.frombuffer(ba, dtype=np.uint8)
                 unpacked = pf.expand(packed)
                 # We know it's redundant but check 10 times:
                 for l in range(10):
                     for k in range(2):
                         self.assertEqual((i << 8) + j, unpacked[k])