raster scaling: check for division by zero
This commit is contained in:
parent
53c643092c
commit
93a34cc68d
1 changed files with 16 additions and 8 deletions
|
@ -131,19 +131,27 @@ public:
|
||||||
fg_ptr = reinterpret_cast<const value_type*>(base_type::source().next_y());
|
fg_ptr = reinterpret_cast<const value_type*>(base_type::source().next_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
fg /= total_weight;
|
if (total_weight == 0)
|
||||||
if (fg < std::numeric_limits<value_type>::min())
|
|
||||||
{
|
{
|
||||||
span->v = std::numeric_limits<value_type>::min();
|
span->v = *nodata_value_;
|
||||||
}
|
|
||||||
else if (fg > std::numeric_limits<value_type>::max())
|
|
||||||
{
|
|
||||||
span->v = std::numeric_limits<value_type>::max();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
span->v = static_cast<value_type>(fg);
|
fg /= total_weight;
|
||||||
|
if (fg < std::numeric_limits<value_type>::min())
|
||||||
|
{
|
||||||
|
span->v = std::numeric_limits<value_type>::min();
|
||||||
|
}
|
||||||
|
else if (fg > std::numeric_limits<value_type>::max())
|
||||||
|
{
|
||||||
|
span->v = std::numeric_limits<value_type>::max();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
span->v = static_cast<value_type>(fg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
span->a = base_mask;
|
span->a = base_mask;
|
||||||
|
|
||||||
++span;
|
++span;
|
||||||
|
|
Loading…
Reference in a new issue