Inkscape
Vector Graphics Editor
level.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2007 Authors:
4 * Christopher Brown <audiere@gmail.com>
5 * Ted Gould <ted@gould.cx>
6 *
7 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
8 */
9
10#include "extension/effect.h"
11#include "extension/system.h"
12
13#include "level.h"
14#include <Magick++.h>
15
16namespace Inkscape {
17namespace Extension {
18namespace Internal {
19namespace Bitmap {
20
21void
22Level::applyEffect(Magick::Image* image) {
23 Magick::Quantum black_point = Magick::Color::scaleDoubleToQuantum(_black_point / 100.0);
24 Magick::Quantum white_point = Magick::Color::scaleDoubleToQuantum(_white_point / 100.0);
25 image->level(black_point, white_point, _mid_point);
26}
27
28void
30 _black_point = module->get_param_float("blackPoint");
31 _white_point = module->get_param_float("whitePoint");
32 _mid_point = module->get_param_float("midPoint");
33}
34
35#include "../clear-n_.h"
36
37void
39{
40 // clang-format off
42 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
43 "<name>" N_("Level") "</name>\n"
44 "<id>org.inkscape.effect.bitmap.level</id>\n"
45 "<param name=\"blackPoint\" gui-text=\"" N_("Black Point:") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n"
46 "<param name=\"whitePoint\" gui-text=\"" N_("White Point:") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n"
47 "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n"
48 "<effect>\n"
49 "<object-type>all</object-type>\n"
50 "<effects-menu>\n"
51 "<submenu name=\"" N_("Raster") "\" />\n"
52 "</effects-menu>\n"
53 "<menu-tip>" N_("Level selected bitmap(s) by scaling values falling between the given ranges to the full color range") "</menu-tip>\n"
54 "</effect>\n"
55 "</inkscape-extension>\n", std::make_unique<Level>());
56 // clang-format on
57}
58
59}; /* namespace Bitmap */
60}; /* namespace Internal */
61}; /* namespace Extension */
62}; /* namespace Inkscape */
Effects are extensions that take a document and do something to it in place.
Definition: effect.h:39
double get_param_float(char const *name) const
Gets a float parameter identified by name with the double placed in value.
Definition: extension.cpp:690
virtual unsigned image(Inkscape::Extension::Print *, unsigned char *, unsigned int, unsigned int, unsigned int, Geom::Affine const &, SPStyle const *)
void refreshParameters(Inkscape::Extension::Effect *module) override
Definition: level.cpp:29
void applyEffect(Magick::Image *image) override
Definition: level.cpp:22
std::unique_ptr< Magick::Image > image
Definition: imagemagick.cpp:40
void build_from_mem(gchar const *buffer, std::unique_ptr< Implementation::Implementation > in_imp)
Create a module from a buffer holding an XML description.
Definition: system.cpp:471
CMYK to sRGB conversion routines.