mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +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")),
|
||||
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
|
||||
"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
|
||||
# BGR;24. Use these modes only if you know exactly what you're
|
||||
|
@ -224,6 +225,7 @@ _MODE_CONV = {
|
|||
"RGBA": ('|u1', 4),
|
||||
"CMYK": ('|u1', 4),
|
||||
"YCbCr": ('|u1', 3),
|
||||
"LAB": ('|u1', 3),
|
||||
"I;16": ('=u2', None),
|
||||
"I;16B": ('>u2', None),
|
||||
"I;16L": ('<u2', None),
|
||||
|
|
|
@ -97,12 +97,12 @@ def test_lab_color_profile():
|
|||
|
||||
def test_lab_color():
|
||||
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,
|
||||
# and have that mapping work back to a PIL mode. (likely RGB)
|
||||
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')
|
||||
|
||||
assert_image_similar(i,target, 1)
|
||||
assert_image_similar(i, target, 1)
|
||||
|
|
|
@ -236,6 +236,9 @@ findLCMStype(char* PILmode)
|
|||
else if (strcmp(PILmode, "YCC") == 0) {
|
||||
return TYPE_YCbCr_8;
|
||||
}
|
||||
else if (strcmp(PILmode, "LAB") == 0) {
|
||||
return TYPE_Lab_8;
|
||||
}
|
||||
|
||||
else {
|
||||
/* take a wild guess... but you probably should fail instead. */
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
* RGBA 4 R, G, B, A
|
||||
* CMYK 4 C, M, Y, K
|
||||
* YCbCr 4 Y, Cb, Cr, -
|
||||
* Lab 4 L, a, b, -
|
||||
*
|
||||
* experimental modes (incomplete):
|
||||
* LA 4 L, -, -, A
|
||||
|
|
|
@ -526,6 +526,12 @@ static struct {
|
|||
{"YCbCr", "Cb", 8, band1},
|
||||
{"YCbCr", "Cr", 8, band2},
|
||||
|
||||
/* LAB Color */
|
||||
{"LAB", "LAB", 24, ImagingPackRGB},
|
||||
{"LAB", "L", 8, band0},
|
||||
{"LAB", "B", 8, band1},
|
||||
{"LAB", "B", 8, band2},
|
||||
|
||||
/* integer */
|
||||
{"I", "I", 32, copy4},
|
||||
{"I", "I;16B", 16, packI16B},
|
||||
|
|
|
@ -178,9 +178,15 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize,
|
|||
im->pixelsize = 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 {
|
||||
free(im);
|
||||
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
||||
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
||||
}
|
||||
|
||||
/* Setup image descriptor */
|
||||
|
|
Loading…
Reference in New Issue
Block a user