Merge the rest of the patches

Now it actually works and passes the test suite
This commit is contained in:
David Joy 2014-06-25 11:42:06 -04:00
parent 433ec1c219
commit 479693417f
2 changed files with 11 additions and 5 deletions

View File

@ -40,7 +40,7 @@ def _parse_codestream(fp):
size = (xsiz - xosiz, ysiz - yosiz)
if csiz == 1:
if len(yrsiz) > 0 and yrsiz[0] > 8:
if (ssiz[0] & 0x7f) > 8:
mode = 'I'
else:
mode = 'L'
@ -99,7 +99,7 @@ def _parse_jp2_header(fp):
= struct.unpack('>IIHBBBB', content)
size = (width, height)
if unkc:
if nc == 1 and bpc > 8:
if nc == 1 and (bpc & 0x7f) > 8:
mode = 'I'
elif nc == 1:
mode = 'L'
@ -115,7 +115,7 @@ def _parse_jp2_header(fp):
if meth == 1:
cs = struct.unpack('>I', content[3:7])[0]
if cs == 16: # sRGB
if nc == 1 and bpc > 8:
if nc == 1 and (bpc & 0x7f) > 8:
mode = 'I'
elif nc == 1:
mode = 'L'
@ -125,7 +125,7 @@ def _parse_jp2_header(fp):
mode = 'RGBA'
break
elif cs == 17: # grayscale
if nc == 1 and bpc > 8:
if nc == 1 and (bpc & 0x7f) > 8:
mode = 'I'
elif nc == 1:
mode = 'L'

View File

@ -290,7 +290,13 @@ j2k_encode_entry(Imaging im, ImagingCodecState state,
components = 1;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_l;
} else if (strcmp (im->mode, "I")){
} else if (strcmp (im->mode, "I;16") == 0){
components = 1;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_i16;
prec = 16;
bpp = 12;
} else if (strcmp (im->mode, "I;16B") == 0){
components = 1;
color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_i16;