Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created May 24, 2012 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/2784202 to your computer and use it in GitHub Desktop.
Save springmeyer/2784202 to your computer and use it in GitHub Desktop.
customization to agg 2.4 span_image_resample_rgba_affine
diff --git a/include/mapnik/span_image_filter.hpp b/include/mapnik/span_image_filter.hpp
index e32b5a2..a4f8159 100644
--- a/include/mapnik/span_image_filter.hpp
+++ b/include/mapnik/span_image_filter.hpp
@@ -29,7 +29,7 @@ using namespace agg;
template<class Source>
class span_image_resample_rgba_affine :
- public span_image_resample_affine<Source>
+public span_image_resample_affine<Source>
{
public:
typedef Source source_type;
@@ -71,7 +71,7 @@ public:
(diameter * base_type::m_rx + image_subpixel_mask) >>
image_subpixel_shift;
- const boost::int16_t* weight_array = base_type::filter().weight_array();
+ const int16* weight_array = base_type::filter().weight_array();
do
{
@@ -108,8 +108,7 @@ public:
fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight;
- fg[3] += *fg_ptr * weight;
-
+ fg[3] += *fg_ptr++ * weight;
total_weight += weight;
x_hr += base_type::m_rx_inv;
if(x_hr >= filter_scale) break;
@@ -120,30 +119,20 @@ public:
fg_ptr = (const value_type*)base_type::source().next_y();
}
- if (total_weight)
- {
- fg[3] /= total_weight;
fg[0] /= total_weight;
fg[1] /= total_weight;
fg[2] /= total_weight;
+ fg[3] /= total_weight;
if(fg[0] < 0) fg[0] = 0;
if(fg[1] < 0) fg[1] = 0;
if(fg[2] < 0) fg[2] = 0;
if(fg[3] < 0) fg[3] = 0;
- }
- else
- {
- fg[0] = 0;
- fg[1] = 0;
- fg[2] = 0;
- fg[3] = 0;
- }
- if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask;
- if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask;
- if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask;
if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask;
+ if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A];
+ if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A];
+ if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A];
span->r = (value_type)fg[order_type::R];
span->g = (value_type)fg[order_type::G];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment