Code

Convolve Matrix Filter:
authortavmjong <tavmjong@users.sourceforge.net>
Sun, 30 Sep 2007 20:56:15 +0000 (20:56 +0000)
committertavmjong <tavmjong@users.sourceforge.net>
Sun, 30 Sep 2007 20:56:15 +0000 (20:56 +0000)
  Enable and use preserveAlpha attribute.
  Increase range for divisor attribute.

src/display/nr-filter-convolve-matrix.cpp
src/sp-feconvolvematrix.cpp
src/ui/dialog/filter-effects-dialog.cpp

index 562f3ffc470e1c83bc4fca2c01640de26a9854c6..6adf9c9a52483072f97dcee5555c92cec4516985 100644 (file)
@@ -69,6 +69,9 @@ int FilterConvolveMatrix::render(FilterSlot &slot, Matrix const &trans) {
             out_data[4*( x + width*y )+1] = CLAMP_D_TO_U8(result_G / divisor + bias);
             out_data[4*( x + width*y )+2] = CLAMP_D_TO_U8(result_B / divisor + bias);
             out_data[4*( x + width*y )+3] = CLAMP_D_TO_U8(result_A / divisor + bias);
+            if( preserveAlpha ) {
+                out_data[4*( x + width*y )+3] = in_data[4*( x + width*y )+3];
+            }
         }
     }
 
index 5a3edfc50f8512be66f4c99d23dd02f5ba3577ba..84a1a8682a7ac217f05aa3c47f66288865d667e4 100644 (file)
@@ -321,6 +321,7 @@ static void sp_feConvolveMatrix_build_renderer(SPFilterPrimitive *primitive, NR:
     nr_convolve->set_kernelMatrix(sp_convolve->kernelMatrix);
     nr_convolve->set_divisor(sp_convolve->divisor);
     nr_convolve->set_bias(sp_convolve->bias);
+    nr_convolve->set_preserveAlpha(sp_convolve->preserveAlpha);
 
 }
 /*
index dc6fc06bb7eae81c5118a3efbfe7737bfb442260..fa64054b0535f92a552df2e03d3ca14d72459155 100644 (file)
@@ -1967,9 +1967,10 @@ void FilterEffectsDialog::init_settings_widgets()
     _convolve_target = _settings->add_multispinbutton(SP_ATTR_TARGETX, SP_ATTR_TARGETY, _("Target"), 0, 4, 1, 1, 0);
     _convolve_matrix = _settings->add_matrix(SP_ATTR_KERNELMATRIX, _("Kernel"));
     _convolve_order->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed));
-    _settings->add_spinslider(SP_ATTR_DIVISOR, _("Divisor"), 0.01, 10, 1, 0.01, 1);
+    _settings->add_spinslider(SP_ATTR_DIVISOR, _("Divisor"), 0.01, 1000, 1, 0.01, 1);
     _settings->add_spinslider(SP_ATTR_BIAS, _("Bias"), -10, 10, 1, 0.01, 1);
     _settings->add_combo(SP_ATTR_EDGEMODE, _("Edge Mode"), ConvolveMatrixEdgeModeConverter);
+    _settings->add_checkbutton(SP_ATTR_PRESERVEALPHA, _("Preserve Alpha"), "true", "false");
 
     _settings->type(NR_FILTER_DIFFUSELIGHTING);
     _settings->add_color(SP_PROP_LIGHTING_COLOR, _("Diffuse Color"));