Fix invalid memory usage when using Image.convert
(cherry picked from commit 34c1a2beaa
)
This commit is contained in:
parent
d700434b7d
commit
45e55d51de
|
@ -376,7 +376,7 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
|
||||||
const uint8_t *rofs = &p_src[((y * p_width) + x) * (read_bytes + (read_alpha ? 1 : 0))];
|
const uint8_t *rofs = &p_src[((y * p_width) + x) * (read_bytes + (read_alpha ? 1 : 0))];
|
||||||
uint8_t *wofs = &p_dst[((y * p_width) + x) * (write_bytes + (write_alpha ? 1 : 0))];
|
uint8_t *wofs = &p_dst[((y * p_width) + x) * (write_bytes + (write_alpha ? 1 : 0))];
|
||||||
|
|
||||||
uint8_t rgba[4];
|
uint8_t rgba[4] = { 0, 0, 0, 255 };
|
||||||
|
|
||||||
if (read_gray) {
|
if (read_gray) {
|
||||||
rgba[0] = rofs[0];
|
rgba[0] = rofs[0];
|
||||||
|
@ -394,7 +394,7 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
|
||||||
|
|
||||||
if (write_gray) {
|
if (write_gray) {
|
||||||
//TODO: not correct grayscale, should use fixed point version of actual weights
|
//TODO: not correct grayscale, should use fixed point version of actual weights
|
||||||
wofs[0] = uint8_t((uint16_t(rofs[0]) + uint16_t(rofs[1]) + uint16_t(rofs[2])) / 3);
|
wofs[0] = uint8_t((uint16_t(rgba[0]) + uint16_t(rgba[1]) + uint16_t(rgba[2])) / 3);
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t i = 0; i < write_bytes; i++) {
|
for (uint32_t i = 0; i < write_bytes; i++) {
|
||||||
wofs[i] = rgba[i];
|
wofs[i] = rgba[i];
|
||||||
|
|
Loading…
Reference in New Issue