mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +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 mode == "F":
|
||||
im = hopper("L").convert(mode)
|
||||
elif mode[:4] == "I;16":
|
||||
im = hopper("I").convert(mode)
|
||||
else:
|
||||
im = hopper().convert(mode)
|
||||
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
|
||||
rgb2f(UINT8 *out_, const UINT8 *in, int xsize) {
|
||||
int x;
|
||||
|
@ -944,6 +964,9 @@ static struct {
|
|||
{"RGB", "LA", rgb2la},
|
||||
{"RGB", "La", rgb2la},
|
||||
{"RGB", "I", rgb2i},
|
||||
{"RGB", "I;16", rgb2i16l},
|
||||
{"RGB", "I;16L", rgb2i16l},
|
||||
{"RGB", "I;16B", rgb2i16b},
|
||||
{"RGB", "F", rgb2f},
|
||||
{"RGB", "BGR;15", rgb2bgr15},
|
||||
{"RGB", "BGR;16", rgb2bgr16},
|
||||
|
|
Loading…
Reference in New Issue
Block a user