Code

5890aa9f11556b4f11a1a93a5ae07e92df6e9bb2
[inkscape.git] / src / extension / internal / bitmap / level.cpp
1 /*
2  * Copyright (C) 2007 Authors:
3  *   Christopher Brown <audiere@gmail.com>
4  *   Ted Gould <ted@gould.cx>
5  *   
6  * Released under GNU GPL, read the file 'COPYING' for more information
7  */
9 #include "extension/effect.h"
10 #include "extension/system.h"
12 #include "level.h"
14 namespace Inkscape {
15 namespace Extension {
16 namespace Internal {
17 namespace Bitmap {
18         
19 void
20 Level::applyEffect(Magick::Image* image) {
21         Magick::Quantum black_point = Magick::Color::scaleDoubleToQuantum(_black_point / 100.0);
22         Magick::Quantum white_point = Magick::Color::scaleDoubleToQuantum(_white_point / 100.0);
23         image->level(black_point, white_point, _mid_point);
24 }
26 void
27 Level::refreshParameters(Inkscape::Extension::Effect* module) {
28         _black_point = module->get_param_float("blackPoint");
29         _white_point = module->get_param_float("whitePoint");
30         _mid_point = module->get_param_float("midPoint");
31 }
33 #include "../clear-n_.h"
35 void
36 Level::init(void)
37 {
38         Inkscape::Extension::build_from_mem(
39                 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
40                         "<name>" N_("Level") "</name>\n"
41                         "<id>org.inkscape.effect.bitmap.level</id>\n"
42                         "<param name=\"blackPoint\" gui-text=\"" N_("Black Point") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n"                        
43                         "<param name=\"whitePoint\" gui-text=\"" N_("White Point") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n"                      
44                         "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n"
45                         "<effect>\n"
46                                 "<object-type>all</object-type>\n"
47                                 "<effects-menu>\n"
48                                         "<submenu name=\"" N_("Raster") "\" />\n"
49                                 "</effects-menu>\n"
50                                 "<menu-tip>" N_("Level selected bitmap(s) by scaling values falling between the given ranges to the full color range.") "</menu-tip>\n"
51                         "</effect>\n"
52                 "</inkscape-extension>\n", new Level());
53 }
55 }; /* namespace Bitmap */
56 }; /* namespace Internal */
57 }; /* namespace Extension */
58 }; /* namespace Inkscape */