From 4458787f5ec99820eea865049d3eaa3189403079 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 14 Oct 2013 22:47:27 -0700 Subject: [PATCH] Back to RGBx format, 3 bands in 4 bytes. Tests for internal consistency --- Tests/images/lab.tif | Bin 0 -> 24364 bytes Tests/test_image_lab.py | 25 +++++++++++++++++++++++++ libImaging/Pack.c | 2 +- libImaging/Storage.c | 5 ++--- libImaging/Unpack.c | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 Tests/images/lab.tif create mode 100644 Tests/test_image_lab.py diff --git a/Tests/images/lab.tif b/Tests/images/lab.tif new file mode 100644 index 0000000000000000000000000000000000000000..7dab9b2badda29bc0be9cc72139661865f427178 GIT binary patch literal 24364 zcmeHPTW}lI89uUnkK@FN11Y5)MG(StWJ|lN+X_X&mMo%Q8_ZDuiiKjBdCQLO= zc?>--evFU@*y20Y~BcMy^VoO{?qLPrRBI!TD~h}p+;V8k`b{_g+JIN5)U5bJZUtggzw z!n&%f&2_cmOD_w)yi`)^v`+XCCnUH~f(!e2E+NDc5soBJY&4|Od0F?Z$`z%4-2eA) zf7kC*%E$e8NAjV3BQ38hCogOA^5s*-(&h6dvFtyQ8c%K{HfoKUtV_O)TD9IxY#jGX zwCx07iVpgHj72|x+;13lHec|iRZaGVXStbDNQnBv(OEtgjq#y?FR#{pS$WmRi9S9Q ziurgx0aL?*&%FGpaX?9}yp~wXWX(2FJMLfC^+qBXym;~A>_uT#)habkTsQ*Yj4D6#Zpv?fcssufkWn%XgFl2k_r`<8=}ZIYakbU8)iYlaKW zaN(j6UtD}96ib9cHYEmUmyWzzR@N@{*Ae0DI&7TXIuLbbNtbq|#m;*L1|y%}c{pmd zo)O9C6B)JCq5+l5q*^VdoQP(lbAmW0M&^X@g1~X}VS!(m7x{2Jp5`MQ$GqAp*Xa|` za`mPz)l0IaGZxyNPMh4j?H@WB`n!ixdc&1s6Q?x=o{{KmO`+pGI9taV?d+1=RI4q< zj|_t=$kEaiwUfI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eK2zOu*7To7QIK)5j=rpz9nWg7n z6>eR9Nqg|I^zxxnGyK}oVQRq0ZINeRfDupKSYB9(>hjBN6SlYD*p>;KzakS}*5(vB zLEb1nmOFZ4^Or0Nk1%JhphUzGvX9J>GEtGhW#S_RvJP0s-DD6JCvxy@ID8~cmWeyL5wCU|<>IGM{X+vgq0;%kY%>DXEpXa^`4 zOT`~J^ElH2CH<4QCB+ttY_lU%~ZDuvAZJOvU?ThKU%|_a%E ANB{r; literal 0 HcmV?d00001 diff --git a/Tests/test_image_lab.py b/Tests/test_image_lab.py new file mode 100644 index 000000000..bbc59a2c7 --- /dev/null +++ b/Tests/test_image_lab.py @@ -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) + + diff --git a/libImaging/Pack.c b/libImaging/Pack.c index f8470fd73..d38d9e5e3 100644 --- a/libImaging/Pack.c +++ b/libImaging/Pack.c @@ -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}, diff --git a/libImaging/Storage.c b/libImaging/Storage.c index f8248a079..50259be47 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -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); diff --git a/libImaging/Unpack.c b/libImaging/Unpack.c index 1330f1434..e05728f49 100644 --- a/libImaging/Unpack.c +++ b/libImaging/Unpack.c @@ -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},