Corrected undefined behaviour

This commit is contained in:
Andrew Murray 2020-05-27 22:43:06 +10:00
parent 8e6e728948
commit 9067e68e64

View File

@ -28,6 +28,7 @@
#include <string.h>
#include <limits.h>
#include "ImagingUtils.h"
#include "QuantOctree.h"
typedef struct _ColorBucket{
@ -152,10 +153,10 @@ static void
avg_color_from_color_bucket(const ColorBucket bucket, Pixel *dst) {
float count = bucket->count;
if (count != 0) {
dst->c.r = (int)(bucket->r / count);
dst->c.g = (int)(bucket->g / count);
dst->c.b = (int)(bucket->b / count);
dst->c.a = (int)(bucket->a / count);
dst->c.r = CLIP8((int)(bucket->r / count));
dst->c.g = CLIP8((int)(bucket->g / count));
dst->c.b = CLIP8((int)(bucket->b / count));
dst->c.a = CLIP8((int)(bucket->a / count));
} else {
dst->c.r = 0;
dst->c.g = 0;