Got 2.0.0 working again. #139

This commit is contained in:
jevans 2014-03-15 22:09:49 -04:00
commit 093f9c49fb
4 changed files with 22 additions and 8 deletions

View file

@ -20,6 +20,7 @@ from collections import Counter
import ctypes import ctypes
import math import math
import os import os
import re
import struct import struct
from uuid import UUID from uuid import UUID
import warnings import warnings
@ -166,7 +167,7 @@ class Jp2k(Jp2kBox):
fps : int fps : int
Frames per second, should be either 24 or 48. Frames per second, should be either 24 or 48.
""" """
if version.openjpeg_version_tuple[0] == 1: if re.match("(1.5|2.0)", version.openjpeg_version) is not None:
msg = "Writing Cinema2K or Cinema4K files is not supported with " msg = "Writing Cinema2K or Cinema4K files is not supported with "
msg += 'openjpeg library versions less than 2.0.1.' msg += 'openjpeg library versions less than 2.0.1.'
raise IOError(msg) raise IOError(msg)

View file

@ -10,6 +10,20 @@ import sys
from .config import glymur_config from .config import glymur_config
OPENJP2, OPENJPEG = glymur_config() OPENJP2, OPENJPEG = glymur_config()
def version():
"""Wrapper for opj_version library routine."""
OPENJP2.opj_version.restype = ctypes.c_char_p
library_version = OPENJP2.opj_version()
if sys.hexversion >= 0x03000000:
return library_version.decode('utf-8')
else:
return library_version
if OPENJP2 is not None:
_MAJOR, _MINOR, _PATCH = version().split('.')
else:
_MINOR = 0
ERROR_MSG_LST = [] ERROR_MSG_LST = []
# Map certain atomic OpenJPEG datatypes to the ctypes equivalents. # Map certain atomic OpenJPEG datatypes to the ctypes equivalents.
@ -391,12 +405,10 @@ class ImageCompType(ctypes.Structure):
("factor", ctypes.c_uint32), ("factor", ctypes.c_uint32),
# image component data # image component data
("data", ctypes.POINTER(ctypes.c_int32)), ("data", ctypes.POINTER(ctypes.c_int32))]
# alpha channel
# TODO: exclude for 2.0, 1.5
("alpha", ctypes.c_uint16)]
if _MINOR == '1':
_fields_.append(("alpha", ctypes.c_uint16))
class ImageType(ctypes.Structure): class ImageType(ctypes.Structure):
"""Defines image data and characteristics. """Defines image data and characteristics.

View file

@ -461,7 +461,9 @@ class TestSuite(unittest.TestCase):
def test_NR_DEC_illegalcolortransform_j2k_14_decode(self): def test_NR_DEC_illegalcolortransform_j2k_14_decode(self):
# Stream too short, expected SOT. # Stream too short, expected SOT.
jfile = opj_data_file('input/nonregression/illegalcolortransform.j2k') jfile = opj_data_file('input/nonregression/illegalcolortransform.j2k')
Jp2k(jfile).read() with warnings.catch_warnings():
warnings.simplefilter("ignore")
Jp2k(jfile).read()
self.assertTrue(True) self.assertTrue(True)
def test_NR_DEC_j2k32_j2k_15_decode(self): def test_NR_DEC_j2k32_j2k_15_decode(self):

View file

@ -222,7 +222,6 @@ class TestSuiteWriteCinema(unittest.TestCase):
codestream = j.get_codestream() codestream = j.get_codestream()
self.check_cinema2k_codestream(codestream, (1998, 1080)) self.check_cinema2k_codestream(codestream, (1998, 1080))
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT, @unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
"Cannot read input image without scikit-image/freeimage") "Cannot read input image without scikit-image/freeimage")
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.") @unittest.skipIf(os.name == "nt", "Temporary file issue on window.")