Code

33020ef43c95f377f337e88c1013584c24b8748e
[inkscape.git] / src / extension / internal / bitmap / colorize.cpp
1 /*
2  * Authors:
3  *   Christopher Brown <audiere@gmail.com>
4  *   Ted Gould <ted@gould.cx>
5  *
6  * Copyright (C) 2007 Authors
7  *
8  * Released under GNU GPL, read the file 'COPYING' for more information
9  */
11 #include "extension/effect.h"
12 #include "extension/system.h"
14 #include "colorize.h"
16 #include "color.h"
18 #include <iostream>
20 namespace Inkscape {
21 namespace Extension {
22 namespace Internal {
23 namespace Bitmap {
24         
25 void
26 Colorize::applyEffect(Magick::Image *image) {
27         float r = ((_color >> 24) & 0xff) / 255.0F;
28         float g = ((_color >> 16) & 0xff) / 255.0F;
29         float b = ((_color >>  8) & 0xff) / 255.0F;
30         float a = ((_color      ) & 0xff) / 255.0F;
31         
32     Magick::ColorRGB mc(r,g,b);
33         
34         image->colorize(a * 100, mc);
35 }
37 void
38 Colorize::refreshParameters(Inkscape::Extension::Effect *module) {      
39         _color = module->get_param_color("color");
40 }
42 #include "../clear-n_.h"
44 void
45 Colorize::init(void)
46 {
47         Inkscape::Extension::build_from_mem(
48                 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
49                         "<name>" N_("Colorize") "</name>\n"
50                         "<id>org.inkscape.effect.bitmap.colorize</id>\n"
51                         "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">0</param>\n"
52                         "<effect>\n"
53                                 "<object-type>all</object-type>\n"
54                                 "<effects-menu>\n"
55                                         "<submenu name=\"" N_("Raster") "\" />\n"
56                                 "</effects-menu>\n"
57                                 "<menu-tip>" N_("Colorize selected bitmap(s) with specified color, using given opacity.") "</menu-tip>\n"
58                         "</effect>\n"
59                 "</inkscape-extension>\n", new Colorize());
60 }
62 }; /* namespace Bitmap */
63 }; /* namespace Internal */
64 }; /* namespace Extension */
65 }; /* namespace Inkscape */