From: tavmjong Date: Sun, 30 Sep 2007 20:56:15 +0000 (+0000) Subject: Convolve Matrix Filter: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b73e69609f67e45076fb28ac523b61bd5c0a227d;p=inkscape.git Convolve Matrix Filter: Enable and use preserveAlpha attribute. Increase range for divisor attribute. --- diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 562f3ffc4..6adf9c9a5 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -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]; + } } } diff --git a/src/sp-feconvolvematrix.cpp b/src/sp-feconvolvematrix.cpp index 5a3edfc50..84a1a8682 100644 --- a/src/sp-feconvolvematrix.cpp +++ b/src/sp-feconvolvematrix.cpp @@ -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); } /* diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index dc6fc06bb..fa64054b0 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -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"));