mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Added LAB mode, core dumped
This commit is contained in:
parent
ac38d91a2d
commit
1c3932e89f
|
@ -200,6 +200,7 @@ _MODEINFO = {
|
||||||
"RGBA": ("RGB", "L", ("R", "G", "B", "A")),
|
"RGBA": ("RGB", "L", ("R", "G", "B", "A")),
|
||||||
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
|
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
|
||||||
"YCbCr": ("RGB", "L", ("Y", "Cb", "Cr")),
|
"YCbCr": ("RGB", "L", ("Y", "Cb", "Cr")),
|
||||||
|
"LAB": ("RGB", "L", ("L", "A", "B")),
|
||||||
|
|
||||||
# Experimental modes include I;16, I;16L, I;16B, RGBa, BGR;15, and
|
# Experimental modes include I;16, I;16L, I;16B, RGBa, BGR;15, and
|
||||||
# BGR;24. Use these modes only if you know exactly what you're
|
# BGR;24. Use these modes only if you know exactly what you're
|
||||||
|
@ -224,6 +225,7 @@ _MODE_CONV = {
|
||||||
"RGBA": ('|u1', 4),
|
"RGBA": ('|u1', 4),
|
||||||
"CMYK": ('|u1', 4),
|
"CMYK": ('|u1', 4),
|
||||||
"YCbCr": ('|u1', 3),
|
"YCbCr": ('|u1', 3),
|
||||||
|
"LAB": ('|u1', 3),
|
||||||
"I;16": ('=u2', None),
|
"I;16": ('=u2', None),
|
||||||
"I;16B": ('>u2', None),
|
"I;16B": ('>u2', None),
|
||||||
"I;16L": ('<u2', None),
|
"I;16L": ('<u2', None),
|
||||||
|
|
|
@ -97,11 +97,11 @@ def test_lab_color_profile():
|
||||||
|
|
||||||
def test_lab_color():
|
def test_lab_color():
|
||||||
pLab = ImageCms.createProfile("LAB")
|
pLab = ImageCms.createProfile("LAB")
|
||||||
t = ImageCms.buildTransform(SRGB, pLab, "RGB", "RGB")
|
t = ImageCms.buildTransform(SRGB, pLab, "RGB", "LAB")
|
||||||
# need to add a type mapping for some PIL type to TYPE_Lab_8 in findLCMSType,
|
# need to add a type mapping for some PIL type to TYPE_Lab_8 in findLCMSType,
|
||||||
# and have that mapping work back to a PIL mode. (likely RGB)
|
# and have that mapping work back to a PIL mode. (likely RGB)
|
||||||
i = ImageCms.applyTransform(lena(), t)
|
i = ImageCms.applyTransform(lena(), t)
|
||||||
assert_image(i, "RGB", (128, 128))
|
assert_image(i, "LAB", (128, 128))
|
||||||
|
|
||||||
target = Image.open('Tests/images/lena.Lab.tif')
|
target = Image.open('Tests/images/lena.Lab.tif')
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,9 @@ findLCMStype(char* PILmode)
|
||||||
else if (strcmp(PILmode, "YCC") == 0) {
|
else if (strcmp(PILmode, "YCC") == 0) {
|
||||||
return TYPE_YCbCr_8;
|
return TYPE_YCbCr_8;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(PILmode, "LAB") == 0) {
|
||||||
|
return TYPE_Lab_8;
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
/* take a wild guess... but you probably should fail instead. */
|
/* take a wild guess... but you probably should fail instead. */
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
||||||
* RGBA 4 R, G, B, A
|
* RGBA 4 R, G, B, A
|
||||||
* CMYK 4 C, M, Y, K
|
* CMYK 4 C, M, Y, K
|
||||||
* YCbCr 4 Y, Cb, Cr, -
|
* YCbCr 4 Y, Cb, Cr, -
|
||||||
|
* Lab 4 L, a, b, -
|
||||||
*
|
*
|
||||||
* experimental modes (incomplete):
|
* experimental modes (incomplete):
|
||||||
* LA 4 L, -, -, A
|
* LA 4 L, -, -, A
|
||||||
|
|
|
@ -526,6 +526,12 @@ static struct {
|
||||||
{"YCbCr", "Cb", 8, band1},
|
{"YCbCr", "Cb", 8, band1},
|
||||||
{"YCbCr", "Cr", 8, band2},
|
{"YCbCr", "Cr", 8, band2},
|
||||||
|
|
||||||
|
/* LAB Color */
|
||||||
|
{"LAB", "LAB", 24, ImagingPackRGB},
|
||||||
|
{"LAB", "L", 8, band0},
|
||||||
|
{"LAB", "B", 8, band1},
|
||||||
|
{"LAB", "B", 8, band2},
|
||||||
|
|
||||||
/* integer */
|
/* integer */
|
||||||
{"I", "I", 32, copy4},
|
{"I", "I", 32, copy4},
|
||||||
{"I", "I;16B", 16, packI16B},
|
{"I", "I;16B", 16, packI16B},
|
||||||
|
|
|
@ -178,6 +178,12 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize,
|
||||||
im->pixelsize = 4;
|
im->pixelsize = 4;
|
||||||
im->linesize = xsize * 4;
|
im->linesize = xsize * 4;
|
||||||
|
|
||||||
|
} else if (strcmp(mode, "LAB") == 0) {
|
||||||
|
/* 24-bit color, luminance, + 2 color channels */
|
||||||
|
im->bands = 3;
|
||||||
|
im->pixelsize = 4;
|
||||||
|
im->linesize = xsize * 4;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
free(im);
|
free(im);
|
||||||
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user