Skip to content

Commit ef8cec6

Browse files
authored
Merge pull request #6256 from radarhere/furthestV
Ensure that furthest v is set in quantize2
2 parents 1a28662 + 44494a1 commit ef8cec6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libImaging/Quant.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ quantize(
15191519

15201520
typedef struct {
15211521
Pixel new;
1522-
Pixel furthest;
1522+
uint32_t furthestV;
15231523
uint32_t furthestDistance;
15241524
int secondPixel;
15251525
} DistanceData;
@@ -1536,7 +1536,7 @@ compute_distances(const HashTable *h, const Pixel pixel, uint32_t *dist, void *u
15361536
}
15371537
if (oldDist > data->furthestDistance) {
15381538
data->furthestDistance = oldDist;
1539-
data->furthest.v = pixel.v;
1539+
data->furthestV = pixel.v;
15401540
}
15411541
}
15421542

@@ -1577,10 +1577,11 @@ quantize2(
15771577
data.new.c.b = (int)(.5 + (double)mean[2] / (double)nPixels);
15781578
for (i = 0; i < nQuantPixels; i++) {
15791579
data.furthestDistance = 0;
1580+
data.furthestV = pixelData[0].v;
15801581
data.secondPixel = (i == 1) ? 1 : 0;
15811582
hashtable_foreach_update(h, compute_distances, &data);
1582-
p[i].v = data.furthest.v;
1583-
data.new.v = data.furthest.v;
1583+
p[i].v = data.furthestV;
1584+
data.new.v = data.furthestV;
15841585
}
15851586
hashtable_free(h);
15861587

0 commit comments

Comments
 (0)