# HG changeset patch # User Fredrik Lundh # Date 1237270439 -3600 # Node ID 64f9636f4d921ea0612f65fddde12fa8666aa6eb # Parent c5ae18013ecb557b9600c3ec7a5a9194f0d788de Fixed I;16B to L/I conversions (note to self: don't claim that something works in the logs if it's not covered by automated tests ;-) diff -r c5ae18013ecb557b9600c3ec7a5a9194f0d788de -r 64f9636f4d921ea0612f65fddde12fa8666aa6eb Tests/test_mode_i16.py --- a/Tests/test_mode_i16.py Tue Mar 17 06:46:30 2009 +0100 +++ b/Tests/test_mode_i16.py Tue Mar 17 07:13:59 2009 +0100 @@ -11,7 +11,11 @@ for x in range(im1.size[0]): xy = x, y if pix1[xy] != pix2[xy]: - failure("got %r at %s, expected %r" % (pix1[xy], xy, pix[xy])) + failure( + "got %r from mode %s at %s, expected %r" % + (pix1[xy], im1.mode, xy, pix2[xy]) + ) + return success() def test_basic(): @@ -84,3 +88,16 @@ assert_equal(tostring("I;16"), "\x01\x00") assert_equal(tostring("I;16B"), "\x00\x01") assert_equal(tostring("I"), "\x01\x00\x00\x00") + + +def test_convert(): + + im = lena("I") + + verify(im.convert("I;16")) + verify(im.convert("I;16").convert("L")) + verify(im.convert("I;16").convert("I")) + + verify(im.convert("I;16B")) + verify(im.convert("I;16B").convert("L")) + verify(im.convert("I;16B").convert("I")) diff -r c5ae18013ecb557b9600c3ec7a5a9194f0d788de -r 64f9636f4d921ea0612f65fddde12fa8666aa6eb libImaging/Convert.c --- a/libImaging/Convert.c Tue Mar 17 06:46:30 2009 +0100 +++ b/libImaging/Convert.c Tue Mar 17 07:13:59 2009 +0100 @@ -455,7 +455,7 @@ /* ------------------------- */ static void -i_i16l(UINT8* out, const UINT8* in_, int xsize) +I_I16L(UINT8* out, const UINT8* in_, int xsize) { int x, v; INT32* in = (INT32*) in_; @@ -467,7 +467,7 @@ } static void -i_i16b(UINT8* out, const UINT8* in_, int xsize) +I_I16B(UINT8* out, const UINT8* in_, int xsize) { int x, v; INT32* in = (INT32*) in_; @@ -480,7 +480,7 @@ static void -i16l_i(UINT8* out_, const UINT8* in, int xsize) +I16L_I(UINT8* out_, const UINT8* in, int xsize) { int x; INT32* out = (INT32*) out_; @@ -490,7 +490,7 @@ static void -i16b_i(UINT8* out_, const UINT8* in, int xsize) +I16B_I(UINT8* out_, const UINT8* in, int xsize) { int x; INT32* out = (INT32*) out_; @@ -499,7 +499,7 @@ } static void -l_i16l(UINT8* out, const UINT8* in, int xsize) +L_I16L(UINT8* out, const UINT8* in, int xsize) { int x; for (x = 0; x < xsize; x++, in++) { @@ -509,7 +509,7 @@ } static void -l_i16b(UINT8* out, const UINT8* in, int xsize) +L_I16B(UINT8* out, const UINT8* in, int xsize) { int x; for (x = 0; x < xsize; x++, in++) { @@ -519,7 +519,7 @@ } static void -i16l_l(UINT8* out, const UINT8* in, int xsize) +I16L_L(UINT8* out, const UINT8* in, int xsize) { int x; for (x = 0; x < xsize; x++, in += 2) @@ -530,7 +530,7 @@ } static void -i16b_l(UINT8* out, const UINT8* in, int xsize) +I16B_L(UINT8* out, const UINT8* in, int xsize) { int x; for (x = 0; x < xsize; x++, in += 2) @@ -615,20 +615,20 @@ { "YCbCr", "L", ycbcr2l }, { "YCbCr", "RGB", ImagingConvertYCbCr2RGB }, - { "I", "I;16", i_i16l }, - { "I;16", "I", i16l_i }, - { "L", "I;16", l_i16l }, - { "I;16", "L", i16l_l }, + { "I", "I;16", I_I16L }, + { "I;16", "I", I16L_I }, + { "L", "I;16", L_I16L }, + { "I;16", "L", I16L_L }, - { "I", "I;16L", i_i16l }, - { "I;16L", "I", i16l_i }, - { "I", "I;16B", i_i16b }, - { "I;16B", "I", i16b_i }, + { "I", "I;16L", I_I16L }, + { "I;16L", "I", I16L_I }, + { "I", "I;16B", I_I16B }, + { "I;16B", "I", I16B_I }, - { "L", "I;16L", i_i16l }, - { "I;16L", "L", i16l_i }, - { "L", "I;16B", i_i16b }, - { "I;16B", "L", i16b_i }, + { "L", "I;16L", L_I16L }, + { "I;16L", "L", I16L_L }, + { "L", "I;16B", L_I16B }, + { "I;16B", "L", I16B_L }, { NULL } };