Fixed random image generation, and now it shows a proper (giant) perf difference between images that take longer for Zone's FILTERED_PIXELS detection to deal with.

This commit is contained in:
Mike Dussault 2021-10-11 14:21:08 -07:00
parent 9370cfe25c
commit e4542de6f2
1 changed files with 7 additions and 3 deletions

View File

@ -55,12 +55,16 @@ std::shared_ptr<Image> GenerateRandomImage(
ZM_COLOUR_GRAY8,
ZM_SUBPIX_ORDER_NONE);
const int range = maxVal - minVal + 1;
const int randMax = RAND_MAX;
const int range = maxVal - minVal;
for (int y=0; y < height; y++)
{
uint8_t *row = (uint8_t*)image->Buffer(0, y);
for (int x=0; x < width; x++)
row[x] = (rand() * range) / RAND_MAX + minVal;
for (int x=0; x < width; x++) {
uint64_t randVal = rand();
row[x] = (uint8_t)((randVal * range) / randMax + minVal);
}
}
return std::shared_ptr<Image>(image);