diff --git a/CHANGES.txt b/CHANGES.txt index 2dff6f3..dd11c27 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,5 @@ -Oct 29, 2013 - Palette box now a 2D numpy array instead of a list of +Nov 11, 2013 - Palette box now a 2D numpy array instead of a list of 1D arrays. Super box constructors now take optional box list argument. - Removed ssiz attribute from SIZsegment class. Oct 29, 2013 - v0.5.9 Fixed bad library load on linux as a result of 0.5.8 diff --git a/glymur/codestream.py b/glymur/codestream.py index d01795f..4274b61 100644 --- a/glymur/codestream.py +++ b/glymur/codestream.py @@ -662,7 +662,7 @@ class Codestream(object): component_buffer) bitdepth = tuple(((x & 0x7f) + 1) for x in data[0::3]) - signed = tuple(((x & 0xb0) > 0) for x in data[0::3]) + signed = tuple(((x & 0x80) > 0) for x in data[0::3]) xrsiz = data[1::3] yrsiz = data[2::3] @@ -1506,6 +1506,15 @@ class SIZsegment(Segment): self.signed = signed self.xrsiz, self.yrsiz = xyrsiz + # ssiz attribute to be removed in 1.0.0 + lst = [] + for bitdepth, signed in zip(self.bitdepth, self.signed): + if signed: + lst.append((bitdepth - 1) & 0x80) + else: + lst.append(bitdepth - 1) + self.ssiz = tuple(lst) + num_tiles_x = (self.xsiz - self.xosiz) / (self.xtsiz - self.xtosiz) num_tiles_y = (self.ysiz - self.yosiz) / (self.ytsiz - self.ytosiz) numtiles = math.ceil(num_tiles_x) * math.ceil(num_tiles_y) diff --git a/glymur/test/test_codestream.py b/glymur/test/test_codestream.py index 76042b9..39e3b16 100644 --- a/glymur/test/test_codestream.py +++ b/glymur/test/test_codestream.py @@ -117,6 +117,17 @@ class TestCodestream(unittest.TestCase): self.assertEqual(codestream.segment[-1].marker_id, 'EOC') + def test_siz_segment_ssiz(self): + """ssiz attribute to be removed in future release""" + j = Jp2k(self.jp2file) + codestream = j.get_codestream() + + # The ssiz attribute was simply a tuple of raw bytes. + # The first 7 bits are interpreted as the bitdepth, the MSB determines + # whether or not it is signed. + self.assertEqual(codestream.segment[1].ssiz, (7, 7, 7)) + + class TestCodestreamRepr(unittest.TestCase): def setUp(self):