From cb9440a2f5f6204257ea167cb418f00a4cf11dd8 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Fri, 11 Oct 2013 23:31:26 -0700 Subject: [PATCH] packing into 24bit --- libImaging/Pack.c | 2 +- libImaging/Storage.c | 6 ++++-- libImaging/Unpack.c | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libImaging/Pack.c b/libImaging/Pack.c index d38d9e5e3..f8470fd73 100644 --- a/libImaging/Pack.c +++ b/libImaging/Pack.c @@ -527,7 +527,7 @@ static struct { {"YCbCr", "Cr", 8, band2}, /* LAB Color */ - {"LAB", "LAB", 24, ImagingPackRGB}, + {"LAB", "LAB", 24, copy3}, {"LAB", "L", 8, band0}, {"LAB", "A", 8, band1}, {"LAB", "B", 8, band2}, diff --git a/libImaging/Storage.c b/libImaging/Storage.c index 1cfcf0913..f8248a079 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -180,9 +180,11 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize, } else if (strcmp(mode, "LAB") == 0) { /* 24-bit color, luminance, + 2 color channels */ + /* L is uint8, a,b are int8 */ im->bands = 3; - im->pixelsize = 4; - im->linesize = xsize * 4; + im->pixelsize = 3; + im->linesize = (xsize*4 + 3) & -4; + im->type = IMAGING_TYPE_SPECIAL; } else { free(im); diff --git a/libImaging/Unpack.c b/libImaging/Unpack.c index 0d0cad292..1330f1434 100644 --- a/libImaging/Unpack.c +++ b/libImaging/Unpack.c @@ -674,6 +674,13 @@ copy2(UINT8* out, const UINT8* in, int pixels) memcpy(out, in, pixels*2); } +static void +copy3(UINT8* out, const UINT8* in, int pixels) +{ + /* LAB triples, 24bit */ + memcpy(out, in, 3 * pixels); +} + static void copy4(UINT8* out, const UINT8* in, int pixels) { @@ -958,7 +965,7 @@ static struct { {"YCbCr", "YCbCrK", 32, copy4}, /* LAB Color */ - {"LAB", "LAB", 24, ImagingUnpackRGB}, + {"LAB", "LAB", 24, copy3}, {"LAB", "L", 8, band0}, {"LAB", "A", 8, band1}, {"LAB", "B", 8, band2},