From d9711532c4ac816bb0dd355f048ce0e26f542710 Mon Sep 17 00:00:00 2001 From: gouldtj Date: Thu, 13 Sep 2007 04:31:40 +0000 Subject: [PATCH] r16564@tres: ted | 2007-09-12 20:45:12 -0700 Final GSoC patch from Chris. I took too long to include it :( --- src/extension/execution-env.cpp | 1 + src/extension/extension.cpp | 6 +- src/extension/extension.h | 8 +- .../implementation/implementation.cpp | 5 + src/extension/implementation/implementation.h | 1 + src/extension/init.cpp | 8 +- .../internal/bitmap/adaptiveThreshold.cpp | 8 +- .../internal/bitmap/adaptiveThreshold.h | 5 +- src/extension/internal/bitmap/addNoise.cpp | 2 +- src/extension/internal/bitmap/blur.cpp | 6 +- src/extension/internal/bitmap/channel.cpp | 2 +- src/extension/internal/bitmap/charcoal.cpp | 6 +- src/extension/internal/bitmap/colorize.cpp | 27 ++-- src/extension/internal/bitmap/colorize.h | 4 +- src/extension/internal/bitmap/contrast.cpp | 7 +- src/extension/internal/bitmap/contrast.h | 2 +- src/extension/internal/bitmap/convolve.cpp | 18 ++- .../internal/bitmap/cycleColormap.cpp | 4 +- src/extension/internal/bitmap/despeckle.cpp | 3 +- src/extension/internal/bitmap/edge.cpp | 4 +- src/extension/internal/bitmap/edge.h | 2 +- src/extension/internal/bitmap/emboss.cpp | 6 +- src/extension/internal/bitmap/enhance.cpp | 6 +- src/extension/internal/bitmap/equalize.cpp | 6 +- src/extension/internal/bitmap/flop.cpp | 6 +- .../internal/bitmap/gaussianBlur.cpp | 6 +- src/extension/internal/bitmap/imagemagick.cpp | 129 +++++++++--------- src/extension/internal/bitmap/imagemagick.h | 10 +- src/extension/internal/bitmap/implode.cpp | 4 +- src/extension/internal/bitmap/level.cpp | 8 +- .../internal/bitmap/levelChannel.cpp | 2 +- .../internal/bitmap/medianFilter.cpp | 4 +- src/extension/internal/bitmap/modulate.cpp | 8 +- src/extension/internal/bitmap/negate.cpp | 2 +- src/extension/internal/bitmap/normalize.cpp | 2 +- src/extension/internal/bitmap/oilPaint.cpp | 2 +- src/extension/internal/bitmap/opacity.cpp | 4 +- src/extension/internal/bitmap/raise.cpp | 10 +- src/extension/internal/bitmap/raise.h | 2 - src/extension/internal/bitmap/reduceNoise.cpp | 2 +- src/extension/internal/bitmap/shade.cpp | 7 +- src/extension/internal/bitmap/sharpen.cpp | 2 +- src/extension/internal/bitmap/solarize.cpp | 4 +- src/extension/internal/bitmap/spread.cpp | 2 +- src/extension/internal/bitmap/swirl.cpp | 6 +- src/extension/internal/bitmap/swirl.h | 8 +- src/extension/internal/bitmap/threshold.cpp | 2 +- src/extension/internal/bitmap/unsharpmask.cpp | 2 +- src/extension/internal/bitmap/wave.cpp | 8 +- src/extension/internal/bitmap/wave.h | 2 +- src/extension/paramcolor.cpp | 65 +++------ src/extension/paramcolor.h | 17 +-- src/extension/parameter.cpp | 6 +- src/extension/parameter.h | 4 +- 54 files changed, 223 insertions(+), 260 deletions(-) diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 3e7bb7e27..12cccbf90 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -215,6 +215,7 @@ void ExecutionEnv::documentCommit (void) { sp_document_done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); Effect::set_last_effect(_effect); + _effect->get_imp()->commitDocument(); return; } diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index b56a1d6f2..825a935ad 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -505,7 +505,7 @@ Extension::get_param_float (const gchar * name, const SPDocument * doc, const In Look up in the parameters list, then execute the function on that found parameter. */ -SPColor* +guint32 Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) { Parameter* param = param_shared(name, parameters); @@ -604,8 +604,8 @@ Extension::set_param_string (const gchar * name, const gchar * value, SPDocument Look up in the parameters list, then execute the function on that found parameter. */ -SPColor* -Extension::set_param_color (const gchar * name, SPColor* color, SPDocument * doc, Inkscape::XML::Node * node) +guint32 +Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, Inkscape::XML::Node * node) { Parameter* param = param_shared(name, parameters); return param->set_color(color, doc, node); diff --git a/src/extension/extension.h b/src/extension/extension.h index b1171548b..aef41a548 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -165,10 +165,10 @@ public: const gchar * get_param_string (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); - SPColor* get_param_color (const gchar * name, + guint32 get_param_color (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); - const gchar * get_param_enum (const gchar * name, + const gchar * get_param_enum (const gchar * name, const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); bool set_param_bool (const gchar * name, @@ -187,8 +187,8 @@ public: const gchar * value, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); - SPColor* set_param_color (const gchar * name, - SPColor* color, + guint32 set_param_color (const gchar * name, + guint32 color, SPDocument * doc = NULL, Inkscape::XML::Node * node = NULL); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 6a9a7955f..70423472b 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -49,6 +49,11 @@ Implementation::cancelProcessing (void) { return true; } +void +Implementation::commitDocument (void) { + return; +} + Gtk::Widget * Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const *filename) { return module->autogui(NULL, NULL); diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index a132996f7..e69686775 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -47,6 +47,7 @@ public: virtual bool check(Inkscape::Extension::Extension *module); virtual bool cancelProcessing (void); + virtual void commitDocument (void); /* ----- Input functions ----- */ /** Find out information about the file. */ diff --git a/src/extension/init.cpp b/src/extension/init.cpp index fca5a7e5d..284c45e6b 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -70,7 +70,7 @@ #include "internal/bitmap/charcoal.h" #include "internal/bitmap/colorize.h" #include "internal/bitmap/contrast.h" -#include "internal/bitmap/convolve.h" +//#include "internal/bitmap/convolve.h" #include "internal/bitmap/cycleColormap.h" #include "internal/bitmap/despeckle.h" #include "internal/bitmap/edge.h" @@ -95,7 +95,7 @@ #include "internal/bitmap/solarize.h" #include "internal/bitmap/spread.h" #include "internal/bitmap/swirl.h" -#include "internal/bitmap/threshold.h" +//#include "internal/bitmap/threshold.h" #include "internal/bitmap/unsharpmask.h" #include "internal/bitmap/wave.h" #endif /* WITH_IMAGE_MAGICK */ @@ -204,7 +204,7 @@ init() Internal::Bitmap::Charcoal::init(); Internal::Bitmap::Colorize::init(); Internal::Bitmap::Contrast::init(); - Internal::Bitmap::Convolve::init(); + //Internal::Bitmap::Convolve::init(); Internal::Bitmap::CycleColormap::init(); Internal::Bitmap::Edge::init(); Internal::Bitmap::Despeckle::init(); @@ -229,7 +229,7 @@ init() Internal::Bitmap::Solarize::init(); Internal::Bitmap::Spread::init(); Internal::Bitmap::Swirl::init(); - Internal::Bitmap::Threshold::init(); + //Internal::Bitmap::Threshold::init(); Internal::Bitmap::Unsharpmask::init(); Internal::Bitmap::Wave::init(); #endif /* WITH_IMAGE_MAGICK */ diff --git a/src/extension/internal/bitmap/adaptiveThreshold.cpp b/src/extension/internal/bitmap/adaptiveThreshold.cpp index 5a2db5dc0..df1c3ea82 100644 --- a/src/extension/internal/bitmap/adaptiveThreshold.cpp +++ b/src/extension/internal/bitmap/adaptiveThreshold.cpp @@ -25,6 +25,7 @@ void AdaptiveThreshold::refreshParameters(Inkscape::Extension::Effect *module) { _width = module->get_param_int("width"); _height = module->get_param_int("height"); + _offset = module->get_param_int("offset"); } #include "../clear-n_.h" @@ -36,14 +37,15 @@ AdaptiveThreshold::init(void) "\n" "" N_("Adaptive Threshold") "\n" "org.inkscape.effect.bitmap.adaptiveThreshold\n" - "5\n" - "1\n" + "5\n" + "5\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Adaptive Threshold Effect") "\n" + "" N_("Apply adaptive thresholding to selected bitmap(s).") "\n" "\n" "\n", new AdaptiveThreshold()); } diff --git a/src/extension/internal/bitmap/adaptiveThreshold.h b/src/extension/internal/bitmap/adaptiveThreshold.h index e7b5e753f..75501720b 100644 --- a/src/extension/internal/bitmap/adaptiveThreshold.h +++ b/src/extension/internal/bitmap/adaptiveThreshold.h @@ -16,8 +16,9 @@ namespace Bitmap { class AdaptiveThreshold : public ImageMagick { private: - int _width; - int _height; + unsigned int _width; + unsigned int _height; + unsigned _offset; public: void applyEffect(Magick::Image *image); void refreshParameters(Inkscape::Extension::Effect *module); diff --git a/src/extension/internal/bitmap/addNoise.cpp b/src/extension/internal/bitmap/addNoise.cpp index 11e3835cf..c846f549a 100644 --- a/src/extension/internal/bitmap/addNoise.cpp +++ b/src/extension/internal/bitmap/addNoise.cpp @@ -56,7 +56,7 @@ AddNoise::init(void) "\n" "\n" "\n" - "" N_("Apply Add Noise Effect") "\n" + "" N_("Add random noise to selected bitmap(s).") "\n" "\n" "\n", new AddNoise()); } diff --git a/src/extension/internal/bitmap/blur.cpp b/src/extension/internal/bitmap/blur.cpp index ad2b5a837..9349f4710 100644 --- a/src/extension/internal/bitmap/blur.cpp +++ b/src/extension/internal/bitmap/blur.cpp @@ -36,14 +36,14 @@ Blur::init(void) "\n" "" N_("Blur") "\n" "org.inkscape.effect.bitmap.blur\n" - "5.0\n" - "1.0\n" + "1\n" + "0.5\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Blur Effect") "\n" + "" N_("Blur selected bitmap(s)") "\n" "\n" "\n", new Blur()); } diff --git a/src/extension/internal/bitmap/channel.cpp b/src/extension/internal/bitmap/channel.cpp index 708638371..a0da25ee9 100644 --- a/src/extension/internal/bitmap/channel.cpp +++ b/src/extension/internal/bitmap/channel.cpp @@ -62,7 +62,7 @@ Channel::init(void) "\n" "\n" "\n" - "" N_("Apply Channel Effect") "\n" + "" N_("Extract specific channel from image.") "\n" "\n" "\n", new Channel()); } diff --git a/src/extension/internal/bitmap/charcoal.cpp b/src/extension/internal/bitmap/charcoal.cpp index 6f3244b8d..442a5d480 100644 --- a/src/extension/internal/bitmap/charcoal.cpp +++ b/src/extension/internal/bitmap/charcoal.cpp @@ -36,14 +36,14 @@ Charcoal::init(void) "\n" "" N_("Charcoal") "\n" "org.inkscape.effect.bitmap.charcoal\n" - "5.0\n" - "1.0\n" + "1\n" + "0.5\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Charcoal Effect") "\n" + "" N_("Apply charcoal stylization to selected bitmap(s).") "\n" "\n" "\n", new Charcoal()); } diff --git a/src/extension/internal/bitmap/colorize.cpp b/src/extension/internal/bitmap/colorize.cpp index cf8ff5dd3..beb6d823b 100644 --- a/src/extension/internal/bitmap/colorize.cpp +++ b/src/extension/internal/bitmap/colorize.cpp @@ -24,29 +24,19 @@ namespace Bitmap { void Colorize::applyEffect(Magick::Image *image) { - float rgb[3]; - sp_color_get_rgb_floatv(_color, rgb); - int red = (int)(rgb[0] * 255); - int green = (int)(rgb[1] * 255); - int blue = (int)(rgb[2] * 255); + float r = ((_color >> 24) & 0xff) / 255.0F; + float g = ((_color >> 16) & 0xff) / 255.0F; + float b = ((_color >> 8) & 0xff) / 255.0F; + float a = ((_color ) & 0xff) / 255.0F; - - printf("(2fk) applying colorize\n"); - printf("(2fl) rgb: %i,%i,%i\n", red, green, blue); - printf("(2fm) opacity: %i\n", _opacity); + Magick::ColorRGB mc(r,g,b); - Magick::ColorRGB mc(red, green, blue); - - image->colorize(_opacity, mc); + image->colorize(a * 100, mc); } void Colorize::refreshParameters(Inkscape::Extension::Effect *module) { - _opacity = module->get_param_int("opacity"); _color = module->get_param_color("color"); - - printf("(2ga) refreshing colorize\n"); - printf("(2gb) _color: %f,%f,%f,%f\n", _color->v.c[0], _color->v.c[1], _color->v.c[2], _color->v.c[3]); } #include "../clear-n_.h" @@ -58,14 +48,13 @@ Colorize::init(void) "\n" "" N_("Colorize") "\n" "org.inkscape.effect.bitmap.colorize\n" - "#FF0000\n" - "1\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Colorize Effect") "\n" + "" N_("Colorize selected bitmap(s) with specified color, using given opacity.") "\n" "\n" "\n", new Colorize()); } diff --git a/src/extension/internal/bitmap/colorize.h b/src/extension/internal/bitmap/colorize.h index e82ef88a4..5b55a1814 100644 --- a/src/extension/internal/bitmap/colorize.h +++ b/src/extension/internal/bitmap/colorize.h @@ -17,8 +17,8 @@ namespace Bitmap { class Colorize : public ImageMagick { private: - SPColor* _color; - int _opacity; + unsigned int _opacity; + guint32 _color; public: void applyEffect(Magick::Image *image); diff --git a/src/extension/internal/bitmap/contrast.cpp b/src/extension/internal/bitmap/contrast.cpp index 1728c325f..f4803dda4 100644 --- a/src/extension/internal/bitmap/contrast.cpp +++ b/src/extension/internal/bitmap/contrast.cpp @@ -18,13 +18,12 @@ namespace Bitmap { void Contrast::applyEffect(Magick::Image *image) { - printf("(o0x) Sharpening at: %i\n", _sharpen); image->contrast(_sharpen); } void Contrast::refreshParameters(Inkscape::Extension::Effect *module) { - _sharpen = module->get_param_bool("sharpen"); + _sharpen = module->get_param_int("sharpen"); } #include "../clear-n_.h" @@ -36,13 +35,13 @@ Contrast::init(void) "\n" "" N_("Contrast") "\n" "org.inkscape.effect.bitmap.contrast\n" - "1\n" + "1\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Contrast Effect") "\n" + "" N_("Enhance intensity differences in selected bitmap(s).") "\n" "\n" "\n", new Contrast()); } diff --git a/src/extension/internal/bitmap/contrast.h b/src/extension/internal/bitmap/contrast.h index acb5982a3..53a636647 100644 --- a/src/extension/internal/bitmap/contrast.h +++ b/src/extension/internal/bitmap/contrast.h @@ -16,7 +16,7 @@ namespace Bitmap { class Contrast : public ImageMagick { private: - bool _sharpen; + unsigned int _sharpen; public: void applyEffect(Magick::Image *image); void refreshParameters(Inkscape::Extension::Effect *module); diff --git a/src/extension/internal/bitmap/convolve.cpp b/src/extension/internal/bitmap/convolve.cpp index 3c04bfebe..65b22bf61 100644 --- a/src/extension/internal/bitmap/convolve.cpp +++ b/src/extension/internal/bitmap/convolve.cpp @@ -24,7 +24,19 @@ Convolve::applyEffect(Magick::Image *image) { void Convolve::refreshParameters(Inkscape::Extension::Effect *module) { _order = module->get_param_int("order"); - *_kernel = 0; + if (_order % 2 == 0) _order--; + _kernel = new double[_order]; + int i = 0; + + char *arrayStr = g_strdup(module->get_param_string("kernel")); + + char *num = strtok(arrayStr, ","); + while (num != NULL) + { + _kernel[i++] = atof(num); + + num = strtok(NULL, ","); + } } #include "../clear-n_.h" @@ -37,8 +49,8 @@ Convolve::init(void) // TRANSLATORS: see http://docs.gimp.org/en/gimp-tool-convolve.html "" N_("Convolve") "\n" "org.inkscape.effect.bitmap.convolve\n" - "1\n" - "1,1,1,0,0,0\n" + "4\n" + "1,1,0,0\n" "\n" "all\n" "\n" diff --git a/src/extension/internal/bitmap/cycleColormap.cpp b/src/extension/internal/bitmap/cycleColormap.cpp index 309837abe..7282fa52e 100644 --- a/src/extension/internal/bitmap/cycleColormap.cpp +++ b/src/extension/internal/bitmap/cycleColormap.cpp @@ -35,13 +35,13 @@ CycleColormap::init(void) "\n" "" N_("Cycle Colormap") "\n" "org.inkscape.effect.bitmap.cycleColormap\n" - "1\n" + "180\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Cycle Colormap Effect") "\n" + "" N_("Cycle colormap(s) of selected bitmap(s).") "\n" "\n" "\n", new CycleColormap()); } diff --git a/src/extension/internal/bitmap/despeckle.cpp b/src/extension/internal/bitmap/despeckle.cpp index 75a1ca35a..2a81d1b3d 100644 --- a/src/extension/internal/bitmap/despeckle.cpp +++ b/src/extension/internal/bitmap/despeckle.cpp @@ -23,7 +23,6 @@ Despeckle::applyEffect(Magick::Image *image) { void Despeckle::refreshParameters(Inkscape::Extension::Effect *module) { - } #include "../clear-n_.h" @@ -40,7 +39,7 @@ Despeckle::init(void) "\n" "\n" "\n" - "" N_("Apply Despeckle Effect") "\n" + "" N_("Reduce speckle noise of selected bitmap(s).") "\n" "\n" "\n", new Despeckle()); } diff --git a/src/extension/internal/bitmap/edge.cpp b/src/extension/internal/bitmap/edge.cpp index f9b14b246..4bde1a779 100644 --- a/src/extension/internal/bitmap/edge.cpp +++ b/src/extension/internal/bitmap/edge.cpp @@ -35,13 +35,13 @@ Edge::init(void) "\n" "" N_("Edge") "\n" "org.inkscape.effect.bitmap.edge\n" - "5\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Edge Effect") "\n" + "" N_("Hilight edges of selected bitmap(s).") "\n" "\n" "\n", new Edge()); } diff --git a/src/extension/internal/bitmap/edge.h b/src/extension/internal/bitmap/edge.h index 4585648f2..40277a89e 100644 --- a/src/extension/internal/bitmap/edge.h +++ b/src/extension/internal/bitmap/edge.h @@ -15,7 +15,7 @@ namespace Bitmap { class Edge : public ImageMagick { private: - int _radius; + unsigned int _radius; public: void applyEffect(Magick::Image *image); void refreshParameters(Inkscape::Extension::Effect *module); diff --git a/src/extension/internal/bitmap/emboss.cpp b/src/extension/internal/bitmap/emboss.cpp index 8d7f72459..cf47bee9e 100644 --- a/src/extension/internal/bitmap/emboss.cpp +++ b/src/extension/internal/bitmap/emboss.cpp @@ -36,14 +36,14 @@ Emboss::init(void) "\n" "" N_("Emboss") "\n" "org.inkscape.effect.bitmap.emboss\n" - "5.0\n" - "1.0\n" + "1.0\n" + "0.5\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Emboss Effect") "\n" + "" N_("Emboss selected bitmap(s) -- hilight edges with 3D effect.") "\n" "\n" "\n", new Emboss()); } diff --git a/src/extension/internal/bitmap/enhance.cpp b/src/extension/internal/bitmap/enhance.cpp index dae90776b..99ac4a171 100644 --- a/src/extension/internal/bitmap/enhance.cpp +++ b/src/extension/internal/bitmap/enhance.cpp @@ -22,9 +22,7 @@ Enhance::applyEffect(Magick::Image *image) { } void -Enhance::refreshParameters(Inkscape::Extension::Effect *module) { - -} +Enhance::refreshParameters(Inkscape::Extension::Effect *module) { } #include "../clear-n_.h" @@ -40,7 +38,7 @@ Enhance::init(void) "\n" "\n" "\n" - "" N_("Apply Enhance Effect") "\n" + "" N_("Enhance selected bitmap(s) -- minimize noise.") "\n" "\n" "\n", new Enhance()); } diff --git a/src/extension/internal/bitmap/equalize.cpp b/src/extension/internal/bitmap/equalize.cpp index 1b0911ac3..9caf342b0 100644 --- a/src/extension/internal/bitmap/equalize.cpp +++ b/src/extension/internal/bitmap/equalize.cpp @@ -22,9 +22,7 @@ Equalize::applyEffect(Magick::Image *image) { } void -Equalize::refreshParameters(Inkscape::Extension::Effect *module) { - -} +Equalize::refreshParameters(Inkscape::Extension::Effect *module) { } #include "../clear-n_.h" @@ -40,7 +38,7 @@ Equalize::init(void) "\n" "\n" "\n" - "" N_("Apply Equalize Effect") "\n" + "" N_("Equalize selected bitmap(s) -- histogram equalization.") "\n" "\n" "\n", new Equalize()); } diff --git a/src/extension/internal/bitmap/flop.cpp b/src/extension/internal/bitmap/flop.cpp index 437c8afbd..ef5d41d49 100644 --- a/src/extension/internal/bitmap/flop.cpp +++ b/src/extension/internal/bitmap/flop.cpp @@ -22,9 +22,7 @@ Flop::applyEffect(Magick::Image *image) { } void -Flop::refreshParameters(Inkscape::Extension::Effect *module) { - -} +Flop::refreshParameters(Inkscape::Extension::Effect *module) { } #include "../clear-n_.h" @@ -40,7 +38,7 @@ Flop::init(void) "\n" "\n" "\n" - "" N_("Apply Flop Effect") "\n" + "" N_("Flop selected bitmap(s) -- reflect each scanline in the horizontal direction.") "\n" "\n" "\n", new Flop()); } diff --git a/src/extension/internal/bitmap/gaussianBlur.cpp b/src/extension/internal/bitmap/gaussianBlur.cpp index 36087c525..97a2482cb 100644 --- a/src/extension/internal/bitmap/gaussianBlur.cpp +++ b/src/extension/internal/bitmap/gaussianBlur.cpp @@ -36,14 +36,14 @@ GaussianBlur::init(void) "\n" "" N_("Gaussian Blur") "\n" "org.inkscape.effect.bitmap.gaussianBlur\n" - "5.0\n" - "5.0\n" + "5.0\n" + "5.0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Gaussian Blur Effect") "\n" + "" N_("Gaussian blur selected bitmap(s).") "\n" "\n" "\n", new GaussianBlur()); } diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index db67294ea..a6c30a587 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -8,9 +8,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include #include #include +#include #include @@ -34,6 +37,7 @@ bool ImageMagick::load(Inkscape::Extension::Extension *module) { _loaded = FALSE; + return TRUE; } @@ -42,19 +46,22 @@ ImageMagick::commitDocument(void) { _loaded = FALSE; } -void +/*void ImageMagick::cancelDocument(void) { for (int i = 0; i < _imageCount; i++) { _nodes[i]->setAttribute("xlink:href", _originals[i], true); + + if (strlen(_originals[i]) < 256) + _nodes[i]->setAttribute("sodipodi:absref", _originals[i], true); } _loaded = FALSE; -} +}*/ void ImageMagick::readImage(const char *xlink, Magick::Image *image) { - // Find if the xlink:href is base64 data, i.e. if the image is embedded + // Find if the xlink:href is base64 data, i.e. if the image is embedded char *search = (char *) g_strndup(xlink, 30); if (strstr(search, "base64") != (char*)NULL) { // 7 = strlen("base64") + strlen(",") @@ -74,17 +81,19 @@ ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::Vi refreshParameters(module); if (!_loaded) - { + { SPDesktop *desktop = (SPDesktop*)document; const GSList *selectedReprList = desktop->selection->reprList(); int selectCount = g_slist_length((GSList *)selectedReprList); - + // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; _originals = new const char*[selectCount]; - _images = new Magick::Image[selectCount]; + _caches = new char*[selectCount]; + _cacheLengths = new unsigned[selectCount]; + _images = new Magick::Image*[selectCount]; _imageCount = 0; - + // Loop through selected nodes for (; selectedReprList != NULL; selectedReprList = g_slist_next(selectedReprList)) { @@ -93,79 +102,71 @@ ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::Vi { _nodes[_imageCount] = node; char const *xlink = node->attribute("xlink:href"); - + _originals[_imageCount] = xlink; - - readImage(xlink, &_images[_imageCount]); - + _caches[_imageCount] = ""; + _cacheLengths[_imageCount] = 0; + _images[_imageCount] = new Magick::Image(); + readImage(xlink, _images[_imageCount]); + _imageCount++; } } - + _loaded = 1; } - + for (int i = 0; i < _imageCount; i++) { try { - Magick::Image effectedImage = _images[i]; + Magick::Image effectedImage = *_images[i]; // make a copy applyEffect(&effectedImage); - Magick::Blob blob; - effectedImage.write(&blob); - - std::string raw_string = blob.base64(); - const char *raw = raw_string.c_str(); - - /* - const int raw_len = raw_string.length(); - const char *raw_i = raw; - int formatted_len = (int)(raw_len / 76.0 * 78.0) + 100; - char *formatted = new char[formatted_len]; - char *formatted_i = formatted; - // data:image/png;base64, - formatted_i = stpcpy(formatted_i, "data:image/"); - formatted_i = stpcpy(formatted_i, effectedImage.magick().c_str()); - formatted_i = stpcpy(formatted_i, ";base64, \n"); - while (strnlen(raw_i, 80) > 76) - { - formatted_i = stpncpy(formatted_i, raw_i, 76); - formatted_i = stpcpy(formatted_i, "\n"); - raw_i += 76; - } - if (strlen(raw_i) > 0) - { - formatted_i = stpcpy(formatted_i, raw_i); - formatted_i = stpcpy(formatted_i, "\n"); - } - - formatted_i = stpcpy(formatted_i, "\0"); - - _nodes[i]->setAttribute("xlink:href", formatted, true); - */ - - Glib::ustring buf = "data:image/"; - buf.append(effectedImage.magick()); - buf.append(";base64, \n"); - int col = 0; - while (*raw) - { - buf.push_back(*raw++); - if (col>=76) - { - buf.push_back('\n'); - col = 0; - } - } - if (col) - buf.push_back('\n'); - - _nodes[i]->setAttribute("xlink:href", buf.c_str(), true); + Magick::Blob *blob = new Magick::Blob(); + effectedImage.write(blob); + + std::string raw_string = blob->base64(); + const int raw_len = raw_string.length(); + const char *raw_i = raw_string.c_str(); + + unsigned new_len = (int)(raw_len * (77.0 / 76.0) + 100); + if (new_len > _cacheLengths[i]) { + _cacheLengths[i] = (int)(new_len * 1.2); + _caches[i] = new char[_cacheLengths[i]]; + } + char *formatted_i = _caches[i]; + const char *src; + + for (src = "data:image/"; *src; ) + *formatted_i++ = *src++; + for (src = effectedImage.magick().c_str(); *src ; ) + *formatted_i++ = *src++; + for (src = ";base64, \n" ; *src; ) + *formatted_i++ = *src++; + + int col = 0; + while (*raw_i) { + *formatted_i++ = *raw_i++; + if (col++ > 76) { + *formatted_i++ = '\n'; + col = 0; + } + } + if (col) { + *formatted_i++ = '\n'; + } + *formatted_i = '\0'; + + _nodes[i]->setAttribute("xlink:href", _caches[i], true); + _nodes[i]->setAttribute("sodipodi:absref", NULL, true); } catch (Magick::Exception &error_) { printf("Caught exception: %s \n", error_.what()); } + + while(Gtk::Main::events_pending()) + Gtk::Main::iteration(); } } diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h index 36536bb69..4afdcfbb4 100644 --- a/src/extension/internal/bitmap/imagemagick.h +++ b/src/extension/internal/bitmap/imagemagick.h @@ -23,19 +23,21 @@ class ImageMagick : public Inkscape::Extension::Implementation::Implementation { private: bool _loaded; - Inkscape::XML::Node **_nodes; + Inkscape::XML::Node** _nodes; - Magick::Image *_images; + Magick::Image** _images; int _imageCount; + char** _caches; + unsigned* _cacheLengths; - const char **_originals; + const char** _originals; public: virtual void applyEffect(Magick::Image *image) { }; virtual void refreshParameters(Inkscape::Extension::Effect *module) { }; bool load(Inkscape::Extension::Extension *module); void commitDocument(void); - void cancelDocument(void); + /*void cancelDocument(void);*/ void readImage(char const *xlink, Magick::Image *image); void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document); diff --git a/src/extension/internal/bitmap/implode.cpp b/src/extension/internal/bitmap/implode.cpp index 74dc81e4e..e8fd2201c 100644 --- a/src/extension/internal/bitmap/implode.cpp +++ b/src/extension/internal/bitmap/implode.cpp @@ -35,13 +35,13 @@ Implode::init(void) "\n" "" N_("Implode") "\n" "org.inkscape.effect.bitmap.implode\n" - "5.0\n" + "10\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Implode Effect") "\n" + "" N_("Implode selected bitmap(s).") "\n" "\n" "\n", new Implode()); } diff --git a/src/extension/internal/bitmap/level.cpp b/src/extension/internal/bitmap/level.cpp index f48be32a2..04f78d7e5 100644 --- a/src/extension/internal/bitmap/level.cpp +++ b/src/extension/internal/bitmap/level.cpp @@ -39,15 +39,15 @@ Level::init(void) "\n" "" N_("Level") "\n" "org.inkscape.effect.bitmap.level\n" - "0.0\n" - "100.0\n" - "1.0\n" + "0\n" + "100\n" + "1\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Level Effect") "\n" + "" N_("Level selected bitmap(s) by scaling values falling between the given ranges to the full color range.") "\n" "\n" "\n", new Level()); } diff --git a/src/extension/internal/bitmap/levelChannel.cpp b/src/extension/internal/bitmap/levelChannel.cpp index 90372aa84..265ea78d0 100644 --- a/src/extension/internal/bitmap/levelChannel.cpp +++ b/src/extension/internal/bitmap/levelChannel.cpp @@ -69,7 +69,7 @@ LevelChannel::init(void) "\n" "\n" "\n" - "" N_("Apply Level (with Channel) Effect") "\n" + "" N_("Level the specified channel of selected bitmap(s) by scaling values falling between the given ranges to the full color range.") "\n" "\n" "\n", new LevelChannel()); } diff --git a/src/extension/internal/bitmap/medianFilter.cpp b/src/extension/internal/bitmap/medianFilter.cpp index 4ba14fd70..3255043ce 100644 --- a/src/extension/internal/bitmap/medianFilter.cpp +++ b/src/extension/internal/bitmap/medianFilter.cpp @@ -35,13 +35,13 @@ MedianFilter::init(void) "\n" "" N_("Median Filter") "\n" "org.inkscape.effect.bitmap.medianFilter\n" - "5.0\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Median Filter Effect") "\n" + "" N_("Filter selected bitmap(s) by replacing each pixel component with the median color in a circular neighborhood.") "\n" "\n" "\n", new MedianFilter()); } diff --git a/src/extension/internal/bitmap/modulate.cpp b/src/extension/internal/bitmap/modulate.cpp index 97a4d5a47..f8dbca86d 100644 --- a/src/extension/internal/bitmap/modulate.cpp +++ b/src/extension/internal/bitmap/modulate.cpp @@ -38,15 +38,15 @@ Modulate::init(void) "\n" "" N_("Modulate") "\n" "org.inkscape.effect.bitmap.modulate\n" - "1.0\n" - "1.0\n" - "0.0\n" + "1\n" + "1\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Modulate Effect") "\n" + "" N_("Modulate percent hue, saturation, and brightness of selected bitmap(s).") "\n" "\n" "\n", new Modulate()); } diff --git a/src/extension/internal/bitmap/negate.cpp b/src/extension/internal/bitmap/negate.cpp index 19e72e8dd..8792883dc 100644 --- a/src/extension/internal/bitmap/negate.cpp +++ b/src/extension/internal/bitmap/negate.cpp @@ -39,7 +39,7 @@ Negate::init(void) "\n" "\n" "\n" - "" N_("Apply Negate Effect") "\n" + "" N_("Negate (take inverse) selected bitmap(s).") "\n" "\n" "\n", new Negate()); } diff --git a/src/extension/internal/bitmap/normalize.cpp b/src/extension/internal/bitmap/normalize.cpp index 6d8b4330b..0b2ddb303 100644 --- a/src/extension/internal/bitmap/normalize.cpp +++ b/src/extension/internal/bitmap/normalize.cpp @@ -39,7 +39,7 @@ Normalize::init(void) "\n" "\n" "\n" - "" N_("Apply Normalize Effect") "\n" + "" N_("Normalize selected bitmap(s), expanding color range to the full possible range of color.") "\n" "\n" "\n", new Normalize()); } diff --git a/src/extension/internal/bitmap/oilPaint.cpp b/src/extension/internal/bitmap/oilPaint.cpp index 7b95fe160..6e8bacdae 100644 --- a/src/extension/internal/bitmap/oilPaint.cpp +++ b/src/extension/internal/bitmap/oilPaint.cpp @@ -41,7 +41,7 @@ OilPaint::init(void) "\n" "\n" "\n" - "" N_("Apply OilPaint Effect") "\n" + "" N_("Stylize selected bitmap(s) so that they appear to be painted with oils.") "\n" "\n" "\n", new OilPaint()); } diff --git a/src/extension/internal/bitmap/opacity.cpp b/src/extension/internal/bitmap/opacity.cpp index af2c3fe26..e2db6792b 100644 --- a/src/extension/internal/bitmap/opacity.cpp +++ b/src/extension/internal/bitmap/opacity.cpp @@ -18,7 +18,7 @@ namespace Bitmap { void Opacity::applyEffect(Magick::Image* image) { - Magick::Quantum opacity = Magick::Color::scaleDoubleToQuantum(_opacity / 100.0); + Magick::Quantum opacity = Magick::Color::scaleDoubleToQuantum((100 - _opacity) / 100.0); image->opacity(opacity); } @@ -42,7 +42,7 @@ Opacity::init(void) "\n" "\n" "\n" - "" N_("Apply Opacity Effect") "\n" + "" N_("Modify opacity channel(s) of selected bitmap(s).") "\n" "\n" "\n", new Opacity()); } diff --git a/src/extension/internal/bitmap/raise.cpp b/src/extension/internal/bitmap/raise.cpp index 6f050fcef..d3130a11d 100644 --- a/src/extension/internal/bitmap/raise.cpp +++ b/src/extension/internal/bitmap/raise.cpp @@ -18,7 +18,7 @@ namespace Bitmap { void Raise::applyEffect(Magick::Image* image) { - Magick::Geometry geometry(_width, _height, _x, _y); + Magick::Geometry geometry(_width, _height, 0, 0); image->raise(geometry, _raisedFlag); } @@ -26,8 +26,6 @@ void Raise::refreshParameters(Inkscape::Extension::Effect* module) { _width = module->get_param_int("width"); _height = module->get_param_int("height"); - _x = module->get_param_int("x"); - _y = module->get_param_int("y"); _raisedFlag = module->get_param_bool("raisedFlag"); } @@ -42,15 +40,13 @@ Raise::init(void) "org.inkscape.effect.bitmap.raise\n" "6\n" "6\n" - "0\n" - "0\n" - "0\n" + "0\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Raise Effect") "\n" + "" N_("Alter lightness the edges of selected bitmap(s) to create a raised appearance.") "\n" "\n" "\n", new Raise()); } diff --git a/src/extension/internal/bitmap/raise.h b/src/extension/internal/bitmap/raise.h index 7ceb08867..81a6c65c3 100644 --- a/src/extension/internal/bitmap/raise.h +++ b/src/extension/internal/bitmap/raise.h @@ -16,8 +16,6 @@ namespace Bitmap { class Raise : public ImageMagick { private: - int _x; - int _y; int _width; int _height; bool _raisedFlag; diff --git a/src/extension/internal/bitmap/reduceNoise.cpp b/src/extension/internal/bitmap/reduceNoise.cpp index 689a97361..972ab39be 100644 --- a/src/extension/internal/bitmap/reduceNoise.cpp +++ b/src/extension/internal/bitmap/reduceNoise.cpp @@ -44,7 +44,7 @@ ReduceNoise::init(void) "\n" "\n" "\n" - "" N_("Apply ReduceNoise Effect") "\n" + "" N_("Reduce noise in selected bitmap(s) using a noise peak elimination filter.") "\n" "\n" "\n", new ReduceNoise()); } diff --git a/src/extension/internal/bitmap/shade.cpp b/src/extension/internal/bitmap/shade.cpp index a9bb5a266..3ee83b43f 100644 --- a/src/extension/internal/bitmap/shade.cpp +++ b/src/extension/internal/bitmap/shade.cpp @@ -18,7 +18,8 @@ namespace Bitmap { void Shade::applyEffect(Magick::Image* image) { - image->shade(_azimuth, _elevation, _colorShading); + image->shade(_azimuth, _elevation, !_colorShading); + // I don't know why, but I have to invert colorShading here } void @@ -39,13 +40,13 @@ Shade::init(void) "org.inkscape.effect.bitmap.shade\n" "30\n" "30\n" - "0\n" + "false\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Shade Effect") "\n" + "" N_("Shade selected bitmap(s) simulating distant light source.") "\n" "\n" "\n", new Shade()); } diff --git a/src/extension/internal/bitmap/sharpen.cpp b/src/extension/internal/bitmap/sharpen.cpp index cf0bf519e..4e21017ed 100644 --- a/src/extension/internal/bitmap/sharpen.cpp +++ b/src/extension/internal/bitmap/sharpen.cpp @@ -43,7 +43,7 @@ Sharpen::init(void) "\n" "\n" "\n" - "" N_("Apply Sharpen Effect") "\n" + "" N_("Sharpen selected bitmap(s).") "\n" "\n" "\n", new Sharpen()); } diff --git a/src/extension/internal/bitmap/solarize.cpp b/src/extension/internal/bitmap/solarize.cpp index 1de9bf9da..744b09046 100644 --- a/src/extension/internal/bitmap/solarize.cpp +++ b/src/extension/internal/bitmap/solarize.cpp @@ -35,13 +35,13 @@ Solarize::init(void) "\n" "" N_("Solarize") "\n" "org.inkscape.effect.bitmap.solarize\n" - "50.0\n" + "50\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Solarize Effect") "\n" + "" N_("Solarize selected bitmap(s), like overexposing photographic film.") "\n" "\n" "\n", new Solarize()); } diff --git a/src/extension/internal/bitmap/spread.cpp b/src/extension/internal/bitmap/spread.cpp index dfc9b8bf5..1000d304d 100644 --- a/src/extension/internal/bitmap/spread.cpp +++ b/src/extension/internal/bitmap/spread.cpp @@ -41,7 +41,7 @@ Spread::init(void) "\n" "\n" "\n" - "" N_("Apply Spread Effect") "\n" + "" N_("Randomly spread pixels in selected bitmap(s), within the radius of 'amount.'") "\n" "\n" "\n", new Spread()); } diff --git a/src/extension/internal/bitmap/swirl.cpp b/src/extension/internal/bitmap/swirl.cpp index a880552c6..668528616 100644 --- a/src/extension/internal/bitmap/swirl.cpp +++ b/src/extension/internal/bitmap/swirl.cpp @@ -23,7 +23,7 @@ Swirl::applyEffect(Magick::Image* image) { void Swirl::refreshParameters(Inkscape::Extension::Effect* module) { - _degrees = module->get_param_float("degrees"); + _degrees = module->get_param_int("degrees"); } #include "../clear-n_.h" @@ -35,13 +35,13 @@ Swirl::init(void) "\n" "" N_("Swirl") "\n" "org.inkscape.effect.bitmap.swirl\n" - "30\n" + "30\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Swirl Effect") "\n" + "" N_("Swirl selected bitmap(s) around center point.") "\n" "\n" "\n", new Swirl()); } diff --git a/src/extension/internal/bitmap/swirl.h b/src/extension/internal/bitmap/swirl.h index cea1850ea..b54b83581 100644 --- a/src/extension/internal/bitmap/swirl.h +++ b/src/extension/internal/bitmap/swirl.h @@ -16,11 +16,11 @@ namespace Bitmap { class Swirl : public ImageMagick { private: - double _degrees; + float _degrees; public: - void applyEffect(Magick::Image *image); - void refreshParameters(Inkscape::Extension::Effect *module); - static void init(void); + void applyEffect(Magick::Image *image); + void refreshParameters(Inkscape::Extension::Effect *module); + static void init(void); }; }; /* namespace Bitmap */ diff --git a/src/extension/internal/bitmap/threshold.cpp b/src/extension/internal/bitmap/threshold.cpp index 702d274e9..ee920a57f 100644 --- a/src/extension/internal/bitmap/threshold.cpp +++ b/src/extension/internal/bitmap/threshold.cpp @@ -42,7 +42,7 @@ Threshold::init(void) "\n" "\n" "\n" - "" N_("Apply Threshold Effect") "\n" + "" N_("Threshold selected bitmap(s).") "\n" "\n" "\n", new Threshold()); } diff --git a/src/extension/internal/bitmap/unsharpmask.cpp b/src/extension/internal/bitmap/unsharpmask.cpp index 6e4a1759a..1249345ba 100644 --- a/src/extension/internal/bitmap/unsharpmask.cpp +++ b/src/extension/internal/bitmap/unsharpmask.cpp @@ -48,7 +48,7 @@ Unsharpmask::init(void) "\n" "\n" "\n" - "" N_("Apply Unsharp Mask Effect") "\n" + "" N_("Sharpen selected bitmap(s) using unsharp mask algorithms.") "\n" "\n" "\n", new Unsharpmask()); } diff --git a/src/extension/internal/bitmap/wave.cpp b/src/extension/internal/bitmap/wave.cpp index c1a2994c0..b654fa7e0 100644 --- a/src/extension/internal/bitmap/wave.cpp +++ b/src/extension/internal/bitmap/wave.cpp @@ -24,7 +24,7 @@ Wave::applyEffect(Magick::Image* image) { void Wave::refreshParameters(Inkscape::Extension::Effect* module) { _amplitude = module->get_param_float("amplitude"); - _wavelength = module->get_param_int("wavelength"); + _wavelength = module->get_param_float("wavelength"); } #include "../clear-n_.h" @@ -36,14 +36,14 @@ Wave::init(void) "\n" "" N_("Wave") "\n" "org.inkscape.effect.bitmap.wave\n" - "25.0\n" - "150.0\n" + "25\n" + "150\n" "\n" "all\n" "\n" "\n" "\n" - "" N_("Apply Wave Effect") "\n" + "" N_("Alter selected bitmap(s) along sine wave.") "\n" "\n" "\n", new Wave()); } diff --git a/src/extension/internal/bitmap/wave.h b/src/extension/internal/bitmap/wave.h index 8ee1fc7f5..5bbde9e48 100644 --- a/src/extension/internal/bitmap/wave.h +++ b/src/extension/internal/bitmap/wave.h @@ -17,7 +17,7 @@ class Wave : public ImageMagick { private: float _amplitude; - int _wavelength; + float _wavelength; public: void applyEffect(Magick::Image *image); void refreshParameters(Inkscape::Extension::Effect *module); diff --git a/src/extension/paramcolor.cpp b/src/extension/paramcolor.cpp index c70d407f6..e051fc8dc 100644 --- a/src/extension/paramcolor.cpp +++ b/src/extension/paramcolor.cpp @@ -36,11 +36,11 @@ void sp_color_param_changed(SPColorSelector *csel, GObject *cp); /** \brief Free the allocated data. */ ParamColor::~ParamColor(void) { - g_free(_value); + } -SPColor* -ParamColor::set (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node) +guint32 +ParamColor::set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) { _value = in; @@ -53,7 +53,7 @@ ParamColor::set (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node) /** \brief Initialize the object, to do that, copy the data. */ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, ext), _value(NULL) + Parameter(name, guitext, desc, scope, ext) { const char * defaulthex = NULL; if (sp_repr_children(xml) != NULL) @@ -65,26 +65,8 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * if (paramval != NULL) defaulthex = paramval; - - const char* hexMark = strchr(defaulthex, '#'); - if (hexMark != NULL) - defaulthex++;// = hexMark; - - if (strlen(defaulthex) == 6) { - int r = 0, g = 0, b = 0; - std::stringstream ss; - ss << g_strndup(defaulthex, 2); - ss >> std::hex >> r; - ss << g_strndup(defaulthex + 2, 2); - ss >> std::hex >> g; - ss << defaulthex + 4; - ss >> std::hex >> b; - g_free(ss); - - SPColor defaultColor; - sp_color_set_rgb_float(&defaultColor, r / 255.0, g / 255.0, b / 255.0); - _value = &defaultColor; - } + + _value = atoi(defaulthex); return; } @@ -93,16 +75,10 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * Glib::ustring * ParamColor::string (void) { - float rgb[3]; - sp_color_get_rgb_floatv(_value, rgb); - char hex[8]; - snprintf(hex, 8, "#%02X%02X%02X", (int)(rgb[0] * 255), (int)(rgb[1] * 255), (int)(rgb[2] * 255)); + char str[16]; + sprintf(str, "%i", _value); - Glib::ustring* ret = new Glib::ustring(hex); - - printf("ParamColor::string = '%s'\n", hex); - - return ret; + return new Glib::ustring(str); } Gtk::Widget * @@ -113,15 +89,15 @@ ParamColor::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK, SP_COLORSPACE_TYPE_RGB); ColorSelector* colorSelector = spColorSelector->base; - if (_value == NULL) { - _value = new SPColor(); - sp_color_set_rgb_float(_value, 1.0, 0.0, 0.0); + if (_value < 1) { + _value = 0xFF000000; } - colorSelector->setColor(*_value); + SPColor *color = new SPColor(); + sp_color_set_rgb_rgba32(color, _value); + float alpha = (_value & 0xff) / 255.0F; + colorSelector->setColorAlpha(*color, alpha); hbox->pack_start (*Glib::wrap(&spColorSelector->vbox), true, true, 0); - g_signal_connect(G_OBJECT(spColorSelector), "dragged", G_CALLBACK(sp_color_param_changed), (void*)this); - g_signal_connect(G_OBJECT(spColorSelector), "released", G_CALLBACK(sp_color_param_changed), (void*)this); g_signal_connect(G_OBJECT(spColorSelector), "changed", G_CALLBACK(sp_color_param_changed), (void*)this); gtk_widget_show(GTK_WIDGET(spColorSelector)); @@ -133,14 +109,11 @@ ParamColor::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign void sp_color_param_changed(SPColorSelector *csel, GObject *obj) { - SPColor color; - float alpha; - csel->base->getColorAlpha(color, &alpha); - guint32 rgba = sp_color_get_rgba32_falpha(&color, alpha); - + const SPColor color = csel->base->getColor(); + float alpha = csel->base->getAlpha(); - ParamColor* ptr = (ParamColor* )obj; - ptr->set(&color, NULL, NULL); + ParamColor* ptr = (ParamColor*)obj; + ptr->set(sp_color_get_rgba32_falpha(&color, alpha), NULL, NULL); ptr->_changeSignal->emit(); } diff --git a/src/extension/paramcolor.h b/src/extension/paramcolor.h index c109df04f..fc9d939cd 100644 --- a/src/extension/paramcolor.h +++ b/src/extension/paramcolor.h @@ -18,13 +18,13 @@ namespace Extension { class ParamColor : public Parameter { private: - SPColor* _value; + guint32 _value; public: ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); ~ParamColor(void); /** \brief Returns \c _value, with a \i const to protect it. */ - SPColor* get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } - SPColor* set (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node); + guint32 get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; } + guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); Glib::ustring * string (void); sigc::signal * _changeSignal; @@ -34,14 +34,3 @@ public: } /* namespace Inkscape */ #endif /* __INK_EXTENSION_PARAMCOLOR_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/parameter.cpp b/src/extension/parameter.cpp index 52c67267f..4af448b20 100644 --- a/src/extension/parameter.cpp +++ b/src/extension/parameter.cpp @@ -215,7 +215,7 @@ Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node) return param->get(doc, node); } -SPColor* +guint32 Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node) { ParamColor* param = dynamic_cast(this); @@ -265,8 +265,8 @@ Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * return stringpntr->set(in, doc, node); } /** \brief Wrapper to cast to the object and use it's function. */ -SPColor* -Parameter::set_color (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node) +guint32 +Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) { ParamColor* param = dynamic_cast(this); if (param == NULL) diff --git a/src/extension/parameter.h b/src/extension/parameter.h index 0c799a1c2..19cd75ecd 100644 --- a/src/extension/parameter.h +++ b/src/extension/parameter.h @@ -87,7 +87,7 @@ public: const Inkscape::XML::Node * node); const gchar * get_string (const SPDocument * doc, const Inkscape::XML::Node * node); - SPColor* get_color (const SPDocument * doc, + guint32 get_color (const SPDocument * doc, const Inkscape::XML::Node * node); const gchar * get_enum (const SPDocument * doc, const Inkscape::XML::Node * node); @@ -96,7 +96,7 @@ public: int set_int (int in, SPDocument * doc, Inkscape::XML::Node * node); float set_float (float in, SPDocument * doc, Inkscape::XML::Node * node); const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - SPColor* set_color (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node); + guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); const gchar * name (void) {return _name;} -- 2.30.2