raster scaling: check for division by zero

This commit is contained in:
Jiri Drbalek 2016-03-04 15:13:55 +00:00 committed by artemp
parent 53c643092c
commit 93a34cc68d

View file

@ -131,6 +131,12 @@ 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());
} }
if (total_weight == 0)
{
span->v = *nodata_value_;
}
else
{
fg /= total_weight; fg /= total_weight;
if (fg < std::numeric_limits<value_type>::min()) if (fg < std::numeric_limits<value_type>::min())
{ {
@ -144,6 +150,8 @@ public:
{ {
span->v = static_cast<value_type>(fg); span->v = static_cast<value_type>(fg);
} }
}
span->a = base_mask; span->a = base_mask;
++span; ++span;