mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-11 17:56:18 +03:00
Merge pull request #7918 from radarhere/convert
This commit is contained in:
commit
c5eb7c7c29
|
@ -263,8 +263,6 @@ def hopper(mode: str | None = None, cache: dict[str, Image.Image] = {}) -> Image
|
||||||
if im is None:
|
if im is None:
|
||||||
if mode == "F":
|
if mode == "F":
|
||||||
im = hopper("L").convert(mode)
|
im = hopper("L").convert(mode)
|
||||||
elif mode[:4] == "I;16":
|
|
||||||
im = hopper("I").convert(mode)
|
|
||||||
else:
|
else:
|
||||||
im = hopper().convert(mode)
|
im = hopper().convert(mode)
|
||||||
cache[mode] = im
|
cache[mode] = im
|
||||||
|
|
|
@ -250,6 +250,26 @@ rgb2i(UINT8 *out_, const UINT8 *in, int xsize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rgb2i16l(UINT8 *out_, const UINT8 *in, int xsize) {
|
||||||
|
int x;
|
||||||
|
for (x = 0; x < xsize; x++, in += 4) {
|
||||||
|
UINT8 v = CLIP16(L24(in) >> 16);
|
||||||
|
*out_++ = v;
|
||||||
|
*out_++ = v >> 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rgb2i16b(UINT8 *out_, const UINT8 *in, int xsize) {
|
||||||
|
int x;
|
||||||
|
for (x = 0; x < xsize; x++, in += 4) {
|
||||||
|
UINT8 v = CLIP16(L24(in) >> 16);
|
||||||
|
*out_++ = v >> 8;
|
||||||
|
*out_++ = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgb2f(UINT8 *out_, const UINT8 *in, int xsize) {
|
rgb2f(UINT8 *out_, const UINT8 *in, int xsize) {
|
||||||
int x;
|
int x;
|
||||||
|
@ -944,6 +964,9 @@ static struct {
|
||||||
{"RGB", "LA", rgb2la},
|
{"RGB", "LA", rgb2la},
|
||||||
{"RGB", "La", rgb2la},
|
{"RGB", "La", rgb2la},
|
||||||
{"RGB", "I", rgb2i},
|
{"RGB", "I", rgb2i},
|
||||||
|
{"RGB", "I;16", rgb2i16l},
|
||||||
|
{"RGB", "I;16L", rgb2i16l},
|
||||||
|
{"RGB", "I;16B", rgb2i16b},
|
||||||
{"RGB", "F", rgb2f},
|
{"RGB", "F", rgb2f},
|
||||||
{"RGB", "BGR;15", rgb2bgr15},
|
{"RGB", "BGR;15", rgb2bgr15},
|
||||||
{"RGB", "BGR;16", rgb2bgr16},
|
{"RGB", "BGR;16", rgb2bgr16},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user