mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Add support for unpacking 16-bit BGRA
This commit is contained in:
parent
b2d6671410
commit
e500dcfb97
|
@ -444,6 +444,8 @@ class TestLibUnpack:
|
|||
self.assert_unpack("RGBA", "RGBA;4B", 2, (17, 0, 34, 0), (51, 0, 68, 0))
|
||||
self.assert_unpack("RGBA", "RGBA;16L", 8, (2, 4, 6, 8), (10, 12, 14, 16))
|
||||
self.assert_unpack("RGBA", "RGBA;16B", 8, (1, 3, 5, 7), (9, 11, 13, 15))
|
||||
self.assert_unpack("RGBA", "BGRA;16L", 8, (6, 4, 2, 8), (14, 12, 10, 16))
|
||||
self.assert_unpack("RGBA", "BGRA;16B", 8, (5, 3, 1, 7), (13, 11, 9, 15))
|
||||
self.assert_unpack(
|
||||
"RGBA", "BGRA", 4, (3, 2, 1, 4), (7, 6, 5, 8), (11, 10, 9, 12)
|
||||
)
|
||||
|
|
|
@ -1065,6 +1065,30 @@ unpackBGRA(UINT8 *_out, const UINT8 *in, int pixels) {
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpackBGRA16L(UINT8 *_out, const UINT8 *in, int pixels) {
|
||||
int i;
|
||||
/* 16-bit RGBA, little-endian order, reversed words */
|
||||
for (i = 0; i < pixels; i++) {
|
||||
UINT32 iv = MAKE_UINT32(in[5], in[3], in[1], in[7]);
|
||||
memcpy(_out, &iv, sizeof(iv));
|
||||
in += 8;
|
||||
_out += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpackBGRA16B(UINT8 *_out, const UINT8 *in, int pixels) {
|
||||
int i;
|
||||
/* 16-bit RGBA, big-endian order, reversed words */
|
||||
for (i = 0; i < pixels; i++) {
|
||||
UINT32 iv = MAKE_UINT32(in[4], in[2], in[0], in[6]);
|
||||
memcpy(_out, &iv, sizeof(iv));
|
||||
in += 8;
|
||||
_out += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unpack to "CMYK" image */
|
||||
|
||||
static void
|
||||
|
@ -1574,6 +1598,8 @@ static struct {
|
|||
{"RGBA", "RGBA;16L", 64, unpackRGBA16L},
|
||||
{"RGBA", "RGBA;16B", 64, unpackRGBA16B},
|
||||
{"RGBA", "BGRA", 32, unpackBGRA},
|
||||
{"RGBA", "BGRA;16L", 64, unpackBGRA16L},
|
||||
{"RGBA", "BGRA;16B", 64, unpackBGRA16B},
|
||||
{"RGBA", "ARGB", 32, unpackARGB},
|
||||
{"RGBA", "ABGR", 32, unpackABGR},
|
||||
{"RGBA", "YCCA;P", 32, ImagingUnpackYCCA},
|
||||
|
|
Loading…
Reference in New Issue
Block a user