Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RGB to I;16, I;16L and I;16B conversion
- Loading branch information
Showing
2 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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); | ||||||||||||||||||||||||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
radarhere
Author
Member
|
rgb2i(UINT8 *out_, const UINT8 *in, int xsize) { | |
int x; | |
for (x = 0; x < xsize; x++, in += 4, out_ += 4) { | |
INT32 v = L24(in) >> 16; | |
memcpy(out_, &v, sizeof(v)); | |
} | |
} |
and
Pillow/src/libImaging/Convert.c
Lines 801 to 810 in 2adeb7a
I_I16L(UINT8 *out, const UINT8 *in_, int xsize) { | |
int x, v; | |
for (x = 0; x < xsize; x++, in_ += 4) { | |
INT32 i; | |
memcpy(&i, in_, sizeof(i)); | |
v = CLIP16(i); | |
*out++ = (UINT8)v; | |
*out++ = (UINT8)(v >> 8); | |
} | |
} |
It looks like I did that too simplistically.
But AIUI there's no way that (L24(in) >> 16) could be > 0xff anyway?
Yes, it makes sense that converting RGB, with a maximum of 0xff for each channel, wouldn't be greater than that in an I;16* mode.
I've created #8008
This seems suspect to me (or I'm misunderstanding); we're clipping to 16 bits and then pushing that into a uint8? And then right-shifting this by 8 bits to populate the second half of the 16-bit int will always return 0.
But AIUI there's no way that (L24(in) >> 16) could be > 0xff anyway?