Merge branch 'issue218' into devel

This commit is contained in:
John Evans 2014-04-09 17:03:06 -04:00
commit afb61d28e6
2 changed files with 19 additions and 4 deletions

View file

@ -990,14 +990,18 @@ class ContiguousCodestreamBox(Jp2kBox):
offset of the box from the start of the file.
longname : str
more verbose description of the box.
main_header : list
List of segments in the codestream header.
main_header : Codestream object
contains list of main header marker/segments
main_header_offset : int
offset of main header from start of file
"""
def __init__(self, main_header=None, length=0, offset=-1):
def __init__(self, main_header=None, main_header_offset=None, length=0,
offset=-1):
Jp2kBox.__init__(self, box_id='jp2c', longname='Contiguous Codestream')
self._main_header = main_header
self.length = length
self.offset = offset
self.main_header_offset = main_header_offset
# The filename can be set if lazy loading is desired.
self._filename = None
@ -1046,11 +1050,13 @@ class ContiguousCodestreamBox(Jp2kBox):
-------
ContiguousCodestreamBox instance
"""
main_header_offset = fptr.tell()
if _parseoptions['codestream'] is True:
main_header = Codestream(fptr, length, header_only=True)
else:
main_header = None
box = cls(main_header, length=length, offset=offset)
box = cls(main_header, main_header_offset=main_header_offset,
length=length, offset=offset)
box._filename = fptr.name
box._length = length
box._offset = offset

View file

@ -935,6 +935,9 @@ class TestWrap(unittest.TestCase):
class TestJp2Boxes(unittest.TestCase):
"""Tests for canonical JP2 boxes."""
def setUp(self):
self.jpxfile = glymur.data.jpxfile()
def test_default_jp2k(self):
"""Should be able to instantiate a JPEG2000SignatureBox"""
jp2k = glymur.jp2box.JPEG2000SignatureBox()
@ -971,6 +974,12 @@ class TestJp2Boxes(unittest.TestCase):
self.assertEqual(box.box_id, 'jp2c')
self.assertIsNone(box.main_header)
def test_codestream_main_header_offset(self):
"""main_header_offset is an attribute of the CCS box"""
j = Jp2k(self.jpxfile);
self.assertEqual(j.box[5].main_header_offset,
j.box[5].offset + 8)
class TestRepr(unittest.TestCase):
"""Tests for __repr__ methods."""