From b1b714bb5c36470a31bc885304bf116b71d1c804 Mon Sep 17 00:00:00 2001 From: Dmitry Karasik Date: Mon, 22 Jul 2024 20:39:08 +0200 Subject: [PATCH] minor optimization --- img/utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/img/utils.c b/img/utils.c index 323de35a..3924f365 100644 --- a/img/utils.c +++ b/img/utils.c @@ -159,8 +159,11 @@ void img_multiply_alpha( Byte * src, Byte * alpha, int alpha_step, Byte * dst, int bytes) { if ( alpha_step == 0 ) { - while (bytes--) - *(dst++) = *(src++) * *(alpha ) / 255.0 + .5; + if ( *alpha < 255 ) { + while (bytes--) + *(dst++) = *(src++) * *(alpha ) / 255.0 + .5; + } else if ( src != dst ) + memcpy( dst, src, bytes); } else { while (bytes--) *(dst++) = *(src++) * *(alpha++) / 255.0 + .5;