mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Storage, packing and access for HSV format images
This commit is contained in:
parent
ee4793a806
commit
625ff24358
|
@ -220,6 +220,7 @@ _MODEINFO = {
|
||||||
"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")),
|
"LAB": ("RGB", "L", ("L", "A", "B")),
|
||||||
|
"HSV": ("RGB", "L", ("H", "S", "V")),
|
||||||
|
|
||||||
# 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
|
||||||
|
|
|
@ -261,6 +261,7 @@ mode_map = {'1': _PyAccess8,
|
||||||
'PA': _PyAccess32_2,
|
'PA': _PyAccess32_2,
|
||||||
'RGB': _PyAccess32_3,
|
'RGB': _PyAccess32_3,
|
||||||
'LAB': _PyAccess32_3,
|
'LAB': _PyAccess32_3,
|
||||||
|
'HSV': _PyAccess32_3,
|
||||||
'YCbCr': _PyAccess32_3,
|
'YCbCr': _PyAccess32_3,
|
||||||
'RGBA': _PyAccess32_4,
|
'RGBA': _PyAccess32_4,
|
||||||
'RGBa': _PyAccess32_4,
|
'RGBa': _PyAccess32_4,
|
||||||
|
|
|
@ -9,6 +9,7 @@ modes = [
|
||||||
"RGB", "RGBA", "RGBa", "RGBX",
|
"RGB", "RGBA", "RGBa", "RGBX",
|
||||||
"CMYK",
|
"CMYK",
|
||||||
"YCbCr",
|
"YCbCr",
|
||||||
|
"LAB", "HSV",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include "Imaging.h"
|
#include "Imaging.h"
|
||||||
|
|
||||||
/* use Tests/make_hash.py to calculate these values */
|
/* use Tests/make_hash.py to calculate these values */
|
||||||
#define ACCESS_TABLE_SIZE 21
|
#define ACCESS_TABLE_SIZE 27
|
||||||
#define ACCESS_TABLE_HASH 30197
|
#define ACCESS_TABLE_HASH 3078
|
||||||
|
|
||||||
static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE];
|
static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE];
|
||||||
|
|
||||||
|
@ -238,6 +238,7 @@ ImagingAccessInit()
|
||||||
ADD("CMYK", line_32, get_pixel_32, put_pixel_32);
|
ADD("CMYK", line_32, get_pixel_32, put_pixel_32);
|
||||||
ADD("YCbCr", line_32, get_pixel_32, put_pixel_32);
|
ADD("YCbCr", line_32, get_pixel_32, put_pixel_32);
|
||||||
ADD("LAB", line_32, get_pixel_32, put_pixel_32);
|
ADD("LAB", line_32, get_pixel_32, put_pixel_32);
|
||||||
|
ADD("HSV", line_32, get_pixel_32, put_pixel_32);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImagingAccess
|
ImagingAccess
|
||||||
|
|
|
@ -566,6 +566,12 @@ static struct {
|
||||||
{"LAB", "A", 8, band1},
|
{"LAB", "A", 8, band1},
|
||||||
{"LAB", "B", 8, band2},
|
{"LAB", "B", 8, band2},
|
||||||
|
|
||||||
|
/* HSV */
|
||||||
|
{"HSV", "HSV", 24, ImagingPackRGB},
|
||||||
|
{"HSV", "H", 8, band0},
|
||||||
|
{"HSV", "S", 8, band1},
|
||||||
|
{"HSV", "V", 8, band2},
|
||||||
|
|
||||||
/* integer */
|
/* integer */
|
||||||
{"I", "I", 32, copy4},
|
{"I", "I", 32, copy4},
|
||||||
{"I", "I;16B", 16, packI16B},
|
{"I", "I;16B", 16, packI16B},
|
||||||
|
|
|
@ -186,6 +186,13 @@ 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, "HSV") == 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;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
free(im);
|
free(im);
|
||||||
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
return (Imaging) ImagingError_ValueError("unrecognized mode");
|
||||||
|
|
|
@ -1159,6 +1159,12 @@ static struct {
|
||||||
{"LAB", "A", 8, band1},
|
{"LAB", "A", 8, band1},
|
||||||
{"LAB", "B", 8, band2},
|
{"LAB", "B", 8, band2},
|
||||||
|
|
||||||
|
/* HSV Color */
|
||||||
|
{"HSV", "HSV", 24, ImagingUnpackRGB},
|
||||||
|
{"HSV", "H", 8, band0},
|
||||||
|
{"HSV", "S", 8, band1},
|
||||||
|
{"HSV", "V", 8, band2},
|
||||||
|
|
||||||
/* integer variations */
|
/* integer variations */
|
||||||
{"I", "I", 32, copy4},
|
{"I", "I", 32, copy4},
|
||||||
{"I", "I;8", 8, unpackI8},
|
{"I", "I;8", 8, unpackI8},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user