Merge pull request #7918 from radarhere/convert

This commit is contained in:
Hugo van Kemenade 2024-03-30 11:12:05 +02:00 committed by GitHub
commit c5eb7c7c29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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},