1 /*
2 delaboratory - color correction utility
3 Copyright (C) 2011 Jacek Poplawski
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "fill_layer.h"
20 #include "fill_channel.h"
21 #include "preset.h"
22 #include "color_space_utils.h"
23
deFillLayer(deColorSpace _colorSpace,deChannelManager & _channelManager,int _sourceLayer,deLayerStack & _layerStack)24 deFillLayer::deFillLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack)
25 :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack)
26 {
27 dePreset* reset = createPreset("reset");
28 int n = getColorSpaceSize(colorSpace);
29
30 int i;
31 for (i = 0; i < n; i++)
32 {
33 std::string n = "fill " + getChannelName(colorSpace, i);
34 createPropertyNumeric(n, 0, 1);
35 reset->addNumericValue(n, 0.5);
36 }
37
38 applyPreset("reset");
39 setOpacity(0.5);
40 }
41
~deFillLayer()42 deFillLayer::~deFillLayer()
43 {
44 }
45
updateMainImageSingleChannel(int channel)46 bool deFillLayer::updateMainImageSingleChannel(int channel)
47 {
48 /*
49 if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel)))
50 {
51 int s = getSourceImage().getChannelIndex(channel);
52 mainLayerImage.disableChannel(channel, s);
53 return true;
54 }
55 */
56 // mainLayerImage.enableChannel(channel);
57
58 std::string p = "fill " + getChannelName(colorSpace, channel);
59
60 deValue value = getNumericValue(p);
61 deValue* destination = mainLayerImage.startWrite(channel);
62 int n = mainLayerImage.getChannelSize().getN();
63
64 fillChannel(destination, n, value);
65
66 mainLayerImage.finishWrite(channel);
67
68 return true;
69 }
70
71