Back to RGBx format, 3 bands in 4 bytes. Tests for internal consistency

This commit is contained in:
wiredfool 2013-10-14 22:47:27 -07:00
parent 215b61aadf
commit 4458787f5e
5 changed files with 29 additions and 5 deletions

BIN
Tests/images/lab.tif Normal file

Binary file not shown.

25
Tests/test_image_lab.py Normal file
View File

@ -0,0 +1,25 @@
from tester import *
from PIL import Image
def test_sanity():
i = Image.open('Tests/images/lab.tif')
bits = i.load()
assert_equal(i.mode, 'LAB')
assert_equal(i.getbands(), ('L','A', 'B'))
k = i.getpixel((0,0))
assert_equal(k, (255,0,0))
L = i.getdata(0)
a = i.getdata(1)
b = i.getdata(2)
assert_equal(list(L), [255]*100)
assert_equal(list(a), [0]*100)
assert_equal(list(b), [0]*100)

View File

@ -527,7 +527,7 @@ static struct {
{"YCbCr", "Cr", 8, band2},
/* LAB Color */
{"LAB", "LAB", 24, copy3},
{"LAB", "LAB", 24, ImagingPackRGB},
{"LAB", "L", 8, band0},
{"LAB", "A", 8, band1},
{"LAB", "B", 8, band2},

View File

@ -182,9 +182,8 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize,
/* 24-bit color, luminance, + 2 color channels */
/* L is uint8, a,b are int8 */
im->bands = 3;
im->pixelsize = 3;
im->linesize = (xsize*4 + 3) & -4;
im->type = IMAGING_TYPE_SPECIAL;
im->pixelsize = 4;
im->linesize = xsize * 4;
} else {
free(im);

View File

@ -965,7 +965,7 @@ static struct {
{"YCbCr", "YCbCrK", 32, copy4},
/* LAB Color */
{"LAB", "LAB", 24, copy3},
{"LAB", "LAB", 24, ImagingUnpackRGB},
{"LAB", "L", 8, band0},
{"LAB", "A", 8, band1},
{"LAB", "B", 8, band2},