mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Faster ImagingUnpackRGB
This commit is contained in:
parent
07fa92ba5b
commit
b4e226714d
|
@ -467,7 +467,6 @@ typedef void (*ImagingShuffler)(UINT8* out, const UINT8* in, int pixels);
|
||||||
/* Public shufflers */
|
/* Public shufflers */
|
||||||
extern void ImagingPackRGB(UINT8* out, const UINT8* in, int pixels);
|
extern void ImagingPackRGB(UINT8* out, const UINT8* in, int pixels);
|
||||||
extern void ImagingPackBGR(UINT8* out, const UINT8* in, int pixels);
|
extern void ImagingPackBGR(UINT8* out, const UINT8* in, int pixels);
|
||||||
extern void ImagingUnpackRGB(UINT8* out, const UINT8* in, int pixels);
|
|
||||||
extern void ImagingUnpackBGR(UINT8* out, const UINT8* in, int pixels);
|
extern void ImagingUnpackBGR(UINT8* out, const UINT8* in, int pixels);
|
||||||
extern void ImagingUnpackYCC(UINT8* out, const UINT8* in, int pixels);
|
extern void ImagingUnpackYCC(UINT8* out, const UINT8* in, int pixels);
|
||||||
extern void ImagingUnpackYCCA(UINT8* out, const UINT8* in, int pixels);
|
extern void ImagingUnpackYCCA(UINT8* out, const UINT8* in, int pixels);
|
||||||
|
|
|
@ -463,19 +463,30 @@ unpackP4L(UINT8* out, const UINT8* in, int pixels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
#define MAKE_UINT32(u0, u1, u2, u3) (u3 | (u2<<8) | (u1<<16) | (u0<<24))
|
||||||
|
#define CHANNEL_4_MASK 0x000000ff
|
||||||
|
#else
|
||||||
|
#define MAKE_UINT32(u0, u1, u2, u3) (u0 | (u1<<8) | (u2<<16) | (u3<<24))
|
||||||
|
#define CHANNEL_4_MASK 0xff000000
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Unpack to "RGB" image */
|
/* Unpack to "RGB" image */
|
||||||
|
|
||||||
void
|
void
|
||||||
ImagingUnpackRGB(UINT8* out, const UINT8* in, int pixels)
|
ImagingUnpackRGB(UINT8* _out, const UINT8* in, int pixels)
|
||||||
{
|
{
|
||||||
int i;
|
int i = 0;
|
||||||
|
UINT32* out = (UINT32*) _out;
|
||||||
/* RGB triplets */
|
/* RGB triplets */
|
||||||
for (i = 0; i < pixels; i++) {
|
for (; i < pixels-1; i++) {
|
||||||
out[R] = in[0];
|
out[i] = CHANNEL_4_MASK | *(UINT32*)&in[0];
|
||||||
out[G] = in[1];
|
in += 3;
|
||||||
out[B] = in[2];
|
}
|
||||||
out[A] = 255;
|
for (; i < pixels; i++) {
|
||||||
out += 4; in += 3;
|
out[i] = MAKE_UINT32(in[0], in[1], in[2], 255);
|
||||||
|
in += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user