diff -Nru delaboratory-0.7/algorithms/blend_channel.cc delaboratory-0.8/algorithms/blend_channel.cc --- delaboratory-0.7/algorithms/blend_channel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_channel.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,66 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "blend_channel.h" +#include +#include "logger.h" + +void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize) +{ + if (!sourcePixels) + { + logError("no source pixels in blend channel"); + return; + } + if (!overlayPixels) + { + logError("no overlay pixels in blend channel"); + return; + } + if (!resultPixels) + { + logError("no result pixels in blend channel"); + return; + } + + int j; + if (maskPixels) + { + for (j = 0; j < channelSize; j++) + { + deValue src = sourcePixels[j]; + deValue ov = overlayPixels[j]; + deValue dst = calcBlendResult(src, ov, blendMode); + deValue m = maskPixels[j] * opacity; + deValue result = (1 - m) * src + m * dst; + resultPixels[j] = result; + } + } + else + { + for (j = 0; j < channelSize; j++) + { + deValue src = sourcePixels[j]; + deValue ov = overlayPixels[j]; + deValue dst = calcBlendResult(src, ov, blendMode); + deValue result = (1 - opacity) * src + opacity * dst; + resultPixels[j] = result; + } + } +} + diff -Nru delaboratory-0.7/algorithms/blend_channel.h delaboratory-0.8/algorithms/blend_channel.h --- delaboratory-0.7/algorithms/blend_channel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_channel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,27 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BLEND_CHANNEL_H +#define _DE_BLEND_CHANNEL_H + +#include "value.h" +#include "blend_mode.h" + +void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize); + +#endif diff -Nru delaboratory-0.7/algorithms/blend_color_luminosity.cc delaboratory-0.8/algorithms/blend_color_luminosity.cc --- delaboratory-0.7/algorithms/blend_color_luminosity.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_color_luminosity.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,314 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "blend_color_luminosity.h" +#include "conversion_cpu.h" + +void blendColorRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) +{ + deConversionCPU cpu(3); + int i; + for (i = 0; i < n; i++) + { + deValue rs = source0[i]; + deValue gs = source1[i]; + deValue bs = source2[i]; + + cpu.input[0] = rs; + cpu.input[1] = gs; + cpu.input[2] = bs; + + rgb2lab(cpu); + + deValue L = cpu.output[0]; + + deValue ro = overlay0[i]; + deValue go = overlay1[i]; + deValue bo = overlay2[i]; + + cpu.input[0] = ro; + cpu.input[1] = go; + cpu.input[2] = bo; + + rgb2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2rgb(cpu); + + deValue r = cpu.output[0]; + deValue g = cpu.output[1]; + deValue b = cpu.output[2]; + + destination0[i] = (1 - o) * rs + o * r; + destination1[i] = (1 - o) * gs + o * g; + destination2[i] = (1 - o) * bs + o * b; + } +} + +void blendLuminosityRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) +{ + deConversionCPU cpu(3); + int i; + for (i = 0; i < n; i++) + { + deValue rs = source0[i]; + deValue gs = source1[i]; + deValue bs = source2[i]; + + cpu.input[0] = rs; + cpu.input[1] = gs; + cpu.input[2] = bs; + + rgb2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + deValue ro = overlay0[i]; + deValue go = overlay1[i]; + deValue bo = overlay2[i]; + + cpu.input[0] = ro; + cpu.input[1] = go; + cpu.input[2] = bo; + + rgb2lab(cpu); + + deValue L = cpu.output[0]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2rgb(cpu); + + deValue r = cpu.output[0]; + deValue g = cpu.output[1]; + deValue b = cpu.output[2]; + + destination0[i] = (1 - o) * rs + o * r; + destination1[i] = (1 - o) * gs + o * g; + destination2[i] = (1 - o) * bs + o * b; + } +} + +void blendColorProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) +{ + deConversionCPU cpu(3); + int i; + for (i = 0; i < n; i++) + { + deValue rs = source0[i]; + deValue gs = source1[i]; + deValue bs = source2[i]; + + cpu.input[0] = rs; + cpu.input[1] = gs; + cpu.input[2] = bs; + + prophoto2lab(cpu); + + deValue L = cpu.output[0]; + + deValue ro = overlay0[i]; + deValue go = overlay1[i]; + deValue bo = overlay2[i]; + + cpu.input[0] = ro; + cpu.input[1] = go; + cpu.input[2] = bo; + + prophoto2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2prophoto(cpu); + + deValue r = cpu.output[0]; + deValue g = cpu.output[1]; + deValue b = cpu.output[2]; + + destination0[i] = (1 - o) * rs + o * r; + destination1[i] = (1 - o) * gs + o * g; + destination2[i] = (1 - o) * bs + o * b; + } +} + +void blendLuminosityProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) +{ + deConversionCPU cpu(3); + int i; + for (i = 0; i < n; i++) + { + deValue rs = source0[i]; + deValue gs = source1[i]; + deValue bs = source2[i]; + + cpu.input[0] = rs; + cpu.input[1] = gs; + cpu.input[2] = bs; + + prophoto2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + deValue ro = overlay0[i]; + deValue go = overlay1[i]; + deValue bo = overlay2[i]; + + cpu.input[0] = ro; + cpu.input[1] = go; + cpu.input[2] = bo; + + prophoto2lab(cpu); + + deValue L = cpu.output[0]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2prophoto(cpu); + + deValue r = cpu.output[0]; + deValue g = cpu.output[1]; + deValue b = cpu.output[2]; + + destination0[i] = (1 - o) * rs + o * r; + destination1[i] = (1 - o) * gs + o * g; + destination2[i] = (1 - o) * bs + o * b; + } +} + +void blendColorCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o) +{ + deConversionCPU cpu(4); + int i; + for (i = 0; i < n; i++) + { + deValue cs = source0[i]; + deValue ms = source1[i]; + deValue ys = source2[i]; + deValue ks = source3[i]; + + cpu.input[0] = cs; + cpu.input[1] = ms; + cpu.input[2] = ys; + cpu.input[3] = ks; + + cmyk2lab(cpu); + + deValue L = cpu.output[0]; + + deValue co = overlay0[i]; + deValue mo = overlay1[i]; + deValue yo = overlay2[i]; + deValue ko = overlay3[i]; + + cpu.input[0] = co; + cpu.input[1] = mo; + cpu.input[2] = yo; + cpu.input[3] = ko; + + cmyk2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2cmyk(cpu); + + deValue c = cpu.output[0]; + deValue m = cpu.output[1]; + deValue y = cpu.output[2]; + deValue k = cpu.output[3]; + + destination0[i] = (1 - o) * cs + o * c; + destination1[i] = (1 - o) * ms + o * m; + destination2[i] = (1 - o) * ys + o * y; + destination3[i] = (1 - o) * ks + o * k; + } +} + +void blendLuminosityCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o) +{ + deConversionCPU cpu(4); + int i; + for (i = 0; i < n; i++) + { + deValue cs = source0[i]; + deValue ms = source1[i]; + deValue ys = source2[i]; + deValue ks = source3[i]; + + cpu.input[0] = cs; + cpu.input[1] = ms; + cpu.input[2] = ys; + cpu.input[3] = ks; + + cmyk2lab(cpu); + + deValue A = cpu.output[1]; + deValue B = cpu.output[2]; + + deValue co = overlay0[i]; + deValue mo = overlay1[i]; + deValue yo = overlay2[i]; + deValue ko = overlay3[i]; + + cpu.input[0] = co; + cpu.input[1] = mo; + cpu.input[2] = yo; + cpu.input[3] = ko; + + cmyk2lab(cpu); + + deValue L = cpu.output[0]; + + cpu.input[0] = L; + cpu.input[1] = A; + cpu.input[2] = B; + + lab2cmyk(cpu); + + deValue c = cpu.output[0]; + deValue m = cpu.output[1]; + deValue y = cpu.output[2]; + deValue k = cpu.output[3]; + + destination0[i] = (1 - o) * cs + o * c; + destination1[i] = (1 - o) * ms + o * m; + destination2[i] = (1 - o) * ys + o * y; + destination3[i] = (1 - o) * ks + o * k; + } +} diff -Nru delaboratory-0.7/algorithms/blend_color_luminosity.h delaboratory-0.8/algorithms/blend_color_luminosity.h --- delaboratory-0.7/algorithms/blend_color_luminosity.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_color_luminosity.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BLEND_COLOR_LUMINOSITY_H +#define _DE_BLEND_COLOR_LUMINOSITY_H + +#include "value.h" + +void blendColorRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); +void blendLuminosityRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); +void blendColorProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); +void blendLuminosityProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); +void blendColorCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o); +void blendLuminosityCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o); + +#endif diff -Nru delaboratory-0.7/algorithms/blend_mode.cc delaboratory-0.8/algorithms/blend_mode.cc --- delaboratory-0.7/algorithms/blend_mode.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_mode.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,355 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "blend_mode.h" +#include + +std::string getBlendModeName(deBlendMode mode) +{ + switch (mode) + { + case deBlendNormal: + return "normal"; + case deBlendNone: + return "none"; + case deBlendMultiply: + return "multiply"; + case deBlendScreen: + return "screen"; + case deBlendOverlay: + return "overlay"; + case deBlendOverlayInvert: + return "overlay invert"; + case deBlendAdd: + return "add"; + case deBlendGrainExtract: + return "graint extract"; + case deBlendGrainMerge: + return "graint merge"; + case deBlendSub: + return "sub"; + case deBlendDifference: + return "difference"; + case deBlendDarken: + return "darken"; + case deBlendLighten: + return "lighten"; + case deBlendDodge: + return "dodge"; + case deBlendBurn: + return "burn"; + case deBlendColor: + return "color"; + case deBlendLuminosity: + return "luminosity"; + default: + return "unknown"; + } +} + +deBlendMode blendModeFromString(const std::string& s) +{ + if (s == "normal") + { + return deBlendNormal; + } + + if (s == "none") + { + return deBlendNone; + } + + if (s == "multiply") + { + return deBlendMultiply; + } + + if (s == "screen") + { + return deBlendScreen; + } + + if (s == "overlay") + { + return deBlendOverlay; + } + + if (s == "overlay invert") + { + return deBlendOverlayInvert; + } + + if (s == "add") + { + return deBlendAdd; + } + + if (s == "grain extract") + { + return deBlendGrainExtract; + } + + if (s == "grain merge") + { + return deBlendGrainMerge; + } + + if (s == "sub") + { + return deBlendSub; + } + + if (s == "difference") + { + return deBlendDifference; + } + + if (s == "darken") + { + return deBlendDarken; + } + + if (s == "lighten") + { + return deBlendLighten; + } + + if (s == "dodge") + { + return deBlendDodge; + } + + if (s == "burn") + { + return deBlendBurn; + } + + if (s == "color") + { + return deBlendColor; + } + + if (s == "luminosity") + { + return deBlendLuminosity; + } + + return deBlendInvalid; + +} + +std::vector getSupportedBlendModes(deColorSpace colorSpace) +{ + std::vector result; + + result.push_back(deBlendNormal); + result.push_back(deBlendNone); + result.push_back(deBlendMultiply); + result.push_back(deBlendScreen); + result.push_back(deBlendOverlay); + result.push_back(deBlendOverlayInvert); + result.push_back(deBlendAdd); + result.push_back(deBlendGrainExtract); + result.push_back(deBlendGrainMerge); + result.push_back(deBlendSub); + result.push_back(deBlendDifference); + result.push_back(deBlendDarken); + result.push_back(deBlendLighten); + result.push_back(deBlendDodge); + result.push_back(deBlendBurn); + + if ((colorSpace == deColorSpaceRGB) || (colorSpace == deColorSpaceProPhoto) || (colorSpace == deColorSpaceCMYK)) + { + result.push_back(deBlendColor); + result.push_back(deBlendLuminosity); + } + + return result; +} + +std::vector getSupportedBlendModeNames(deColorSpace colorSpace) +{ + std::vector modes = getSupportedBlendModes(colorSpace); + std::vector result; + std::vector::const_iterator i; + for (i = modes.begin(); i != modes.end(); i++) + { + result.push_back(getBlendModeName(*i)); + } + return result; +} + +deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode) +{ + switch (mode) + { + case deBlendNormal: + return v2; + break; + case deBlendNone: + return src; + break; + case deBlendMultiply: + return src*v2; + break; + case deBlendScreen: + return 1 - (1-src)*(1-v2); + break; + case deBlendOverlay: + if (src > 0.5) + { + return 1 - (1 - 2 * ( src - 0.5)) * (1 - v2); + } + else + { + return 2 * src * v2; + } + break; + case deBlendOverlayInvert: + if (src > 0.5) + { + return 1 - (1 - 2 * ( src - 0.5)) * v2; + } + else + { + return 2 * src * (1 - v2); + } + break; + case deBlendAdd: + { + deValue v = src + v2; + if (v < 0) + { + return 0; + } + if (v > 1) + { + return 1; + } + return v; + break; + } + case deBlendGrainExtract: + { + deValue v = 0.5 + src - v2; + if (v < 0) + { + return 0; + } + if (v > 1) + { + return 1; + } + return v; + break; + } + case deBlendGrainMerge: + { + deValue v = src + v2 - 0.5; + if (v < 0) + { + return 0; + } + if (v > 1) + { + return 1; + } + return v; + break; + } + case deBlendSub: + { + deValue v = src - v2; + if (v < 0) + { + return 0; + } + if (v > 1) + { + return 1; + } + return v; + break; + } + case deBlendDifference: + return fabs(src - v2); + break; + case deBlendDarken: + if (src < v2) + { + return src; + } + else + { + return v2; + } + break; + case deBlendLighten: + if (src > v2) + { + return src; + } + else + { + return v2; + } + break; + case deBlendDodge: + { + deValue d = 1 - v2; + if (d == 0) + { + return 1.0; + } + else + { + deValue r = src / d; + if ( r > 1) + { + return 1; + } + else + { + return r; + } + } + break; + } + case deBlendBurn: + { + if (v2 == 0) + { + return 0.0; + } + else + { + deValue v = (1 - src) / v2; + if (v > 1) + { + v = 1; + } + deValue r = 1 - v; + return r; + } + break; + } + default: + return 0; + } +} + diff -Nru delaboratory-0.7/algorithms/blend_mode.h delaboratory-0.8/algorithms/blend_mode.h --- delaboratory-0.7/algorithms/blend_mode.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blend_mode.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BLEND_MODES_H +#define _DE_BLEND_MODES_H + +#include +#include +#include "value.h" +#include "color_space.h" + +enum deBlendMode +{ + deBlendInvalid, + deBlendNormal, + deBlendNone, + deBlendMultiply, + deBlendScreen, + deBlendOverlay, + deBlendOverlayInvert, + deBlendDodge, + deBlendBurn, + deBlendAdd, + deBlendGrainExtract, + deBlendGrainMerge, + deBlendSub, + deBlendDifference, + deBlendDarken, + deBlendLighten, + deBlendColor, + deBlendLuminosity +}; + +std::string getBlendModeName(deBlendMode mode); +deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode); +deBlendMode blendModeFromString(const std::string& s); +std::vector getSupportedBlendModeNames(deColorSpace colorSpace); + +#endif diff -Nru delaboratory-0.7/algorithms/blur.cc delaboratory-0.8/algorithms/blur.cc --- delaboratory-0.7/algorithms/blur.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blur.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,359 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "blur.h" +#include +#include +#include "logger.h" + +void boxBlur(deValue* source, deValue* destination, int n, int s) +{ + int i; + for (i = 0; i < n; i++) + { + deValue result = 0.0; + + int n1 = i - s + 1; + int n2 = i + s - 1; + if (n1 < 0) + { + n1 = 0; + } + + if (n2 >= n) + { + n2 = n - 1; + } + + int j; + for (j = n1; j <= n2; j++) + { + result += source[j]; + } + destination[i] = result / (n2 - n1 + 1.0); + } +} + +void gaussianBlur(deValue* source, deValue* destination, int n, int s, deValue* weights) +{ + int i; + for (i = 0; i < n; i++) + { + deValue result = 0.0; + deValue sum = 0.0; + + int n1 = i - s + 1; + int n2 = i + s - 1; + if (n1 < 0) + { + n1 = 0; + } + + if (n2 >= n) + { + n2 = n - 1; + } + + int j; + int p; + + j = n1; + p = i - n1; + while (p >= 0) + { + deValue v = source[j]; + deValue w = weights[p]; + result += w * v; + sum += w; + + p--; + j++; + } + p = 1; + while (j <= n2) + { + + deValue v = source[j]; + deValue w = weights[p]; + result += w * v; + sum += w; + + p++; + j++; + } + + destination[i] = result / sum; + } +} + +void surfaceBlur(deValue* source, deValue* destination, int n, int s, deValue* weights, deValue t) +{ + deValue tt = 1.0 - t; + + int i; + for (i = 0; i < n; i++) + { + deValue result = 0.0; + deValue sum = 0.0; + + deValue reference = source[i]; + + int n1 = i - s + 1; + int n2 = i + s - 1; + if (n1 < 0) + { + n1 = 0; + } + + if (n2 >= n) + { + n2 = n - 1; + } + + int j; + int p; + + j = n1; + p = i - n1; + while (p >= 0) + { + deValue v = source[j]; + if (fabs(v - reference) <= tt) + { + deValue w = weights[p]; + result += w * v; + sum += w; + } + + p--; + j++; + } + p = 1; + while (j <= n2) + { + + deValue v = source[j]; + if (fabs(v - reference) <= tt) + { + deValue w = weights[p]; + result += w * v; + sum += w; + } + + p++; + j++; + } + + + destination[i] = result / sum; + } +} + +void fillWeightsFlat(deValue* weights, int blurSize) +{ + int i; + for (i = 0 ; i < blurSize; i++) + { + weights[i] = 1.0; + } +} + +void fillWeightsGaussian(deValue* weights, int blurSize) +{ + int i; + deValue radius = blurSize / 3.0; + deValue rr2 = 2.0 * radius * radius; + for (i = 0 ; i < blurSize; i++) + { + deValue ii = i * i; + deValue ee = exp( - ii / rr2 ); + weights[i] = 1.0 / sqrt(rr2 * M_PI) * ee; + } +} + +bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t) +{ + assert(source); + assert(destination); + + int w = size.getW(); + int h = size.getH(); + + if (w == 0) + { + return false; + } + + if (h == 0) + { + return false; + } + + if ((radiusX <= 0) || (radiusY <= 0)) + { + return false; + } + + assert(w > 0); + assert(h > 0); + + int min = 1; + + int blurSizeW = radiusX; + if (blurSizeW < min) + { + blurSizeW = min; + } + int blurSizeH = radiusY; + if (blurSizeH < min) + { + blurSizeH = min; + } + + int maxSize = blurSizeW; + if (blurSizeH > maxSize) + { + maxSize = blurSizeH; + } + + int max = w; + if (h > max) + { + max = h; + } + + deValue* tmp = NULL; + + try + { + tmp = new deValue[size.getN()]; + } + catch (std::bad_alloc) + { + logError("allocating memory in blur"); + if (tmp) + { + delete [] tmp; + } + return false; + } + + deValue* sourceBuffer = new deValue[max]; + deValue* destinationBuffer = new deValue[max]; + deValue* weights = NULL; + + + if (type != deBoxBlur) + { + weights = new deValue[maxSize]; + } + + int i; + int j; + + { + if (type != deBoxBlur) + { + fillWeightsGaussian(weights, blurSizeW); + } + + for (i = 0; i < h; i++) + { + int p = i * w; + for (j = 0; j < w; j++) + { + sourceBuffer[j] = source[p + j]; + } + switch (type) + { + case deBoxBlur: + { + boxBlur(sourceBuffer, destinationBuffer, w, blurSizeW); + break; + } + case deGaussianBlur: + { + gaussianBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights); + break; + } + case deSurfaceBlur: + { + surfaceBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights, t); + break; + } + default: + break; + } + for (j = 0; j < w; j++) + { + tmp[p + j] = destinationBuffer[j]; + } + } + } + + + { + if (type != deBoxBlur) + { + fillWeightsGaussian(weights, blurSizeH); + } + + for (i = 0; i < w; i++) + { + for (j = 0; j < h; j++) + { + sourceBuffer[j] = tmp[j * w + i]; + } + switch (type) + { + case deBoxBlur: + { + boxBlur(sourceBuffer, destinationBuffer, h, blurSizeH); + break; + } + case deGaussianBlur: + { + gaussianBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights); + break; + } + case deSurfaceBlur: + { + surfaceBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights, t); + break; + } + default: + break; + } + for (j = 0; j < h; j++) + { + destination[j * w + i] = destinationBuffer[j]; + } + } + } + + delete [] tmp; + if (type != deBoxBlur) + { + delete [] weights; + } + delete [] destinationBuffer; + delete [] sourceBuffer; + + return true; +} + diff -Nru delaboratory-0.7/algorithms/blur.h delaboratory-0.8/algorithms/blur.h --- delaboratory-0.7/algorithms/blur.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blur.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BLUR_H +#define _DE_BLUR_H + +#include "value.h" +#include "blur_type.h" +#include "size.h" + +bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t); + +#endif diff -Nru delaboratory-0.7/algorithms/blur_type.cc delaboratory-0.8/algorithms/blur_type.cc --- delaboratory-0.7/algorithms/blur_type.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blur_type.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,68 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "blur_type.h" + +std::string getBlurTypeName(deBlurType type) +{ + switch (type) + { + case deBoxBlur: + return "box"; + case deGaussianBlur: + return "gaussian"; + case deSurfaceBlur: + return "surface"; + default: + return "unknown"; + } +} + +deBlurType blurTypeFromString(const std::string& s) +{ + if (s == "box") + { + return deBoxBlur; + } + if (s == "gaussian") + { + return deGaussianBlur; + } + if (s == "surface") + { + return deSurfaceBlur; + } + + return deBlurInvalid; +} + +void getSupportedBlurTypes(std::vector& result) +{ + result.push_back(deBoxBlur); + result.push_back(deGaussianBlur); + result.push_back(deSurfaceBlur); +} + +std::vector getSupportedBlurTypes() +{ + std::vector result; + result.push_back("box"); + result.push_back("gaussian"); + result.push_back("surface"); + return result; +} diff -Nru delaboratory-0.7/algorithms/blur_type.h delaboratory-0.8/algorithms/blur_type.h --- delaboratory-0.7/algorithms/blur_type.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/blur_type.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BLUR_TYPE_H +#define _DE_BLUR_TYPE_H + +#include +#include + +enum deBlurType +{ + deBlurInvalid, + deBoxBlur, + deGaussianBlur, + deSurfaceBlur +}; + +std::string getBlurTypeName(deBlurType type); +deBlurType blurTypeFromString(const std::string& s); +void getSupportedBlurTypes(std::vector& result); +std::vector getSupportedBlurTypes(); + +#endif diff -Nru delaboratory-0.7/algorithms/c2g.cc delaboratory-0.8/algorithms/c2g.cc --- delaboratory-0.7/algorithms/c2g.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/c2g.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,154 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "c2g.h" +#include +#include + +#include "radial_lut.h" +#include "logger.h" +#include "str.h" + +void c2g(const deValue* source0, const deValue* source1, const deValue* source2, deValue* mask, const deSize& size, deValue r, int samples) +{ + int w = size.getW(); + int h = size.getH(); + + int lutsize = 10 * 1024; + deRadialLUT lut(lutsize, r); + + int* offsets = new int [samples]; + + int x; + for (x = 0; x < w; x++) + { + int y; + for (y = 0; y < h; y++) + { + int p = w * y + x; + deValue v0 = source0[p]; + deValue v1 = source1[p]; + deValue v2 = source2[p]; + + deValue min0 = 1.0; + deValue max0 = 0.0; + deValue min1 = 1.0; + deValue max1 = 0.0; + deValue min2 = 1.0; + deValue max2 = 0.0; + + int offset = lut.getStart(samples); + + int i = 0; + while (i < samples) + { + int xx; + int yy; + lut.get(offset, xx, yy); + xx += x; + yy += y; + if ((xx >= 0) && (xx < w) && (yy >= 0) && (yy < h)) + { + int pp = w * yy + xx; + offsets[i] = pp; + i++; + } + + offset++; + if (offset >= lutsize) + { + offset = 0; + } + } + + for (i = 0; i < samples; i++) + { + int pp = offsets[i]; + + deValue vv0 = source0[pp]; + deValue vv1 = source1[pp]; + deValue vv2 = source2[pp]; + + if (vv0 < min0) + { + min0 = vv0; + } + if (vv0 > max0) + { + max0 = vv0; + } + + if (vv1 < min1) + { + min1 = vv1; + } + if (vv1 > max1) + { + max1 = vv1; + } + + if (vv2 < min2) + { + min2 = vv2; + } + if (vv2 > max2) + { + max2 = vv2; + } + } + + deValue n0 = v0 - min0; + deValue d0 = v0 - max0; + deValue n1 = v1 - min1; + deValue d1 = v1 - max1; + deValue n2 = v2 - min2; + deValue d2 = v2 - max2; + + deValue n = sqrt(n0 * n0 + n1 * n1 + n2 * n2); + deValue d = sqrt(d0 * d0 + d1 * d1 + d2 * d2); + + d = d + n; + + deValue result; + + if (d != 0) + { + result = n / d; + + if (result < 0) + { + result = 0; + } + else if (result > 1) + { + result = 1; + } + } + else + { + result = (v0 + v1 + v2) / 3.0; + } + + mask[p] = result; + } + } + + delete [] offsets; + +} + diff -Nru delaboratory-0.7/algorithms/c2g.h delaboratory-0.8/algorithms/c2g.h --- delaboratory-0.7/algorithms/c2g.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/c2g.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,27 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_C2G_H +#define _DE_C2G_H + +#include "value.h" +#include "size.h" + +void c2g(const deValue* source0, const deValue* source1, const deValue* source2, deValue* mask, const deSize& size, deValue r, int samples); + +#endif diff -Nru delaboratory-0.7/algorithms/fill_channel.cc delaboratory-0.8/algorithms/fill_channel.cc --- delaboratory-0.7/algorithms/fill_channel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/fill_channel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,29 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "fill_channel.h" + +void fillChannel(deValue* dst, int n, deValue v) +{ + int i; + for (i = 0; i < n; i++) + { + dst[i] = v; + } +} + diff -Nru delaboratory-0.7/algorithms/fill_channel.h delaboratory-0.8/algorithms/fill_channel.h --- delaboratory-0.7/algorithms/fill_channel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/fill_channel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COPY_CHANNEL_H +#define _DE_COPY_CHANNEL_H + +#include "value.h" + +void fillChannel(deValue* dst, int n, deValue v); + +#endif diff -Nru delaboratory-0.7/algorithms/gradient.cc delaboratory-0.8/algorithms/gradient.cc --- delaboratory-0.7/algorithms/gradient.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/gradient.cc 2012-07-01 16:53:40.000000000 +0000 @@ -0,0 +1,103 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gradient.h" +#include +#include +#include "logger.h" +#include "str.h" + +void gradientChannel(deValue* destination, deSize size, deValue cx, deValue cy, deValue r, deValue a, deValue sinus) +{ + int w = size.getW(); + int h = size.getH(); + + if (w == 0) + { + return; + } + + if (h == 0) + { + return; + } + + deValue ww = w / 2.0; + deValue hh = h / 2.0; + + int i; + int j; + + int p = 0; + + deValue angle = 2 * M_PI * (a / 360.0); + deValue vx = sin (angle); + deValue vy = cos (angle); + + deValue div; + + if (r > 0) + { + div = 1.0 / (r + 0.1); + } + else + { + div = 1.0 / (r - 0.1); + } + + for (i = 0; i < h; i++) + { + deValue y = (i - hh) / hh; + + deValue yy = y - cy; + + for (j = 0; j < w; j++) + { + deValue x = (j - ww) / ww; + + deValue xx = x - cx; + + deValue rr = (yy * vy + xx * vx) * div; + + rr = 1.0 - rr; + + if (sinus > 0) + { + rr = 1.0 - sin (sinus * rr * M_PI); + } + else if (sinus < 0) + { + rr = sin (sinus * rr * M_PI); + } + + if (rr < 0) + { + rr = -rr; + } + if (rr > 1) + { + rr = 1; + } + + + + destination[p] = rr; + p++; + } + } +} diff -Nru delaboratory-0.7/algorithms/gradient.h delaboratory-0.8/algorithms/gradient.h --- delaboratory-0.7/algorithms/gradient.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/gradient.h 2012-07-01 13:24:19.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GRADIENT_H +#define _DE_GRADIENT_H + +#include "value.h" +#include "size.h" + +void gradientChannel(deValue* destination, deSize size, deValue cx, deValue cy, deValue r, deValue a, deValue sinus); + + +#endif diff -Nru delaboratory-0.7/algorithms/radial_lut.cc delaboratory-0.8/algorithms/radial_lut.cc --- delaboratory-0.7/algorithms/radial_lut.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/radial_lut.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,62 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "radial_lut.h" +#include +#include "value.h" +#include + +deRadialLUT::deRadialLUT(int _size, int r) +:size(_size) +{ + lut = new int [2 * size]; + + srand(0); + + int i; + + for (i = 0; i < size; i++) + { + deValue angle = (rand () % 1024) / 1024.0 * 2 * M_PI; + deValue radius_1 = ((rand () % 1024) / 1024.0 * r + 1.0); + deValue radius_2 = ((rand () % 1024) / 1024.0 * radius_1 + 1.0); + int xx = sin(angle) * radius_2; + int yy = cos(angle) * radius_2; + lut[2*i+0] = xx; + lut[2*i+1] = yy; + } +} + +deRadialLUT::~deRadialLUT() +{ + delete [] lut; +} + +void deRadialLUT::get(int i, int& x, int& y) const +{ + if ((i >= 0) && (i < size)) + { + x = lut[2*i+0]; + y = lut[2*i+1]; + } +} + +int deRadialLUT::getStart(int s) const +{ + return rand() % (size - s); +} diff -Nru delaboratory-0.7/algorithms/radial_lut.h delaboratory-0.8/algorithms/radial_lut.h --- delaboratory-0.7/algorithms/radial_lut.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/radial_lut.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,36 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RADIAL_LUT_H +#define _DE_RADIAL_LUT_H + +class deRadialLUT +{ + private: + int size; + int* lut; + public: + deRadialLUT(int _size, int r); + + virtual ~deRadialLUT(); + + void get(int i, int& x, int& y) const; + int getStart(int s) const; +}; + +#endif diff -Nru delaboratory-0.7/algorithms/sample_pixel.cc delaboratory-0.8/algorithms/sample_pixel.cc --- delaboratory-0.7/algorithms/sample_pixel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/sample_pixel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,113 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sample_pixel.h" + +deValue samplePixel(const deValue* src, int xx1, int xx2, int yy1, int yy2, bool mirrorX, bool mirrorY, int ws, int hs) +{ + if (xx1 < 0) + { + xx1 = 0; + } + else if (xx1 >= ws) + { + xx1 = ws - 1; + } + if (xx2 < 0) + { + xx2 = 0; + } + else if (xx2 >= ws) + { + xx2 = ws - 1; + } + if (yy1 < 0) + { + yy1 = 0; + } + else if (yy1 >= hs) + { + yy1 = hs - 1; + } + if (yy2 < 0) + { + yy2 = 0; + } + else if (yy2 >= hs) + { + yy2 = hs - 1; + } + + int n = 0; + int x0; + int y0; + deValue value = 0.0; + + if ((!mirrorX) && (!mirrorY)) + { + for (x0 = xx1; x0 <= xx2; x0++) + { + for (y0 = yy1; y0 <= yy2; y0++) + { + value += src[x0 + y0 * ws]; + n++; + } + } + } + if ((mirrorX) && (!mirrorY)) + { + for (x0 = xx1; x0 <= xx2; x0++) + { + for (y0 = yy1; y0 <= yy2; y0++) + { + value += src[(ws - 1 - x0) + y0 * ws]; + n++; + } + } + } + if ((!mirrorX) && (mirrorY)) + { + for (x0 = xx1; x0 <= xx2; x0++) + { + for (y0 = yy1; y0 <= yy2; y0++) + { + value += src[x0 + (hs - 1 - y0) * ws]; + n++; + } + } + } + if ((mirrorX) && (mirrorY)) + { + for (x0 = xx1; x0 <= xx2; x0++) + { + for (y0 = yy1; y0 <= yy2; y0++) + { + value += src[(ws - 1 - x0) + (hs - 1 - y0) * ws]; + n++; + } + } + } + + if (n == 0) + { + return 0.0; + } + + return value / n; +} + diff -Nru delaboratory-0.7/algorithms/sample_pixel.h delaboratory-0.8/algorithms/sample_pixel.h --- delaboratory-0.7/algorithms/sample_pixel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/sample_pixel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SAMPLE_PIXEL_H +#define _DE_SAMPLE_PIXEL_H + +#include "value.h" + +deValue samplePixel(const deValue* src, int xx1, int xx2, int yy1, int yy2, bool mirrorX, bool mirrorY, int ws, int hs); + +#endif diff -Nru delaboratory-0.7/algorithms/scale_channel.cc delaboratory-0.8/algorithms/scale_channel.cc --- delaboratory-0.7/algorithms/scale_channel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/scale_channel.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,99 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "scale_channel.h" +#include "sample_pixel.h" + +void scaleChannel(const deValue* src, deValue* dst, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, int w, int h, bool mirrorX, bool mirrorY, int rotate, int ws, int hs, deValue contrast) +{ + int x1; + int y1; + int x2; + int y2; + x1 = ws * z_x1; + y1 = hs * z_y1; + x2 = ws * z_x2; + y2 = hs * z_y2; + if ((rotate == 90) || (rotate == 270)) + { + x1 = hs * z_x1; + y1 = ws * z_y1; + x2 = hs * z_x2; + y2 = ws * z_y2; + } + + deValue scaleW; + deValue scaleH; + + deValue dx = x2 - x1; + deValue dy = y2 - y1; + + scaleW = dx / w; + scaleH = dy / h; + + if (scaleW <= 0) + { + } + if (scaleH <= 0) + { + } + + int yy1; + int yy2; + int xx1; + int xx2; + + int x; + for (x = 0; x < w; x++) + { + xx1 = scaleW * x; + xx2 = scaleW * (x + 1); + + int y; + for (y = 0; y < h; y++) + { + yy1 = scaleH * y; + yy2 = scaleH * (y + 1); + + deValue v = 1; + + if (rotate == 0) + { + v = samplePixel(src, x1 + xx1, x1 + xx2, y1 + yy1, y1 + yy2, mirrorX, mirrorY, ws, hs); + } + if (rotate == 90) + { + v = samplePixel(src, ws - 1 - yy2 - y1, ws - 1 - yy1 - y1, xx1 + x1, xx2 + x1, mirrorX, mirrorY, ws, hs); + } + if (rotate == 180) + { + v = samplePixel(src, ws - 1 - xx2 - x1, ws - 1 - xx1 - x1, hs - 1 - yy2 - y1, hs - 1 - yy1 - y1, mirrorX, mirrorY, ws, hs); + } + if (rotate == 270) + { + v = samplePixel(src, y1 + yy1, y1 + yy2, hs - 1 - xx2 - x1, hs - 1 - xx1 - x1, mirrorX, mirrorY, ws, hs); + } + + dst[y * w + x] = contrast * v + 0.5 - 0.5 * contrast; + + } + + } + +} + diff -Nru delaboratory-0.7/algorithms/scale_channel.h delaboratory-0.8/algorithms/scale_channel.h --- delaboratory-0.7/algorithms/scale_channel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/scale_channel.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SCALE_CHANNEL_H +#define _DE_SCALE_CHANNEL_H + +#include "value.h" + +void scaleChannel(const deValue* src, deValue* dst, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, int w, int h, bool mirrorX, bool mirrorY, int rotate, int ws, int hs, deValue contrast); + +#endif diff -Nru delaboratory-0.7/algorithms/usm.cc delaboratory-0.8/algorithms/usm.cc --- delaboratory-0.7/algorithms/usm.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/usm.cc 2012-06-16 17:43:16.000000000 +0000 @@ -0,0 +1,288 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "usm.h" +#include "logger.h" +#include "blur.h" +#include "blend_channel.h" +#include +#include "image.h" +#include "color_space_utils.h" + +void unsharpMask(const deValue* source, const deValue* mask, deValue* destination, int n, deValue a) +{ + int i; + for (i = 0; i < n; i++) + { + deValue src = source[i]; + deValue u = src - mask[i]; + + deValue d = src + a * u; + + if (d < 0) + { + destination[i] = 0; + } + else if (d > 1) + { + destination[i] = 1; + } + else + { + destination[i] = d; + } + } +} + +void unsharpMask(const deValue* source, const deValue* mask, deValue* destination, int n, deValue a, deValue t) +{ + int i; + for (i = 0; i < n; i++) + { + deValue src = source[i]; + deValue u = src - mask[i]; + + if (fabs(2 * u) >= t) + { + deValue d = src + a * u; + + if (d < 0) + { + destination[i] = 0; + } + else if (d > 1) + { + destination[i] = 1; + } + else + { + destination[i] = d; + } + } + else + { + destination[i] = src; + } + } +} + +bool unsharpMask(const deValue* source, deValue* destination, deSize& size, deValue a, deValue r, deValue t, deBlurType type) +{ + logInfo("unsharp mask start"); + int n = size.getN(); + + deValue* mask = NULL; + try + { + mask = new deValue [n]; + } + catch (std::bad_alloc) + { + logError("allocating memory in USM"); + if (mask) + { + delete [] mask; + } + return false; + } + + if (mask) + { + logInfo("mask allocated"); + } + else + { + logError("unable to allocate mask"); + } + + deValue b_t = 0.0; + + if (blurChannel(source, mask, size, r, r, type, b_t)) + { + if (t > 0) + { + unsharpMask(source, mask, destination, n, a, t); + } + else + { + unsharpMask(source, mask, destination, n, a); + } + } + + delete [] mask; + + logInfo("unsharp mask DONE"); + + return true; +} + +bool autoDodgeBurn(const deValue* source, deValue* destination, deSize& size, deValue r1, deValue r2, deValue t, bool burn) +{ + int n = size.getN(); + + deValue* mask1 = NULL; + try + { + mask1 = new deValue [n]; + } + catch (std::bad_alloc) + { + logError("allocating memory"); + if (mask1) + { + delete [] mask1; + } + return false; + } + + blurChannel(source, mask1, size, r1, r1, deBoxBlur, 0.0); + int i; + + t = 1 - t; + + if (burn) + { + + deValue d = 1.0 - t; + deValue s = 1.0 / d; + + for (i = 0; i < n; i++) + { + deValue v = 1.0 - mask1[i]; + if (v < t) + { + v = 0.0; + } + else + { + v = s * (v - t); + if (v < 0) + { + v = 0; + } + } + mask1[i] = v; + } + } + else + { + deValue d = 1.0 - t; + deValue s = 1.0 / d; + + for (i = 0; i < n; i++) + { + deValue v = mask1[i]; + if (v < t) + { + v = 0.0; + } + else + { + v = s * (v - t); + if (v > 1) + { + v = 1; + } + } + mask1[i] = v; + } + } + + + blurChannel(mask1, mask1, size, r2, r2, deBoxBlur, 0.0); + + deBlendMode mode = deBlendDodge; + if (burn) + { + mode = deBlendBurn; + } + + blendChannel(source, source, destination, mask1, mode, 1.0, n); + + delete [] mask1; + + return true; +} + +bool shadowsHighlights(deValue r, int channel, const deImage& sourceImage, deImage& mainLayerImage, bool shadows) +{ + deSize size = mainLayerImage.getChannelSize(); + int n = size.getN(); + + deValue* mask = NULL; + try + { + mask = new deValue [n]; + } + catch (std::bad_alloc) + { + logError("allocating memory"); + if (mask) + { + delete [] mask; + } + return false; + } + + const deValue* source = sourceImage.startRead(channel); + blurChannel(source, mask, size, r, r, deBoxBlur, 0.0); + sourceImage.finishRead(channel); + + int i; + int nc = getColorSpaceSize(sourceImage.getColorSpace()); + for (i = 0; i < nc; i++) + { + deValue* d = mainLayerImage.startWrite(i); + const deValue* s = sourceImage.startRead(i); + int j; + if (shadows) + { + for (j = 0; j < n; j++) + { + deValue v = s[j]; + deValue m = mask[j]; + deValue r = calcBlendResult(v, m, deBlendOverlayInvert); + if (r > v) + { + v = r; + } + d[j] = v; + } + } + else + { + for (j = 0; j < n; j++) + { + deValue v = s[j]; + deValue m = mask[j]; + deValue r = calcBlendResult(v, m, deBlendOverlayInvert); + if (r < v) + { + v = r; + } + d[j] = v; + } + } + sourceImage.finishRead(i); + mainLayerImage.finishWrite(i); + } + + delete [] mask; + + return true; +} diff -Nru delaboratory-0.7/algorithms/usm.h delaboratory-0.8/algorithms/usm.h --- delaboratory-0.7/algorithms/usm.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/usm.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_USM_H +#define _DE_USM_H + +#include "value.h" +#include "size.h" +#include "blur.h" +class deImage; + +bool unsharpMask(const deValue* source, deValue* destination, deSize& size, deValue a, deValue r, deValue t, deBlurType type); +bool autoDodgeBurn(const deValue* source, deValue* destination, deSize& size, deValue r1, deValue r2, deValue t, bool burn); +bool shadowsHighlights(deValue r, int channel, const deImage& sourceImage, deImage& mainLayerImage, bool shadows); + +#endif diff -Nru delaboratory-0.7/algorithms/vignette.cc delaboratory-0.8/algorithms/vignette.cc --- delaboratory-0.7/algorithms/vignette.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/vignette.cc 2012-06-16 17:23:38.000000000 +0000 @@ -0,0 +1,173 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "vignette.h" +#include +#include +#include "logger.h" +#include "str.h" + +deEllipse::deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY) +:centerX(_centerX), + centerY(_centerY), + radiusX(_radiusX), + radiusY(_radiusY) +{ +} + +deEllipse::~deEllipse() +{ +} + +deValue deEllipse::processX(deValue x) const +{ + x = x - centerX; + + x /= radiusX; + + return x; +} + +deValue deEllipse::processY(deValue y) const +{ + y = y - centerY; + + y /= radiusY; + + return y; +} + +bool deEllipse::isValid() const +{ + if (radiusX <= 0.0) + { + return false; + } + if (radiusY <= 0.0) + { + return false; + } + + return true; +} + +void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot) +{ + logInfo("vignette start"); + if (!destination) + { + logError("NULL channel in vignette"); + return; + } + + if (!ellipse.isValid()) + { + logError("invalid ellipce in ignette"); + return; + } + + int w = size.getW(); + int h = size.getH(); + + if (w == 0) + { + return; + } + + if (h == 0) + { + return; + } + + deValue ww = w / 2.0; + deValue hh = h / 2.0; + + int i; + int j; + + int p = 0; + + for (i = 0; i < h; i++) + { + deValue y = (i - hh) / hh; + + y = ellipse.processY(y); + + for (j = 0; j < w; j++) + { + deValue x = (j - ww) / ww; + + x = ellipse.processX(x); + + deValue r = 1.0; + + deValue rr = x * x + y * y; + +// if (rr <= 1.0) + { + r = sqrt(rr); + } + + deValue v = 1.0 - r; + + if (v > 0) + { + v = sin(v * M_PI / 2); + } + + deValue vv = darkness + (light - darkness) * v; + if (vv < 0) + { + vv = 0; + } + if (vv > 1) + { + vv = 1; + } + + destination[p] = vv; + p++; + } + } + + logInfo("vignette DONE"); + +} + +deEllipse calcEllipse(deValue radX, deValue radY, deValue cenX, deValue cenY, deValue x1, deValue y1, deValue x2, deValue y2) +{ + deValue w = x2 - x1; + deValue h = y2 - y1; + + deValue rx = radX / w; + deValue ry = radY / h; + + // 0..1 + deValue ccx = (cenX + 1.0) / 2.0; + deValue ccy = (cenY + 1.0) / 2.0; + + deValue cccx = (ccx - x1) / w; + deValue cccy = (ccy - y1) / h; + + // -1..1 + deValue cx = cccx * 2.0 - 1.0; + deValue cy = cccy * 2.0 - 1.0; + + return deEllipse(cx, cy, rx, ry); +} + diff -Nru delaboratory-0.7/algorithms/vignette.h delaboratory-0.8/algorithms/vignette.h --- delaboratory-0.7/algorithms/vignette.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/algorithms/vignette.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,47 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_VIGNETTE_H +#define _DE_VIGNETTE_H + +#include "value.h" +#include "size.h" + +class deEllipse +{ + private: + deValue centerX; + deValue centerY; + deValue radiusX; + deValue radiusY; + public: + deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY); + virtual ~deEllipse(); + + deValue processX(deValue x) const; + deValue processY(deValue y) const; + + bool isValid() const; + +}; + +void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot); + +deEllipse calcEllipse(deValue radX, deValue radY, deValue cenX, deValue cenY, deValue x1, deValue y1, deValue x2, deValue y2); + +#endif diff -Nru delaboratory-0.7/core/base_layer.cc delaboratory-0.8/core/base_layer.cc --- delaboratory-0.7/core/base_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,137 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "base_layer.h" +#include "logger.h" +#include "str.h" +#include "update_main_layer_image.h" + + +deBaseLayer::deBaseLayer(deColorSpace _colorSpace, deChannelManager& _channelManager) +:colorSpace(_colorSpace), + mainLayerImage(_colorSpace, _channelManager) +{ +} + +deBaseLayer::~deBaseLayer() +{ +} + +deColorSpace deBaseLayer::getColorSpace() const +{ + return colorSpace; +} + +void deBaseLayer::lockLayer() +{ +#ifdef DEBUG_LOG + logInfo("base layer before lock"); +#endif + mutex.lock(); +#ifdef DEBUG_LOG + logInfo("base layer locked"); +#endif +} + +void deBaseLayer::unlockLayer() +{ + mutex.unlock(); +#ifdef DEBUG_LOG + logInfo("base layer unlocked"); +#endif +} + +void deBaseLayer::processLayer(deLayerProcessType type, int channel) +{ +#ifdef DEBUG_LOG + logInfo("processLayer channel: " + str(channel)); +#endif + switch (type) + { + case deLayerProcessFull: + { + processFull(); + break; + } + case deLayerProcessSingleChannel: + { + processSingleChannel(channel); + break; + } + case deLayerProcessBlend: + { + updateBlendAllChannels(); + break; + } + default: + break; + } +#ifdef DEBUG_LOG + logInfo("processLayer DONE"); +#endif +} + +bool deBaseLayer::processFull() +{ + return updateImage(); +} + +const deImage& deBaseLayer::getLayerImage() const +{ + return mainLayerImage; +} + +void deBaseLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + mainLayerImage.updateChannelUsage(channelUsage, layerIndex); +} + +void deBaseLayer::processSingleChannel(int channel) +{ + processMainImageSingleChannel(channel); +} + +bool deBaseLayer::processMainImageSingleChannel(int channel) +{ + bool result = true; +#ifdef DEBUG_LOG + logInfo("base layer process main image single channel"); +#endif + result = updateMainImageSingleChannel(channel); +#ifdef DEBUG_LOG + logInfo("base layer process main image single channel DONE"); +#endif + return result; +} + +bool deBaseLayer::updateImage() +{ + bool result = updateMainImageNotThreadedWay(); + if (!result) + { + updateMainImageAllChannels(*this); + result = true; + } + + return result; +} + +void deBaseLayer::allocateChannels() +{ + mainLayerImage.allocateChannels(); +} diff -Nru delaboratory-0.7/core/base_layer.h delaboratory-0.8/core/base_layer.h --- delaboratory-0.7/core/base_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,94 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BASE_LAYER_H +#define _DE_BASE_LAYER_H + +#include "color_space.h" +#include "mutex.h" +#include +#include +#include "image.h" +class deChannelManager; +class deViewManager; +class deProperty; +class dePreset; +class dePropertyNumeric; +class dePropertyChoice; +class dePropertyBoolean; + +enum deLayerProcessType +{ + deLayerProcessInvalid, + deLayerProcessFull, + deLayerProcessSingleChannel, + deLayerProcessBlend +}; + +class deBaseLayer +{ + private: + deBaseLayer(const deBaseLayer& layer); + deBaseLayer& operator = (const deBaseLayer& layer); + + deMutex mutex; + + virtual bool updateMainImageSingleChannel(int channel) {return false;}; + + protected: + deColorSpace colorSpace; + deImage mainLayerImage; + + virtual bool updateBlendAllChannels() {return false;}; + virtual bool updateMainImageNotThreadedWay() {return false;}; + virtual bool updateImage(); + + public: + deBaseLayer(deColorSpace _colorSpace, deChannelManager& _channelManager); + virtual ~deBaseLayer(); + + deColorSpace getColorSpace() const; + + void lockLayer(); + void unlockLayer(); + + void processLayer(deLayerProcessType type, int channel); + + bool processFull(); + virtual void processSingleChannel(int channel); + + bool updateImageThreadCall(); + + virtual std::string getType() const = 0; + + virtual const deImage& getLayerImage() const; + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + virtual std::string getWarning() const {return "OK";}; + + virtual bool onImageClick(deValue x, deValue y) {return false;}; + virtual void beforeSetUIFromLayer() {}; + + bool processMainImageSingleChannel(int channel); + + virtual void allocateChannels(); + +}; + +#endif diff -Nru delaboratory-0.7/core/base_layer_with_properties.cc delaboratory-0.8/core/base_layer_with_properties.cc --- delaboratory-0.7/core/base_layer_with_properties.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer_with_properties.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,211 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "base_layer_with_properties.h" +#include "color_space_utils.h" +#include "logger.h" +#include "semaphore.h" +#include "str.h" +#include "property_numeric.h" +#include "property_boolean.h" +#include "property_choice.h" +#include "preset.h" + +deBaseLayerWithProperties::deBaseLayerWithProperties(deColorSpace _colorSpace, deChannelManager& _channelManager) +:deBaseLayer(_colorSpace, _channelManager) +{ +} + +deBaseLayerWithProperties::~deBaseLayerWithProperties() +{ + std::vector::iterator i; + while (properties.size() > 0) + { + i = properties.begin(); + delete *i; + properties.erase(i); + } + std::vector::iterator j; + while (presets.size() > 0) + { + j = presets.begin(); + delete *j; + presets.erase(j); + } +} + +void deBaseLayerWithProperties::createPropertyNumeric(const std::string& _name, deValue _min, deValue _max) +{ + std::vector::iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + if (property->getName() == _name) + { + return; + } + } + properties.push_back(new dePropertyNumeric(_name, _min, _max)); +} + +void deBaseLayerWithProperties::createPropertyChoice(const std::string& _name, const std::vector& _choices) +{ + std::vector::iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + if (property->getName() == _name) + { + return; + } + } + properties.push_back(new dePropertyChoice(_name, _choices)); +} + +void deBaseLayerWithProperties::createPropertyBoolean(const std::string& _name) +{ + std::vector::iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + if (property->getName() == _name) + { + return; + } + } + properties.push_back(new dePropertyBoolean(_name)); +} + +deProperty* deBaseLayerWithProperties::getProperty(const std::string& _name) +{ + std::vector::iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + if (property->getName() == _name) + { + return property; + } + } + logError("property " + _name + " not found"); + + return NULL; +} + +const deProperty* deBaseLayerWithProperties::getProperty(const std::string& _name) const +{ + std::vector::const_iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + if (property->getName() == _name) + { + return property; + } + } + + return NULL; +} + +void deBaseLayerWithProperties::getProperties(std::vector& names) const +{ + std::vector::const_iterator i; + for (i = properties.begin(); i != properties.end(); i++) + { + deProperty* property = *i; + names.push_back(property->getName()); + } + +} + +dePropertyNumeric* deBaseLayerWithProperties::getPropertyNumeric(const std::string& _name) +{ + return dynamic_cast(getProperty(_name)); +} + +const dePropertyNumeric* deBaseLayerWithProperties::getPropertyNumeric(const std::string& _name) const +{ + return dynamic_cast(getProperty(_name)); +} + +dePropertyChoice* deBaseLayerWithProperties::getPropertyChoice(const std::string& _name) +{ + return dynamic_cast(getProperty(_name)); +} + +const dePropertyChoice* deBaseLayerWithProperties::getPropertyChoice(const std::string& _name) const +{ + return dynamic_cast(getProperty(_name)); +} + +dePropertyBoolean* deBaseLayerWithProperties::getPropertyBoolean(const std::string& _name) +{ + return dynamic_cast(getProperty(_name)); +} + +const dePropertyBoolean* deBaseLayerWithProperties::getPropertyBoolean(const std::string& _name) const +{ + return dynamic_cast(getProperty(_name)); +} + +deValue deBaseLayerWithProperties::getNumericValue(const std::string& name) const +{ + const dePropertyNumeric* p = getPropertyNumeric(name); + if (p) + { + return p->get(); + } + return 0; +} + +void deBaseLayerWithProperties::applyPreset(const std::string& name) +{ + std::vector::iterator i; + for (i = presets.begin(); i != presets.end(); i++) + { + dePreset* preset = *i; + if (preset->getName() == name) + { + preset->apply(*this); + } + } +} + +void deBaseLayerWithProperties::getPresets(std::vector& names) +{ + std::vector::iterator i; + for (i = presets.begin(); i != presets.end(); i++) + { + dePreset* preset = *i; + if (preset) + { + names.push_back(preset->getName()); + } + else + { + logError("NULL preset found"); + } + } +} + +dePreset* deBaseLayerWithProperties::createPreset(const std::string& name) +{ + dePreset* preset = new dePreset(name); + presets.push_back(preset); + return preset; +} diff -Nru delaboratory-0.7/core/base_layer_with_properties.h delaboratory-0.8/core/base_layer_with_properties.h --- delaboratory-0.7/core/base_layer_with_properties.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer_with_properties.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,66 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BASE_LAYER_WITH_PROPERTIES_H +#define _DE_BASE_LAYER_WITH_PROPERTIES_H + +#include "base_layer.h" + +class deBaseLayerWithProperties:public deBaseLayer +{ + private: + deBaseLayerWithProperties(const deBaseLayerWithProperties& layer); + deBaseLayerWithProperties& operator = (const deBaseLayerWithProperties& layer); + + protected: + std::vector properties; + std::vector presets; + + void createPropertyNumeric(const std::string& _name, deValue _min, deValue _max); + void createPropertyChoice(const std::string& _name, const std::vector& _choices); + void createPropertyBoolean(const std::string& _name); + + public: + deBaseLayerWithProperties(deColorSpace _colorSpace, deChannelManager& _channelManager); + virtual ~deBaseLayerWithProperties(); + + deProperty* getProperty(const std::string& _name); + const deProperty* getProperty(const std::string& _name) const; + + dePropertyNumeric* getPropertyNumeric(const std::string& _name); + const dePropertyNumeric* getPropertyNumeric(const std::string& _name) const; + + dePropertyChoice* getPropertyChoice(const std::string& _name); + const dePropertyChoice* getPropertyChoice(const std::string& _name) const; + + dePropertyBoolean* getPropertyBoolean(const std::string& _name); + const dePropertyBoolean* getPropertyBoolean(const std::string& _name) const; + + void getProperties(std::vector& names) const; + + deValue getNumericValue(const std::string& name) const; + + void applyPreset(const std::string& name); + void getPresets(std::vector& names); + dePreset* createPreset(const std::string& name); + + virtual void executeOperation(const std::string& o) {}; + +}; + +#endif diff -Nru delaboratory-0.7/core/base_layer_with_source.cc delaboratory-0.8/core/base_layer_with_source.cc --- delaboratory-0.7/core/base_layer_with_source.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer_with_source.cc 2012-07-03 22:57:08.000000000 +0000 @@ -0,0 +1,85 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "base_layer_with_source.h" +#include "layer_stack.h" +#include "copy_channel.h" +#include "logger.h" +#include "str.h" + +deBaseLayerWithSource::deBaseLayerWithSource(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) +:deBaseLayerWithProperties(_colorSpace, _channelManager), +sourceLayerIndex(_sourceLayerIndex), +layerStack(_layerStack) +{ +} + +deBaseLayerWithSource::~deBaseLayerWithSource() +{ +} + +const deBaseLayer& deBaseLayerWithSource::getSourceLayer() const +{ + const deBaseLayer* layer = layerStack.getLayer(sourceLayerIndex); + return *layer; +} + +const deBaseLayer& deBaseLayerWithSource::getOriginalLayer() const +{ + const deBaseLayer* layer = layerStack.getLayer(0); + return *layer; +} + +const deImage& deBaseLayerWithSource::getSourceImage() const +{ + return getSourceLayer().getLayerImage(); +} + +const deImage& deBaseLayerWithSource::getOriginalImage() const +{ + return getOriginalLayer().getLayerImage(); +} + +const deImage& deBaseLayerWithSource::getOtherLayerImage(int a) const +{ + deBaseLayer* applied = layerStack.getLayer(a); + + const deImage& appliedImage = applied->getLayerImage(); + + return appliedImage; +} + +deColorSpace deBaseLayerWithSource::getSourceColorSpace() const +{ + return getSourceLayer().getColorSpace(); +} + +int deBaseLayerWithSource::getLayerStackSize() const +{ + return layerStack.getSize(); +} + +void deBaseLayerWithSource::copySourceChannel(int channel) +{ + logInfo("copy source channel " + str(channel)); + const deValue* s = getSourceImage().startRead(channel); + deValue* d = mainLayerImage.startWrite(channel); + copyChannel(s, d, mainLayerImage.getChannelSize().getN()); + mainLayerImage.finishWrite(channel); + getSourceImage().finishRead(channel); +} diff -Nru delaboratory-0.7/core/base_layer_with_source.h delaboratory-0.8/core/base_layer_with_source.h --- delaboratory-0.7/core/base_layer_with_source.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/base_layer_with_source.h 2012-07-03 22:57:08.000000000 +0000 @@ -0,0 +1,50 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BASE_LAYER_WITH_SOURCE_H +#define _DE_BASE_LAYER_WITH_SOURCE_H + +#include "base_layer_with_properties.h" +class deLayerStack; + +class deBaseLayerWithSource:public deBaseLayerWithProperties +{ + private: + int sourceLayerIndex; + deLayerStack& layerStack; + + const deBaseLayer& getSourceLayer() const; + const deBaseLayer& getOriginalLayer() const; + + protected: + void copySourceChannel(int channel); + + public: + deBaseLayerWithSource(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deBaseLayerWithSource(); + + const deImage& getOriginalImage() const; + const deImage& getSourceImage() const; + const deImage& getOtherLayerImage(int a) const; + deColorSpace getSourceColorSpace() const; + int getLayerStackSize() const; + + +}; + +#endif diff -Nru delaboratory-0.7/core/channel_manager.cc delaboratory-0.8/core/channel_manager.cc --- delaboratory-0.7/core/channel_manager.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/channel_manager.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,397 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "channel_manager.h" +#include +#include +#include "logger.h" +#include "str.h" + +deChannelManager::deChannelManager() +:channelSize(0,0) +{ +#ifdef DEBUG_LOG + logInfo("channel manager constructor"); +#endif +} + +deChannelManager::~deChannelManager() +{ +#ifdef DEBUG_LOG + logInfo("channel manager destructor"); +#endif + unsigned int i; + for (i = 0; i < channels.size(); i++) + { + lock(); + + freeChannel(i); + delete mutexes[i]; + + unlock(); + } +#ifdef DEBUG_LOG + logInfo("channel manager destructor DONE"); +#endif +} + +void deChannelManager::setChannelSize(const deSize& size, bool reallocate) +{ + lock(); + + channelSize = size; + + if (channelSize.getW() < 0) + { + logError("w: " + str(channelSize.getW()) + " when setting channel size in channel manager"); + } + if (channelSize.getH() < 0) + { + logError("h: " + str(channelSize.getH()) + " when setting channel size in channel manager"); + } + + unsigned int i; + for (i = 0; i < channels.size(); i++) + { + logInfo("destroy channel " + str(i)); + mutexes[i]->lockWrite(); + tryDeallocateChannel(i); + if (reallocate) + { + tryAllocateChannel(i); + } + mutexes[i]->unlockWrite(); + } + + unlock(); +} + +void deChannelManager::lock() +{ +#ifdef DEBUG_LOG + logInfo("channel manager before lock"); +#endif + mutex.lock(); +#ifdef DEBUG_LOG + logInfo("channel manager locked"); +#endif +} + +void deChannelManager::unlock() +{ + mutex.unlock(); +#ifdef DEBUG_LOG + logInfo("channel manager unlocked"); +#endif +} + +int deChannelManager::reserveNewChannel() +{ + lock(); + + deValue* channel = NULL; + + int c = -1; + if (trashed.size() > 0) + { + std::set::iterator i = trashed.begin(); + c = *i; + trashed.erase(c); + channels[c] = channel; + logInfo("reused trashed channel " + str(c)); + } + else + { + channels.push_back(channel); + mutexes.push_back(new deMutexReadWrite(4)); + c = channels.size() - 1; + logInfo("added channel " + str(c)); + } + + unlock(); + + return c; +} + +void deChannelManager::freeChannel(int index) +{ + lock(); + + bool error = false; + + if (index < 0) + { + logError("freeChannel index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("freeChannel index >= " + str(s)); + error = true; + } + + if (!error) + { + logInfo("freeChannel before lockWrite"); + mutexes[index]->lockWrite(); + logInfo("freeChannel after locks"); + + assert(index >= 0); + assert((unsigned int)index < channels.size()); + + if (channels[index]) + { + delete [] channels[index]; + channels[index] = NULL; + trashed.insert(index); + logInfo("destroyed channel " + str(index)); + } + else + { + } + + mutexes[index]->unlockWrite(); + } + + unlock(); + + logInfo("freeChannel after unlocks"); + +} + +deSize deChannelManager::getChannelSizeFromChannelManager() const +{ + if (channelSize.getW() < 0) + { + logError("w: " + str(channelSize.getW()) + " when getting channel size from channel manager"); + } + if (channelSize.getH() < 0) + { + logError("h: " + str(channelSize.getH()) + " when getting channel size from channel manager"); + } + + deSize size = channelSize; + + return size; +} + +void deChannelManager::tryAllocateChannel(int index) +{ + lock(); + + bool error = false; + + if (index < 0) + { + logError("tryAllocateChannel index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("tryAllocateChannel index >= " + str(s)); + error = true; + } + + if (!error) + { + if (!channels[index]) + { + logInfo("allocating channel " + str(index)); + try + { + deValue* c = new deValue [channelSize.getN()]; + if (c) + { + logInfo("allocated channel " + str(index)); + } + else + { + logError("unable to allocate channel " + str(index)); + } + channels[index] = c; + } + catch (std::bad_alloc) + { + logError("bad_alloc exception on allocate channel " + str(index)); + channels[index] = NULL; + } + } + } + + unlock(); + +} + +void deChannelManager::tryDeallocateChannel(int index) +{ + lock(); + + bool error = false; + + if (index < 0) + { + logError("tryDeallocateChannel index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("tryDeallocateChannel index >= " + str(s)); + error = true; + } + + if (!error) + { + if (channels[index]) + { + logInfo("deallocating channel " + str(index)); + delete [] channels[index]; + channels[index] = NULL; + } + } + + unlock(); + +} + +bool deChannelManager::isImageEmpty() const +{ + return channelSize.getN() == 0; +} + +const deValue* deChannelManager::startRead(int index) +{ +#ifdef DEBUG_LOG + logInfo("startRead " + str(index)); +#endif + + bool error = false; + + if (index < 0) + { + logError("startRead index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("startRead index >= " + str(s)); + error = true; + } + + deValue* p = NULL; + + if (!error) + { + mutexes[index]->lockRead(); + + p = channels[index]; + } + + return p; +} + +void deChannelManager::finishRead(int index) +{ +#ifdef DEBUG_LOG + logInfo("finishRead " + str(index)); +#endif + + bool error = false; + + if (index < 0) + { + logError("finishRead index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("finishRead index >= " + str(s)); + error = true; + } + + if (!error) + { + mutexes[index]->unlockRead(); + } +} + +deValue* deChannelManager::startWrite(int index) +{ +#ifdef DEBUG_LOG + logInfo("startWrite " + str(index)); +#endif + + bool error = false; + + if (index < 0) + { + logError("startWrite index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("startWrite index >= " + str(s)); + error = true; + } + + deValue* p = NULL; + + if (!error) + { + mutexes[index]->lockWrite(); + +#ifdef DEBUG_LOG + logInfo("startWrite " + str(index) + " locked"); +#endif + + p = channels[index]; + } + + return p; +} + +void deChannelManager::finishWrite(int index) +{ +#ifdef DEBUG_LOG + logInfo("finishWrite " + str(index)); +#endif + + bool error = false; + + if (index < 0) + { + logError("finishWrite index < 0"); + error = true; + } + else if ((unsigned int)index >= channels.size()) + { + int s = channels.size(); + logError("finishWrite index >= " + str(s)); + error = true; + } + + if (!error) + { + mutexes[index]->unlockWrite(); + } +} diff -Nru delaboratory-0.7/core/channel_manager.h delaboratory-0.8/core/channel_manager.h --- delaboratory-0.7/core/channel_manager.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/channel_manager.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,70 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CHANNEL_MANAGER_H +#define _DE_CHANNEL_MANAGER_H + +#include "size.h" +#include +#include +#include "mutex.h" +#include "mutex_read_write.h" + +class deImage; +class deLogger; + +class deChannelManager +{ + private: + deSize channelSize; + deMutex mutex; + + std::vector channels; + std::vector mutexes; + std::set trashed; + + deChannelManager(const deChannelManager& m); + deChannelManager& operator =(const deChannelManager& m); + + public: + deChannelManager(); + virtual ~deChannelManager(); + + void setChannelSize(const deSize& size, bool reallocate); + deSize getChannelSizeFromChannelManager() const; + + int reserveNewChannel(); + void freeChannel(int index); + + void tryAllocateChannel(int index); + void tryDeallocateChannel(int index); + + bool isImageEmpty() const; + + const deValue* startRead(int index); + void finishRead(int index); + deValue* startWrite(int index); + void finishWrite(int index); + + void lock(); + void unlock(); + + +}; + +#endif diff -Nru delaboratory-0.7/core/channels.h delaboratory-0.8/core/channels.h --- delaboratory-0.7/core/channels.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/channels.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,56 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CHANNELS_H +#define _DE_CHANNELS_H + +// RGB +#define DE_CHANNEL_RED 0 +#define DE_CHANNEL_GREEN 1 +#define DE_CHANNEL_BLUE 2 + +// BW +#define DE_CHANNEL_GRAYSCALE 0 + +// LAB +#define DE_CHANNEL_L 0 +#define DE_CHANNEL_A 1 +#define DE_CHANNEL_B 2 + +// LCH +#define DE_CHANNEL_C 1 +#define DE_CHANNEL_H 2 + +// CMY/CMYK +#define DE_CHANNEL_CYAN 0 +#define DE_CHANNEL_MAGENTA 1 +#define DE_CHANNEL_YELLOW 2 +#define DE_CHANNEL_KEY 3 + +// HSL/HSV +#define DE_CHANNEL_HUE 0 +#define DE_CHANNEL_SATURATION 1 +#define DE_CHANNEL_LIGHTNESS 2 +#define DE_CHANNEL_VALUE 2 + +// XYZ +#define DE_CHANNEL_X 0 +#define DE_CHANNEL_Y 1 +#define DE_CHANNEL_Z 2 + +#endif diff -Nru delaboratory-0.7/core/color_matrix.cc delaboratory-0.8/core/color_matrix.cc --- delaboratory-0.7/core/color_matrix.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/color_matrix.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,253 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "color_matrix.h" +#include +#include + +deColorMatrix::deColorMatrix(int _w, int _h) +{ + width = _w; + height = _h; + + minX = 0; + minY = 0; + maxX = 1; + maxY = 1; + + int n = width * height; + matrix = new deValue [n]; + density = new int [n]; +} + +deColorMatrix::~deColorMatrix() +{ + delete [] matrix; + delete [] density; +} + +void deColorMatrix::clear() +{ + int n = width * height; + int i; + for (i = 0; i < n; i++) + { + matrix[i] = -1; + density[i] = 0; + } +} + +void deColorMatrix::buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min) +{ + minX = 0; + minY = 0; + maxX = 1; + maxY = 1; + + clear(); + build(channelH, channelV, channelA, n); + int xx; + int yy; + int minxx = width; + int maxxx = -1; + int minyy = height; + int maxyy = -1; + + for (xx = 0; xx < width; xx++) + { + for (yy = 0; yy < height; yy++) + { + int pos = width * yy + xx; + if (density[pos] >= min) + { + if (xx < minxx) + { + minxx = xx; + } + if (yy < minyy) + { + minyy = yy; + } + if (xx > maxxx) + { + maxxx = xx; + } + if (yy > maxyy) + { + maxyy = yy; + } + } + } + } + + if (minxx > 0) + { + minxx--; + } + if (minyy > 0) + { + minyy--; + } + if (maxxx < width - 1) + { + maxxx++; + } + if (maxyy < height - 1) + { + maxyy++; + } + + minX = (deValue) minxx / width; + minY = (deValue) minyy / height; + maxX = (deValue) maxxx / width; + maxY = (deValue) maxyy / height; + + deValue margin = -0.01; + + if (maxX < 0.5 - margin) + { + maxX = 0.5 - margin; + } + if (maxY < 0.5 - margin) + { + maxY = 0.5 - margin; + } + if (minX > 0.5 + margin) + { + minX = 0.5 + margin; + } + if (minY > 0.5 + margin) + { + minY = 0.5 + margin; + } + + clear(); + build(channelH, channelV, channelA, n); + +} + +void deColorMatrix::build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n) +{ + if (!channelH) + { + return; + } + if (!channelV) + { + return; + } + if (!channelA) + { + return; + } + + int i; + + for (i = 0; i < n; i++) + { + deValue h = channelH[i]; + deValue v = channelV[i]; + deValue a = channelA[i]; + + if ((h >= 0) && (h < 1) && (v >= 0) && (v < 1) && ((a >= 0) && (a < 1))) + { + int x = (h - minX) / (maxX - minX) * width; + int y = (v - minY) / (maxY - minY) * height; + + if ((x >= 0) && (y >= 0) && (x < width) && (y < height)) + { + int pos = width * y + x; + + int d = density[pos]; + + if (d == 0) + { + density[pos] = 1; + matrix[pos] = a; + } + else + { + density[pos]++; + matrix[pos] += a; + } + } + } + } + + int nn = width * height; + for (i = 0; i < nn; i++) + { + int d = density[i]; + if (d > 0) + { + matrix[i] /= d; + } + } +} + +deValue deColorMatrix::get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const +{ + vx = minX + ((deValue) x / width) * (maxX - minX); + deValue vx2 = minX + ((deValue) (x+1) / width) * (maxX - minX); + deValue vx3 = minX + ((deValue) (x-1) / width) * (maxX - minX); + deValue dx = fabs(0.5 - vx); + deValue dx2 = fabs(0.5 - vx2); + deValue dx3 = fabs(0.5 - vx3); + + vy = minY + ((deValue) y / height) * (maxY - minY); + deValue vy2 = minY + ((deValue) (y+1) / height) * (maxY - minY); + deValue vy3 = minY + ((deValue) (y-1) / height) * (maxY - minY); + deValue dy = fabs(0.5 - vy); + deValue dy2 = fabs(0.5 - vy2); + deValue dy3 = fabs(0.5 - vy3); + + center = false; + if ((dx < dx2) && (dx < dx3)) + { + center = true; + } + if ((dy < dy2) && (dy < dy3)) + { + center = true; + } + + if (x < 0) + { + return -1; + } + if (y < 0) + { + return -1; + } + if (x >= width) + { + return -1; + } + if (y >= height) + { + return -1; + } + int pos = width * y + x; + if (density[pos] < min) + { + return -1; + } + + deValue result = matrix[pos]; + return result; +} diff -Nru delaboratory-0.7/core/color_matrix.h delaboratory-0.8/core/color_matrix.h --- delaboratory-0.7/core/color_matrix.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/color_matrix.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COLOR_MATRIX_H +#define _DE_COLOR_MATRIX_H + +#include "value.h" + +class deColorMatrix +{ + private: + int width; + int height; + deValue minX; + deValue minY; + deValue maxX; + deValue maxY; + + deValue* matrix; + int* density; + public: + deColorMatrix(int _w, int _h); + virtual ~deColorMatrix(); + + void clear(); + void build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n); + void buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min); + + deValue get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const; + + +}; + +#endif diff -Nru delaboratory-0.7/core/color_space.cc delaboratory-0.8/core/color_space.cc --- delaboratory-0.7/core/color_space.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/color_space.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,20 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "color_space.h" + diff -Nru delaboratory-0.7/core/color_space.h delaboratory-0.8/core/color_space.h --- delaboratory-0.7/core/color_space.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/color_space.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,39 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COLOR_SPACE_H +#define _DE_COLOR_SPACE_H + +#define MAX_COLOR_SPACE_SIZE 4 + +enum deColorSpace +{ + deColorSpaceInvalid, + deColorSpaceRGB, + deColorSpaceProPhoto, + deColorSpaceBW, + deColorSpaceLAB, + deColorSpaceCMY, + deColorSpaceCMYK, + deColorSpaceHSV, + deColorSpaceHSL, + deColorSpaceXYZ, + deColorSpaceLCH +}; + +#endif diff -Nru delaboratory-0.7/core/conversion_cpu.cc delaboratory-0.8/core/conversion_cpu.cc --- delaboratory-0.7/core/conversion_cpu.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/conversion_cpu.cc 2012-07-15 13:03:42.000000000 +0000 @@ -0,0 +1,1933 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "conversion_processor.h" + +#include "image.h" +#include "channel_manager.h" +#include "color_space_utils.h" + +#include "logger.h" + +#include "power.h" + +#include "str.h" + +#include + +static const deValue Xn = 0.951; +static const deValue Yn = 1.0; +static const deValue Zn = 1.089; +static const deValue c6_29 = 6.0 / 29.0; +static const deValue c29_6 = 29.0 / 6.0; +static const deValue c6_29_2 = c6_29 * c6_29; +static const deValue c6_29_3 = c6_29 * c6_29 * c6_29; +static const deValue c29_6_2 = c29_6 * c29_6; +static const deValue c4_29 = 4.0 / 29.0; + +deConversionCPU::deConversionCPU(int size) +{ + input = new deValue [size]; + output = new deValue [size]; + registers = new deValue [CPU_REGISTERS]; + + registers[CPU_REGISTER_OVERFLOW] = 0; + registers[CPU_REGISTER_CMYK_KEY_SUB] = 0.25; + registers[CPU_REGISTER_CMYK_KEY_MAX] = 0.8; + registers[CPU_REGISTER_CMYK_MIN_SUM] = 1.0; + registers[CPU_REGISTER_BW_MIXER_R] = 0.3; + registers[CPU_REGISTER_BW_MIXER_G] = 0.6; + registers[CPU_REGISTER_BW_MIXER_B] = 0.1; + registers[CPU_REGISTER_CONTRAST] = 1.0; + registers[CPU_REGISTER_SATURATION] = 1.0; + registers[CPU_REGISTER_PSEUDOGREY] = 0.0; +} + +deConversionCPU::~deConversionCPU() +{ + delete [] input; + delete [] output; + delete [] registers; +} + +void deConversionCPU::switchIO() +{ + deValue* a = input; + input = output; + output = a; +} + +void deConversionCPU::incOverflow() +{ + registers[CPU_REGISTER_OVERFLOW] ++; +} + +bool deConversionCPU::renderImage1(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) +{ + int n = image.getChannelSize().getN(); + + const deValue* s0 = image.startRead(0); + if (!s0) + { + logError("NULL in renderImage1"); + image.finishRead(0); + return false; + } + + int i; + int pos = 0; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + + f(*this); + + unsigned char r = 255 * output[0]; + data[pos] = r; + pos++; + unsigned char g = 255 * output[1]; + data[pos] = g; + pos++; + unsigned char b = 255 * output[2]; + data[pos] = b; + pos++; + } + + image.finishRead(0); + + return true; +} + +bool deConversionCPU::renderImage3(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) +{ + int n = image.getChannelSize().getN(); + + const deValue* s0 = image.startRead(0); + const deValue* s1 = image.startRead(1); + const deValue* s2 = image.startRead(2); + if ((!s0) || (!s1) || (!s2)) + { + logError("NULL in renderImage3"); + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + return false; + } + + int i; + int pos = 0; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + + f(*this); + + unsigned char r = 255 * output[0]; + data[pos] = r; + pos++; + unsigned char g = 255 * output[1]; + data[pos] = g; + pos++; + unsigned char b = 255 * output[2]; + data[pos] = b; + pos++; + } + + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + + return true; +} + +bool deConversionCPU::renderImage4(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) +{ + int n = image.getChannelSize().getN(); + + const deValue* s0 = image.startRead(0); + const deValue* s1 = image.startRead(1); + const deValue* s2 = image.startRead(2); + const deValue* s3 = image.startRead(3); + + if ((!s0) || (!s1) || (!s2) || (!s3)) + { + logError("NULL in renderImage4"); + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + image.finishRead(3); + return false; + } + + int i; + int pos = 0; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + input[3] = s3[i]; + + f(*this); + + unsigned char r = 255 * output[0]; + data[pos] = r; + pos++; + unsigned char g = 255 * output[1]; + data[pos] = g; + pos++; + unsigned char b = 255 * output[2]; + data[pos] = b; + pos++; + } + + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + image.finishRead(3); + + return true; +} + +void deConversionCPU::convertImage3x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + const deValue* s1 = sourceImage.startRead(1); + const deValue* s2 = sourceImage.startRead(2); + + deValue* d0 = image.startWrite(0); + deValue* d1 = image.startWrite(1); + deValue* d2 = image.startWrite(2); + + bool ok; + if (s0 && s1 && s2 && d0 && d1 && d2) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 3x3"); + ok = false; + } + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + d1[i] = output[1]; + d2[i] = output[2]; + } + } + + sourceImage.finishRead(0); + sourceImage.finishRead(1); + sourceImage.finishRead(2); + image.finishWrite(0); + image.finishWrite(1); + image.finishWrite(2); +} + +void deConversionCPU::convertImage3x4(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + const deValue* s1 = sourceImage.startRead(1); + const deValue* s2 = sourceImage.startRead(2); + + deValue* d0 = image.startWrite(0); + deValue* d1 = image.startWrite(1); + deValue* d2 = image.startWrite(2); + deValue* d3 = image.startWrite(3); + + bool ok; + if (s0 && s1 && s2 && d0 && d1 && d2 && d3) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 3x4"); + ok = false; + } + if (ok) + { + int i; + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + d1[i] = output[1]; + d2[i] = output[2]; + d3[i] = output[3]; + } + } + + sourceImage.finishRead(0); + sourceImage.finishRead(1); + sourceImage.finishRead(2); + image.finishWrite(0); + image.finishWrite(1); + image.finishWrite(2); + image.finishWrite(3); +} + +void deConversionCPU::convertImage3x1(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + const deValue* s1 = sourceImage.startRead(1); + const deValue* s2 = sourceImage.startRead(2); + + deValue* d0 = image.startWrite(0); + + bool ok; + if (s0 && s1 && s2 && d0) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 3x1"); + ok = false; + } + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + } + } + + sourceImage.finishRead(0); + sourceImage.finishRead(1); + sourceImage.finishRead(2); + image.finishWrite(0); +} + +void deConversionCPU::convertImage4x1(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + const deValue* s1 = sourceImage.startRead(1); + const deValue* s2 = sourceImage.startRead(2); + const deValue* s3 = sourceImage.startRead(3); + + deValue* d0 = image.startWrite(0); + + bool ok; + if (s0 && s1 && s2 && s3 && d0) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 4x1"); + ok = false; + } + + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + input[3] = s3[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + } + } + + sourceImage.finishRead(0); + sourceImage.finishRead(1); + sourceImage.finishRead(2); + sourceImage.finishRead(3); + image.finishWrite(0); +} + +void deConversionCPU::convertImage4x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + const deValue* s1 = sourceImage.startRead(1); + const deValue* s2 = sourceImage.startRead(2); + const deValue* s3 = sourceImage.startRead(3); + + deValue* d0 = image.startWrite(0); + deValue* d1 = image.startWrite(1); + deValue* d2 = image.startWrite(2); + + bool ok; + if (s0 && s1 && s2 && s3 && d0 && d1 && d2) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 4x3"); + ok = false; + } + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + input[1] = s1[i]; + input[2] = s2[i]; + input[3] = s3[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + d1[i] = output[1]; + d2[i] = output[2]; + } + } + + sourceImage.finishRead(0); + sourceImage.finishRead(1); + sourceImage.finishRead(2); + sourceImage.finishRead(3); + image.finishWrite(0); + image.finishWrite(1); + image.finishWrite(2); +} + +void deConversionCPU::convertImage1x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + + deValue* d0 = image.startWrite(0); + deValue* d1 = image.startWrite(1); + deValue* d2 = image.startWrite(2); + + bool ok; + if (s0 && d0 && d1 && d2) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 1x3"); + ok = false; + } + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + d1[i] = output[1]; + d2[i] = output[2]; + } + } + + sourceImage.finishRead(0); + image.finishWrite(0); + image.finishWrite(1); + image.finishWrite(2); +} + +void deConversionCPU::convertImage1x4(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) +{ + int n = sourceImage.getChannelSize().getN(); + + const deValue* s0 = sourceImage.startRead(0); + + deValue* d0 = image.startWrite(0); + deValue* d1 = image.startWrite(1); + deValue* d2 = image.startWrite(2); + deValue* d3 = image.startWrite(3); + + bool ok; + if (s0 && d0 && d1 && d2 && d3) + { + ok = true; + } + else + { + logError("NULL channel in convertImage 1x4"); + ok = false; + } + if (ok) + { + int i; + + for (i = 0; i < n; i++) + { + input[0] = s0[i]; + + f1(*this); + f2(*this); + + d0[i] = output[0]; + d1[i] = output[1]; + d2[i] = output[2]; + d3[i] = output[3]; + } + } + + sourceImage.finishRead(0); + image.finishWrite(0); + image.finishWrite(1); + image.finishWrite(2); + image.finishWrite(3); +} + +void empty(deConversionCPU& cpu) +{ +} + +void rgb2cmy(deConversionCPU& cpu) +{ + cpu.output[0] = 1.0 - cpu.input[0]; + cpu.output[1] = 1.0 - cpu.input[1]; + cpu.output[2] = 1.0 - cpu.input[2]; +} + +void bw2rgb(deConversionCPU& cpu) +{ + deValue pg = cpu.registers[CPU_REGISTER_PSEUDOGREY] / 255.0; + + deValue bw = cpu.input[0]; + + if (pg == 0) + { + cpu.output[0] = bw; + cpu.output[1] = bw; + cpu.output[2] = bw; + } + else + { + int bbw = (int) (255 * bw * 16); + int m = bbw % 16; + + deValue r = 0; + deValue g = 0; + deValue b = 0; + + if ((m >= 2) && (m <= 4)) + { + b = 1; + } + if ((m >= 5) && (m <= 6)) + { + r = 1; + } + if ((m >= 7) && (m <= 8)) + { + r = 1; + b = 1; + } + if ((m >= 9) && (m <= 10)) + { + g = 1; + } + if ((m >= 11) && (m <= 13)) + { + g = 1; + b = 1; + } + if ((m >= 14) && (m <= 15)) + { + g = 1; + r = 1; + } + + r = bw + pg * r; + if (r > 1) + { + r = 1; + } + g = bw + pg * g; + if (g > 1) + { + g = 1; + } + b = bw + pg * b; + if (b > 1) + { + b = 1; + } + cpu.output[0] = r; + cpu.output[1] = g; + cpu.output[2] = b; + } +} + +void rgb2bw(deConversionCPU& cpu) +{ + deValue r = cpu.input[0]; + deValue g = cpu.input[1]; + deValue b = cpu.input[2]; + + deValue mr = cpu.registers[CPU_REGISTER_BW_MIXER_R]; + deValue mg = cpu.registers[CPU_REGISTER_BW_MIXER_G]; + deValue mb = cpu.registers[CPU_REGISTER_BW_MIXER_B]; + + deValue bw = mr * r + mg * g + mb * b; + + if (bw < 0) + { + bw = 0; + cpu.incOverflow(); + } + else if (bw > 1) + { + bw = 1; + cpu.incOverflow(); + } + + cpu.output[0] = bw; +} + +void cmy2rgb(deConversionCPU& cpu) +{ + cpu.output[0] = 1.0 - cpu.input[0]; + cpu.output[1] = 1.0 - cpu.input[1]; + cpu.output[2] = 1.0 - cpu.input[2]; +} + +void cmy2cmyk(deConversionCPU& cpu) +{ + deValue k; + deValue c = cpu.input[0]; + deValue m = cpu.input[1]; + deValue y = cpu.input[2]; + + if (c < m) + { + if (c < y) + { + k = c; + } + else + { + k = y; + } + } + else + { + if (m < y) + { + k = m; + } + else + { + k = y; + } + } + + k = k - cpu.registers[CPU_REGISTER_CMYK_KEY_SUB]; + + if (k < 0.0) + { + k = 0.0; + } + + deValue max = cpu.registers[CPU_REGISTER_CMYK_KEY_MAX]; + if (k > max) + { + k = max; + } + + if (c + m + y < cpu.registers[CPU_REGISTER_CMYK_MIN_SUM]) + { + k = 0.0; + } + + deValue kk = (1 - k); + + cpu.output[0] = (c - k) / kk; + cpu.output[1] = (m - k) / kk; + cpu.output[2] = (y - k) / kk; + cpu.output[3] = k; +} + +void cmyk2cmy(deConversionCPU& cpu) +{ + deValue k = cpu.input[3]; + deValue kk = 1.0 - k; + + deValue c = cpu.input[0] * kk + k; + deValue m = cpu.input[1] * kk + k; + deValue y = cpu.input[2] * kk + k; + + cpu.output[0] = c; + cpu.output[1] = m; + cpu.output[2] = y; +} + +void rgb2prophoto(deConversionCPU& cpu) +{ + /* + from dcraw + + octave:1> x = [0.529317, 0.330092, 0.140588; 0.098368, 0.873465, 0.028169; 0.016879, 0.117663, 0.865457] + x = + + 0.529317 0.330092 0.140588 + 0.098368 0.873465 0.028169 + 0.016879 0.117663 0.865457 + + */ + + + deValue r = cpu.input[0]; + deValue g = cpu.input[1]; + deValue b = cpu.input[2]; + + cpu.output[0] = 0.529317 * r + 0.330092 * g + 0.140588 * b; + cpu.output[1] = 0.098368 * r + 0.873465 * g + 0.028169 * b; + cpu.output[2] = 0.016879 * r + 0.117663 * g + 0.865457 * b; + +} + +void prophoto2rgb(deConversionCPU& cpu) +{ + + /* + invert matrix from dcraw + + octave:2> inv(x) + ans = + + 2.0341926 -0.7274198 -0.3067655 + -0.2288108 1.2317292 -0.0029216 + -0.0085649 -0.1532726 1.1618390 + + */ + + deValue pr = cpu.input[0]; + deValue pg = cpu.input[1]; + deValue pb = cpu.input[2]; + + deValue r = 2.0341926 * pr -0.7274198 * pg -0.3067655 * pb; + deValue g = -0.2288108 * pr + 1.2317292 * pg -0.0029216 * pb; + deValue b = -0.0085649 * pr -0.1532726 * pg + 1.1618390 * pb; + + if (r < 0) + { + r = 0; + cpu.incOverflow(); + } + else if (r > 1) + { + r = 1; + cpu.incOverflow(); + } + if (g < 0) + { + g = 0; + cpu.incOverflow(); + } + else if (g > 1) + { + g = 1; + cpu.incOverflow(); + } + if (b < 0) + { + b = 0; + cpu.incOverflow(); + } + else if (b > 1) + { + b = 1; + cpu.incOverflow(); + } + + cpu.output[0] = r; + cpu.output[1] = g; + cpu.output[2] = b; + +} + +void prophoto2xyz(deConversionCPU& cpu) +{ + + /* + + octave:7> z + z = + + 2.0341926 -0.7274198 -0.3067655 + -0.2288108 1.2317292 -0.0029216 + -0.0085649 -0.1532726 1.1618390 + + octave:8> y + y = + + 0.412400 0.357600 0.180500 + 0.212600 0.715200 0.072200 + 0.019300 0.119200 0.950500 + + octave:10> y * z + ans = + + 0.7555323 0.1128127 0.0821571 + 0.2682055 0.7152170 0.0165769 + 0.0038447 -0.0129027 1.0980591 + + */ + + deValue pr = cpu.input[0]; + deValue pg = cpu.input[1]; + deValue pb = cpu.input[2]; + + cpu.output[0] = 0.7555323 * pr + 0.1128127* pg + 0.0821571* pb; + cpu.output[1] = 0.2682055 * pr + 0.7152170* pg + 0.0165769* pb; + cpu.output[2] = 0.0038447 * pr -0.0129027 * pg + 1.0980591* pb; + +} + +void rgb2xyz(deConversionCPU& cpu) +{ + deValue r = cpu.input[0]; + deValue g = cpu.input[1]; + deValue b = cpu.input[2]; + + cpu.output[0] = 0.4124 * r + 0.3576 * g + 0.1805 * b; + cpu.output[1] = 0.2126 * r + 0.7152 * g + 0.0722 * b; + cpu.output[2] = 0.0193 * r + 0.1192 * g + 0.9505 * b; + +} + +void xyz2rgb(deConversionCPU& cpu) +{ + deValue x = cpu.input[0]; + deValue y = cpu.input[1]; + deValue z = cpu.input[2]; + + deValue r = 3.2410 * x - 1.5374 * y - 0.4986 * z; + deValue g = -0.9692 * x + 1.8760 * y + 0.0416 * z; + deValue b = 0.0556 * x - 0.2040 * y + 1.0570 * z; + + if (r < 0) + { + r = 0; + cpu.incOverflow(); + } + else if (r > 1) + { + r = 1; + cpu.incOverflow(); + } + if (g < 0) + { + g = 0; + cpu.incOverflow(); + } + else if (g > 1) + { + g = 1; + cpu.incOverflow(); + } + if (b < 0) + { + b = 0; + cpu.incOverflow(); + } + else if (b > 1) + { + b = 1; + cpu.incOverflow(); + } + + cpu.output[0] = r; + cpu.output[1] = g; + cpu.output[2] = b; +} + +void xyz2lab(deConversionCPU& cpu) +{ + static dePower power(1.0 / 3.0, 2); + + deValue xx = cpu.input[0] / Xn; + deValue yy = cpu.input[1] / Yn; + deValue zz = cpu.input[2] / Zn; + + deValue fx; + deValue fy; + deValue fz; + + if (xx > c6_29_3) + { + fx = power.get(xx); + } + else + { + fx = 1.0 / 3.0 * c29_6_2 * xx + c4_29; + } + + if (yy > c6_29_3) + { + fy = power.get(yy); + } + else + { + fy = 1.0 / 3.0 * c29_6_2 * yy + c4_29; + } + + if (zz > c6_29_3) + { + fz = power.get(zz); + } + else + { + fz = 1.0 / 3.0 * c29_6_2 * zz + c4_29; + } + + deValue l = 116.0 * fy - 16.0; + deValue a = 500.0 * (fx - fy); + deValue b = 200.0 * (fy - fz); + + l /= 100.0; + a += 100.0; + b += 100.0; + a /= 200.0; + b /= 200.0; + + if (l < 0) + { + l = 0; + cpu.incOverflow(); + } + else if (l > 1) + { + l = 1; + cpu.incOverflow(); + } + + if (a < 0) + { + a = 0; + cpu.incOverflow(); + } + else if (a > 1) + { + a = 1; + cpu.incOverflow(); + } + + if (b < 0) + { + b = 0; + cpu.incOverflow(); + } + else if (b > 1) + { + b = 1; + cpu.incOverflow(); + } + + + cpu.output[0] = l; + cpu.output[1] = a; + cpu.output[2] = b; + +} + +void lab2lch(deConversionCPU& cpu) +{ + deValue a = cpu.input[1]; + deValue b = cpu.input[2]; + + a = ( a - 0.5) * 200.0; + b = ( b - 0.5) * 200.0; + + deValue _c = sqrt(a * a + b * b); + deValue _h = atan2(b, a); + + _c = _c / 100.0; + _h = (_h / ( 2 * M_PI )); + + if (_h < 0) + { + _h += 1; + } + + if ( _c > 1) + { + _c = 1; + cpu.incOverflow(); + } + if ( _c < 0) + { + _c = 0; + cpu.incOverflow(); + } + + cpu.output[0] = cpu.input[0]; + + cpu.output[1] = _c; + cpu.output[2] = _h; +} + +void lch2lab(deConversionCPU& cpu) +{ + deValue c = cpu.input[1]; + deValue h = cpu.input[2]; + + c = c * 100.0; + h = h * (2 * M_PI); + + deValue a = c * cos(h); + deValue b = c * sin(h); + + a = a / 200.0 + 0.5; + b = b / 200.0 + 0.5; + + cpu.output[0] = cpu.input[0]; + + cpu.output[1] = a; + cpu.output[2] = b; +} + +void prophoto2lab(deConversionCPU& cpu) +{ + prophoto2xyz(cpu); + cpu.switchIO(); + xyz2lab(cpu); +} + +void rgb2cmyk(deConversionCPU& cpu) +{ + rgb2cmy(cpu); + cpu.switchIO(); + cmy2cmyk(cpu); +} + +void prophoto2cmyk(deConversionCPU& cpu) +{ + prophoto2rgb(cpu); + cpu.switchIO(); + rgb2cmyk(cpu); +} + + +void noConversion(deConversionCPU& cpu) +{ + cpu.switchIO(); +} + +void rgb2lab(deConversionCPU& cpu) +{ + rgb2xyz(cpu); + cpu.switchIO(); + xyz2lab(cpu); +} + +void rgb2lch(deConversionCPU& cpu) +{ + rgb2lab(cpu); + cpu.switchIO(); + lab2lch(cpu); +} + +void prophoto2lch(deConversionCPU& cpu) +{ + prophoto2lab(cpu); + cpu.switchIO(); + lab2lch(cpu); +} + +void cmyk2rgb(deConversionCPU& cpu) +{ + cmyk2cmy(cpu); + cpu.switchIO(); + cmy2rgb(cpu); +} + +void cmyk2lab(deConversionCPU& cpu) +{ + cmyk2rgb(cpu); + cpu.switchIO(); + rgb2lab(cpu); +} + +void lab2xyz(deConversionCPU& cpu) +{ + deValue l = cpu.input[0]; + deValue a = cpu.input[1]; + deValue b = cpu.input[2]; + + l *= 100.0; + a *= 200.0; + b *= 200.0; + a -= 100.0; + b -= 100.0; + + deValue ll = (l + 16.0) / 116.0; + deValue ll_aa = ll + a / 500.0; + deValue ll_bb = ll - b / 200.0; + + deValue ffx; + deValue ffy; + deValue ffz; + + if (ll > c6_29) + { + ffy = ll * ll * ll; + } + else + { + ffy = 3.0 * c6_29_2 * (ll - c4_29); + } + + if (ll_aa > c6_29) + { + ffx = ll_aa * ll_aa * ll_aa; + } + else + { + ffx = 3.0 * c6_29_2 * (ll_aa - c4_29); + } + + if (ll_bb > c6_29) + { + ffz = ll_bb * ll_bb * ll_bb; + } + else + { + ffz = 3.0 * c6_29_2 * (ll_bb - c4_29); + } + + cpu.output[0] = Xn * ffx; + cpu.output[1] = Yn * ffy; + cpu.output[2] = Zn * ffz; +} + +void xyz2prophoto(deConversionCPU& cpu) +{ + /* + + x = [0.7555323, 0.1128127, 0.0821571; 0.2682055, 0.7152170, 0.0165769; 0.0038447, -0.0129027, 1.0980591] + + octave:2> inv(x) + ans = + + 1.403314 -0.223181 -0.101627 + -0.525984 1.481448 0.016990 + -0.011094 0.018189 0.911253 + + */ + + deValue x = cpu.input[0]; + deValue y = cpu.input[1]; + deValue z = cpu.input[2]; + + cpu.output[0] = 1.403314* x -0.223181* y -0.101627* z; + cpu.output[1] = -0.525984* x + 1.481448* y + 0.016990* z; + cpu.output[2] = -0.011094* x + 0.018189* y + 0.911253* z; + +} + + +void lab2prophoto(deConversionCPU& cpu) +{ + lab2xyz(cpu); + cpu.switchIO(); + xyz2prophoto(cpu); +} + +void lch2prophoto(deConversionCPU& cpu) +{ + lch2lab(cpu); + cpu.switchIO(); + lab2prophoto(cpu); +} + + +void lab2rgb(deConversionCPU& cpu) +{ + lab2xyz(cpu); + cpu.switchIO(); + xyz2rgb(cpu); +} + +void lab2bw(deConversionCPU& cpu) +{ + lab2rgb(cpu); + cpu.switchIO(); + rgb2bw(cpu); +} + +void cmyk2bw(deConversionCPU& cpu) +{ + cmyk2rgb(cpu); + cpu.switchIO(); + rgb2bw(cpu); +} + +void bw2cmyk(deConversionCPU& cpu) +{ + bw2rgb(cpu); + cpu.switchIO(); + rgb2cmyk(cpu); +} + +void bw2lab(deConversionCPU& cpu) +{ + bw2rgb(cpu); + cpu.switchIO(); + rgb2lab(cpu); +} + +void bw2lch(deConversionCPU& cpu) +{ + bw2lab(cpu); + cpu.switchIO(); + lab2lch(cpu); +} + +void lch2bw(deConversionCPU& cpu) +{ + lch2lab(cpu); + cpu.switchIO(); + lab2bw(cpu); +} + +void lab2cmyk(deConversionCPU& cpu) +{ + lab2rgb(cpu); + cpu.switchIO(); + rgb2cmy(cpu); + cpu.switchIO(); + cmy2cmyk(cpu); +} + +void lch2rgb(deConversionCPU& cpu) +{ + lch2lab(cpu); + cpu.switchIO(); + lab2rgb(cpu); +} + +void lch2cmyk(deConversionCPU& cpu) +{ + lch2rgb(cpu); + cpu.switchIO(); + rgb2cmyk(cpu); +} + +void cmyk2lch(deConversionCPU& cpu) +{ + cmyk2rgb(cpu); + cpu.switchIO(); + rgb2lch(cpu); +} + +deValue min3(deValue a, deValue b, deValue c) +{ + if (a < b) + { + if (a < c) + { + return a; + } + else + { + return c; + } + } + else + { + if (b < c) + { + return b; + } + else + { + return c; + } + } +} + +deValue max3(deValue a, deValue b, deValue c) +{ + if (a > b) + { + if (a > c) + { + return a; + } + else + { + return c; + } + } + else + { + if (b > c) + { + return b; + } + else + { + return c; + } + } +} + +void rgb2hsl(deConversionCPU& cpu) +{ + deValue r = cpu.input[0]; + deValue g = cpu.input[1]; + deValue b = cpu.input[2]; + + deValue minVal = min3( r, g, b ); + deValue maxVal = max3( r, g, b ); + deValue delta = maxVal - minVal; + deValue sum = minVal + maxVal; + + deValue l = sum / 2.0; + deValue h; + deValue s; + + if (delta == 0) + { + h = 0; + s = 0; + } + else + { + if ( l < 0.5 ) + { + s = delta / sum; + } + else + { + s = delta / ( 2.0 - sum ); + } + + deValue deltaR = ( ( ( maxVal - r ) / 6 ) + ( delta / 2 ) ) / delta; + deValue deltaG = ( ( ( maxVal - g ) / 6 ) + ( delta / 2 ) ) / delta; + deValue deltaB = ( ( ( maxVal - b ) / 6 ) + ( delta / 2 ) ) / delta; + + if ( r == maxVal ) + { + h = deltaB - deltaG; + } + else if ( g == maxVal ) + { + h = ( 1.0 / 3.0 ) + deltaR - deltaB; + } + else if ( b == maxVal ) + { + h = ( 2.0 / 3.0 ) + deltaG - deltaR; + } + + if ( h < 0 ) + h += 1; + if ( h > 1 ) + h -= 1; + } + cpu.output[0] = h; + cpu.output[1] = s; + cpu.output[2] = l; +} + +deValue min(deValue a, deValue b, deValue c) +{ + if (a < b) + { + if (a < c) + { + return a; + } + else + { + return c; + } + } + else + { + if (b < c) + { + return b; + } + else + { + return c; + } + } +} + +deValue max(deValue a, deValue b, deValue c) +{ + if (a > b) + { + if (a > c) + { + return a; + } + else + { + return c; + } + } + else + { + if (b > c) + { + return b; + } + else + { + return c; + } + } +} + +deValue hue2rgb( deValue v1, deValue v2, deValue vH ) +{ + if ( vH < 0 ) + vH += 1; + if ( vH > 1 ) + vH -= 1; + if ( ( 6.0 * vH ) < 1.0 ) + return ( v1 + ( v2 - v1 ) * 6.0 * vH ); + if ( ( 2.0 * vH ) < 1.0 ) + return ( v2 ); + if ( ( 3.0 * vH ) < 2.0 ) + return ( v1 + ( v2 - v1 ) * ( ( 2.0 / 3.0 ) - vH ) * 6.0 ); + return ( v1 ); +} + +void hsl2rgb(deConversionCPU& cpu) +{ + deValue h = cpu.input[0]; + deValue s = cpu.input[1]; + deValue l = cpu.input[2]; + + deValue r = 0.0; + deValue g = 0.0; + deValue b = 0.0; + + if ( s == 0 ) + { + r = l; + g = l; + b = l; + } + else + { + deValue v1; + deValue v2; + + if ( l < 0.5 ) + { + v2 = l * ( 1 + s ); + } + else + { + v2 = ( l + s ) - ( s * l ); + } + + v1 = 2.0 * l - v2; + + r = hue2rgb( v1, v2, h + ( 1.0 / 3.0 ) ); + g = hue2rgb( v1, v2, h ); + b = hue2rgb( v1, v2, h - ( 1.0 / 3.0 ) ); + } + + cpu.output[0] = r; + cpu.output[1] = g; + cpu.output[2] = b; +} + +void rgb2hsv(deConversionCPU& cpu) +{ + deValue r = cpu.input[0]; + deValue g = cpu.input[1]; + deValue b = cpu.input[2]; + + deValue h = 0.0; + deValue s = 0.0; + deValue v = max( r, g, b ); + + deValue minVal = min( r, g, b ); + deValue delta = v - minVal; + + if (delta == 0) + { + h = 0; + s = 0; + } + else + { + s = delta / v; + + deValue deltaR = ( ( ( v - r ) / 6.0 ) + ( delta / 2.0 ) ) / delta; + deValue deltaG = ( ( ( v - g ) / 6.0 ) + ( delta / 2.0 ) ) / delta; + deValue deltaB = ( ( ( v - b ) / 6.0 ) + ( delta / 2.0 ) ) / delta; + + if ( r == v ) + { + h = deltaB - deltaG; + } + else if ( g == v ) + { + h = ( 1.0 / 3.0 ) + deltaR - deltaB; + } + else if ( b == v ) + { + h = ( 2.0 / 3.0 ) + deltaG - deltaR; + } + + if ( h < 0 ) + h += 1.0; + if ( h > 1 ) + h -= 1.0; + } + + cpu.output[0] = h; + cpu.output[1] = s; + cpu.output[2] = v; +} + +void prophoto2hsv(deConversionCPU& cpu) +{ + prophoto2rgb(cpu); + cpu.switchIO(); + rgb2hsv(cpu); +} + +void prophoto2hsl(deConversionCPU& cpu) +{ + prophoto2rgb(cpu); + cpu.switchIO(); + rgb2hsl(cpu); +} + +void lab2hsv(deConversionCPU& cpu) +{ + lab2rgb(cpu); + cpu.switchIO(); + rgb2hsv(cpu); +} + +void lch2hsv(deConversionCPU& cpu) +{ + lch2lab(cpu); + cpu.switchIO(); + lab2hsv(cpu); +} + +void bw2hsv(deConversionCPU& cpu) +{ + bw2rgb(cpu); + cpu.switchIO(); + rgb2hsv(cpu); +} + +void lab2hsl(deConversionCPU& cpu) +{ + lab2rgb(cpu); + cpu.switchIO(); + rgb2hsl(cpu); +} + +void lch2hsl(deConversionCPU& cpu) +{ + lch2lab(cpu); + cpu.switchIO(); + lab2hsl(cpu); +} + +void bw2hsl(deConversionCPU& cpu) +{ + bw2rgb(cpu); + cpu.switchIO(); + rgb2hsl(cpu); +} + + +void hsv2rgb(deConversionCPU& cpu) +{ + deValue h = cpu.input[0]; + deValue s = cpu.input[1]; + deValue v = cpu.input[2]; + + deValue r = 0.0; + deValue g = 0.0; + deValue b = 0.0; + + if ( s == 0 ) + { + r = v; + g = v; + b = v; + } + else + { + deValue var_h = h * 6.0; + + if ( var_h == 6.0 ) + { + var_h = 0; + } + + deValue var_i = int( var_h); + deValue var_1 = v * ( 1.0 - s ); + deValue var_2 = v * ( 1.0 - s * ( var_h - var_i ) ); + deValue var_3 = v * ( 1.0 - s * ( 1.0 - ( var_h - var_i ) ) ); + + if ( var_i == 0 ) + { + r = v; + g = var_3; + b = var_1; + } + else if ( var_i == 1 ) + { + r = var_2; + g = v; + b = var_1; + } + else if ( var_i == 2 ) + { + r = var_1; + g = v; + b = var_3; + } + else if ( var_i == 3 ) + { + r = var_1; + g = var_2; + b = v; + } + else if ( var_i == 4 ) + { + r = var_3; + g = var_1; + b = v; + } + else + { + r = v; + g = var_1; + b = var_2; + } + } + + cpu.output[0] = r; + cpu.output[1] = g; + cpu.output[2] = b; +} + +void hsv2cmyk(deConversionCPU& cpu) +{ + hsv2rgb(cpu); + cpu.switchIO(); + rgb2cmyk(cpu); +} + +void cmyk2hsv(deConversionCPU& cpu) +{ + cmyk2rgb(cpu); + cpu.switchIO(); + rgb2hsv(cpu); +} + +void cmyk2hsl(deConversionCPU& cpu) +{ + cmyk2rgb(cpu); + cpu.switchIO(); + rgb2hsl(cpu); +} + +void hsv2lab(deConversionCPU& cpu) +{ + hsv2rgb(cpu); + cpu.switchIO(); + rgb2lab(cpu); +} + +void hsv2bw(deConversionCPU& cpu) +{ + hsv2rgb(cpu); + cpu.switchIO(); + rgb2bw(cpu); +} + +void hsv2lch(deConversionCPU& cpu) +{ + hsv2rgb(cpu); + cpu.switchIO(); + rgb2lch(cpu); +} + + +deConversionCPU::deFunction getConversion(deColorSpace sourceColorSpace, deColorSpace targetColorSpace) +{ + if (sourceColorSpace == targetColorSpace) + { + return noConversion; + } + + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceRGB)) + { + return prophoto2rgb; + } + if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceRGB)) + { + return rgb2prophoto; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceLAB)) + { + return prophoto2lab; + } + if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceLAB)) + { + return lab2prophoto; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceLCH)) + { + return prophoto2lch; + } + if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceLCH)) + { + return lch2prophoto; + } + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceLAB)) + { + return rgb2lab; + } + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSL)) + { + return rgb2hsl; + } + + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSV)) + { + return rgb2hsv; + } + if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceHSV)) + { + return cmyk2hsv; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceHSV)) + { + return prophoto2hsv; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceHSV)) + { + return lch2hsv; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceHSV)) + { + return lab2hsv; + } + if ((targetColorSpace == deColorSpaceHSV) && (sourceColorSpace == deColorSpaceBW)) + { + return bw2hsv; + } + + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSL)) + { + return rgb2hsl; + } + if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceHSL)) + { + return cmyk2hsl; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceHSL)) + { + return prophoto2hsl; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceHSL)) + { + return lch2hsl; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceHSL)) + { + return lab2hsl; + } + if ((targetColorSpace == deColorSpaceHSL) && (sourceColorSpace == deColorSpaceBW)) + { + return bw2hsl; + } + + if ((sourceColorSpace == deColorSpaceHSL) && (targetColorSpace == deColorSpaceRGB)) + { + return hsl2rgb; + } + if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceRGB)) + { + return hsv2rgb; + } + if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceLAB)) + { + return hsv2lab; + } + if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceCMYK)) + { + return hsv2cmyk; + } + if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceBW)) + { + return hsv2bw; + } + if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceLCH)) + { + return hsv2lch; + } + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceLCH)) + { + return rgb2lch; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceRGB)) + { + return lch2rgb; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceCMYK)) + { + return lch2cmyk; + } + if ((targetColorSpace == deColorSpaceLCH) && (sourceColorSpace == deColorSpaceCMYK)) + { + return cmyk2lch; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceRGB)) + { + return lab2rgb; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceLCH)) + { + return lab2lch; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceLAB)) + { + return lch2lab; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceCMYK)) + { + return prophoto2cmyk; + } + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceCMYK)) + { + return rgb2cmyk; + } + if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceRGB)) + { + return cmyk2rgb; + } + if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceBW)) + { + return rgb2bw; + } + if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceBW)) + { + return rgb2bw; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceBW)) + { + return lab2bw; + } + if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceBW)) + { + return lch2bw; + } + if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceBW)) + { + return cmyk2bw; + } + if ((sourceColorSpace == deColorSpaceBW) && (targetColorSpace == deColorSpaceRGB)) + { + return bw2rgb; + } + if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceLAB)) + { + return cmyk2lab; + } + if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceCMYK)) + { + return lab2cmyk; + } + if ((targetColorSpace == deColorSpaceLAB) && (sourceColorSpace == deColorSpaceBW)) + { + return bw2lab; + } + if ((targetColorSpace == deColorSpaceLCH) && (sourceColorSpace == deColorSpaceBW)) + { + return bw2lch; + } + if ((targetColorSpace == deColorSpaceCMYK) && (sourceColorSpace == deColorSpaceBW)) + { + return bw2cmyk; + } + + logError("no conversion for " + getColorSpaceName(sourceColorSpace) + " -> " + getColorSpaceName(targetColorSpace)); + return NULL; + +} + + diff -Nru delaboratory-0.7/core/conversion_cpu.h delaboratory-0.8/core/conversion_cpu.h --- delaboratory-0.7/core/conversion_cpu.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/conversion_cpu.h 2012-06-23 07:19:49.000000000 +0000 @@ -0,0 +1,86 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CONVERSION_CPU_H +#define _DE_CONVERSION_CPU_H + +#include "value.h" +class deImage; +class deChannelManager; +#include "color_space.h" + +#define CPU_REGISTER_OVERFLOW 0 +#define CPU_REGISTER_CMYK_KEY_SUB 1 +#define CPU_REGISTER_CMYK_KEY_MAX 2 +#define CPU_REGISTER_CMYK_MIN_SUM 3 +#define CPU_REGISTER_BW_MIXER_R 4 +#define CPU_REGISTER_BW_MIXER_G 5 +#define CPU_REGISTER_BW_MIXER_B 6 +#define CPU_REGISTER_CONTRAST 7 +#define CPU_REGISTER_SATURATION 8 +#define CPU_REGISTER_PSEUDOGREY 9 + +#define CPU_REGISTERS 10 + +class deConversionCPU +{ + private: + public: + typedef void (*deFunction)(deConversionCPU& cpu); + + deValue* input; + deValue* output; + deValue* registers; + + deConversionCPU(int size); + virtual ~deConversionCPU(); + + void switchIO(); + void incOverflow(); + + void convertImage3x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage3x4(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage4x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage3x1(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage1x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage4x1(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + void convertImage1x4(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); + + bool renderImage1(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); + bool renderImage3(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); + bool renderImage4(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); + +}; + +void rgb2cmy(deConversionCPU& cpu); +void cmy2rgb(deConversionCPU& cpu); +void cmy2cmyk(deConversionCPU& cpu); +void cmyk2cmy(deConversionCPU& cpu); +void rgb2prophoto(deConversionCPU& cpu); +void prophoto2rgb(deConversionCPU& cpu); +void empty(deConversionCPU& cpu); +void rgb2lab(deConversionCPU& cpu); +void lab2rgb(deConversionCPU& cpu); +void prophoto2lab(deConversionCPU& cpu); +void lab2prophoto(deConversionCPU& cpu); +void cmyk2lab(deConversionCPU& cpu); +void lab2cmyk(deConversionCPU& cpu); + +deConversionCPU::deFunction getConversion(deColorSpace sourceColorSpace, deColorSpace targetColorSpace); + +#endif diff -Nru delaboratory-0.7/core/conversion_processor.cc delaboratory-0.8/core/conversion_processor.cc --- delaboratory-0.7/core/conversion_processor.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/conversion_processor.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,256 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "conversion_processor.h" + +#include "image.h" +#include "channel_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" + +#include "logger.h" + +#include "power.h" + +#include "str.h" + +void copyImage(const deImage& sourceImage, deImage& image) +{ + int n = getColorSpaceSize(sourceImage.getColorSpace()); + int i; + + for (i = 0; i < n; i++) + { + const deValue* source = sourceImage.startRead(i); + deValue* destination = image.startWrite(i); + copyChannel(source, destination, sourceImage.getChannelSize().getN()); + image.finishWrite(i); + sourceImage.finishRead(i); + } +} + +void applyContrastRGB(deConversionCPU& cpu) +{ + deValue a = cpu.registers[CPU_REGISTER_CONTRAST]; + deValue b = 0.5 - 0.5 * a; + + cpu.input[0] = a * cpu.input[0] + b; + cpu.input[1] = a * cpu.input[1] + b; + cpu.input[2] = a * cpu.input[2] + b; +} + +void applyContrastSaturationLAB(deConversionCPU& cpu) +{ + deValue a1 = cpu.registers[CPU_REGISTER_CONTRAST]; + deValue b1 = 0.5 - 0.5 * a1; + deValue a2 = cpu.registers[CPU_REGISTER_SATURATION]; + deValue b2 = 0.5 - 0.5 * a2; + + cpu.input[0] = a1 * cpu.input[0] + b1; + cpu.input[1] = a2 * cpu.input[1] + b2; + cpu.input[2] = a2 * cpu.input[2] + b2; +} + +void applyContrastSaturationLCH(deConversionCPU& cpu) +{ + deValue a1 = cpu.registers[CPU_REGISTER_CONTRAST]; + deValue b1 = 0.5 - 0.5 * a1; + deValue a2 = cpu.registers[CPU_REGISTER_SATURATION]; + + cpu.input[0] = a1 * cpu.input[0] + b1; + cpu.input[1] = a2 * cpu.input[1]; +} + + + +deConversionProcessor::deConversionProcessor() +{ +} + +deConversionProcessor::~deConversionProcessor() +{ +} + + +bool deConversionProcessor::convert(deColorSpace sourceColorSpace, deValue v1, deValue v2, deValue v3, deValue v4, deColorSpace targetColorSpace, deValue &r1, deValue& r2, deValue& r3, deValue& r4) +{ + deConversionCPU cpu(4); + deConversionCPU::deFunction f = getConversion(sourceColorSpace, targetColorSpace); + + if (!f) + { + return false; + } + + cpu.input[0] = v1; + cpu.input[1] = v2; + cpu.input[2] = v3; + cpu.input[3] = v4; + + f(cpu); + + r1 = cpu.output[0]; + r2 = cpu.output[1]; + r3 = cpu.output[2]; + r4 = cpu.output[3]; + + return true; +} + +bool deConversionProcessor::renderImageToRGBNew(const deImage& image, unsigned char* data) +{ + deColorSpace colorSpace = image.getColorSpace(); + + deConversionCPU cpu(4); + cpu.registers[CPU_REGISTER_OVERFLOW] = 0; + + int s = getColorSpaceSize(colorSpace); + + deConversionCPU::deFunction f = getConversion(colorSpace, deColorSpaceRGB); + + if (!f) + { + return false; + } + + if (s == 3) + { + return cpu.renderImage3(image, f, data); + } else + if (s == 4) + { + return cpu.renderImage4(image, f, data); + } else + if (s == 1) + { + return cpu.renderImage1(image, f, data); + }; + + return false; + +} + +void deConversionProcessor::convertImage(const deImage& sourceImage, deImage& image, deConversionCPU& cpu) +{ + deColorSpace sourceColorSpace = sourceImage.getColorSpace(); + deColorSpace targetColorSpace = image.getColorSpace(); + + if (sourceColorSpace == targetColorSpace) + { + copyImage(sourceImage, image); + return; + } + + int ss = getColorSpaceSize(sourceColorSpace); + int ds = getColorSpaceSize(targetColorSpace); + + deConversionCPU::deFunction f1 = empty; + + if (sourceColorSpace == deColorSpaceProPhoto) + { + if (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0) + { + f1 = applyContrastRGB; + } + } + if (sourceColorSpace == deColorSpaceLAB) + { + if ((cpu.registers[CPU_REGISTER_SATURATION] < 1.0) || (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0)) + { + f1 = applyContrastSaturationLAB; + } + } + if (sourceColorSpace == deColorSpaceLCH) + { + if ((cpu.registers[CPU_REGISTER_SATURATION] < 1.0) || (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0)) + { + f1 = applyContrastSaturationLCH; + } + } + + deConversionCPU::deFunction f2 = getConversion(sourceColorSpace, targetColorSpace); + if (!f2) + { + logError("conversion not found"); + } + + if ((ss == 3) && (ds == 3)) + { + if (f2) + { + cpu.convertImage3x3(sourceImage, image, f1, f2); + return; + } + } + else + if ((ss == 3) && (ds == 4)) + { + if (f2) + { + cpu.convertImage3x4(sourceImage, image, f1, f2); + return; + } + } + else + if ((ss == 4) && (ds == 3)) + { + if (f2) + { + cpu.convertImage4x3(sourceImage, image, f1, f2); + return; + } + } + else + if ((ss == 3) && (ds == 1)) + { + if (f2) + { + cpu.convertImage3x1(sourceImage, image, f1, f2); + return; + } + } + else + if ((ss == 1) && (ds == 3)) + { + if (f2) + { + cpu.convertImage1x3(sourceImage, image, f1, f2); + return; + } + } + if ((ss == 4) && (ds == 1)) + { + if (f2) + { + cpu.convertImage4x1(sourceImage, image, f1, f2); + return; + } + } + else + if ((ss == 1) && (ds == 4)) + { + if (f2) + { + cpu.convertImage1x4(sourceImage, image, f1, f2); + return; + } + } + + logError("convert image FAILED"); + +} diff -Nru delaboratory-0.7/core/conversion_processor.h delaboratory-0.8/core/conversion_processor.h --- delaboratory-0.7/core/conversion_processor.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/conversion_processor.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,42 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CONVERSION_PROCESSOR_H +#define _DE_CONVERSION_PROCESSOR_H + +#include "conversion_cpu.h" + + +class deConversionProcessor +{ + private: + + public: + deConversionProcessor(); + virtual ~deConversionProcessor(); + + void convertImage(const deImage& sourceImage, deImage& image, deConversionCPU& cpu); + + bool renderImageToRGBNew(const deImage& image, unsigned char* data); + bool convert(deColorSpace sourceColorSpace, deValue v1, deValue v2, deValue v3, deValue v4, deColorSpace targetColorSpace, deValue &r1, deValue& r2, deValue& r3, deValue& r4); + +}; + + + +#endif diff -Nru delaboratory-0.7/core/copy_channel.cc delaboratory-0.8/core/copy_channel.cc --- delaboratory-0.7/core/copy_channel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/copy_channel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "copy_channel.h" +#include + +void copyChannel(const deValue* src, deValue* dst, int n) +{ + int i; + for (i = 0; i < n; i++) + { + deValue v = src[i]; + dst[i] = v; + } +} + diff -Nru delaboratory-0.7/core/copy_channel.h delaboratory-0.8/core/copy_channel.h --- delaboratory-0.7/core/copy_channel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/copy_channel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COPY_CHANNEL_H +#define _DE_COPY_CHANNEL_H + +#include "value.h" + +void copyChannel(const deValue* src, deValue* dst, int n); + +#endif diff -Nru delaboratory-0.7/core/flatten_layers.cc delaboratory-0.8/core/flatten_layers.cc --- delaboratory-0.7/core/flatten_layers.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/flatten_layers.cc 2012-06-16 21:34:03.000000000 +0000 @@ -0,0 +1,124 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "flatten_layers.h" + +#include "progress_dialog.h" +#include "logger.h" +#include "layer_stack.h" +#include "base_layer.h" +#include "channel_manager.h" +#include "image_io.h" +#include "str.h" +#include + +bool flattenLayers(int view, deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, deLayerStack& layerStack, deChannelManager& previewChannelManager) +{ + bool result = true; + logInfo("flattenLayers"); + + std::map channelUsage; + int i; + int n = layerStack.getSize(); + for (i = 0; i < n; i++) + { + const deBaseLayer* layer = layerStack.startReadLayer(i); + + layer->updateChannelUsage(channelUsage, i); + + layerStack.finishReadLayer(i); + } + + unsigned int index; + int progress = 0; + for (index = 0; index <= (unsigned int)view; index++) + { + logInfo("flattenLayers index: " + str(index)); + std::map::iterator i; + int previous = index - 1; + if (previous >= 0) + { + for (i = channelUsage.begin(); i != channelUsage.end(); i++) + { + int c = i->first; + int l = i->second; + if (l == previous) + { + logInfo("deallocate " + str(c)); + previewChannelManager.tryDeallocateChannel(c); + } + } + } + + deBaseLayer* layer = layerStack.getLayer(index); + + std::string label = str(index); + + progressDialog.update(progress, label); + + layer->allocateChannels(); + + logInfo("flattenLayers process index: " + str(index)); + bool r = layer->processFull(); + if (r) + { + if (saveAll) + { + const deImage& image = layer->getLayerImage(); + const std::string f = insertIndex(fileName, index); + saveImage(f, image, type, previewChannelManager); + } + } + else + { + logError("flattenLayers - error on layer " + str(index)); + result = false; + // stop loop + index = view + 1; + } + + if (view > 0) + { + progress = 100 * index / view; + } + else + { + progress = 100; + } + + progressDialog.update(progress, label); + } + + progressDialog.update(100, "finished"); + + if ((result) && (!saveAll)) + { + logInfo("flattenLayers save final image"); + // take the final image + deBaseLayer* layer = layerStack.getLayer(view); + const deImage& image = layer->getLayerImage(); + + // save it + result = saveImage(fileName, image, type, previewChannelManager); + } + + logInfo("flattenLayers DONE"); + + return result; +} + diff -Nru delaboratory-0.7/core/flatten_layers.h delaboratory-0.8/core/flatten_layers.h --- delaboratory-0.7/core/flatten_layers.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/flatten_layers.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,29 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_FLATTEN_LAYERS_H +#define _DE_FLATTEN_LAYERS_H + +class deProgressDialog; +#include +class deLayerStack; +class deChannelManager; + +bool flattenLayers(int view, deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, deLayerStack& layerStack, deChannelManager& previewChannelManager); + +#endif diff -Nru delaboratory-0.7/core/generic_layer_frame.cc delaboratory-0.8/core/generic_layer_frame.cc --- delaboratory-0.7/core/generic_layer_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/generic_layer_frame.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,289 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "generic_layer_frame.h" +#include "base_layer.h" +#include "base_layer_with_source.h" +#include "property_numeric_ui.h" +#include "property_choice_ui.h" +#include "property_boolean_ui.h" +#include "property_levels_ui.h" +#include "property_curves_ui.h" +#include "property_mixer_ui.h" +#include "property_numeric.h" +#include "property_levels.h" +#include "property_curves.h" +#include "property_mixer.h" +#include "property_boolean.h" +#include "property_choice.h" +#include "preset_button.h" +#include "layer_processor.h" + +deGenericLayerFrame::deGenericLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager, int _index) +:deLayerFrame(parent, name, _layer, _frameManager, _index), layerProcessor(_layerProcessor) +{ + + deBaseLayerWithProperties* layerWP = dynamic_cast(&layer); + + addSizer("channels"); + addSizer("blend"); + + std::vector names; + std::vector::iterator i; + + deWindow& window = getWindow(); + + names.clear(); + if (layerWP) + { + layerWP->getProperties(names); + } + + int width = 400; + int widthn = 120; + int widthl = 35; + + for (i = names.begin(); i != names.end(); i++) + { + std::string n = *i; + deProperty* property = layerWP->getProperty(n); + + dePropertyNumeric* numeric = dynamic_cast(property); + if (numeric) + { + dePropertyNumericUI* p = new dePropertyNumericUI(window, *numeric, _layerProcessor, _index, width - widthn - widthl, widthn, widthl); + + numerics.push_back(p); + + addWidget(p->getWindow()); + } + + dePropertyChoice* choice = dynamic_cast(property); + if (choice) + { + dePropertyChoiceUI* p = new dePropertyChoiceUI(window, *choice, _layerProcessor, _index, *this); + + choices.push_back(p); + + std::string s = property->getSizer(); + if (s.size() > 0) + { + addWidget(s, p->getWindow()); + } + else + { + addWidget(p->getWindow()); + } + + + } + + dePropertyBoolean* boolean = dynamic_cast(property); + if (boolean) + { + dePropertyBooleanUI* p = new dePropertyBooleanUI(window, *boolean, _layerProcessor, _index); + + booleans.push_back(p); + + std::string s = property->getSizer(); + if (s.size() > 0) + { + addWidget(s, p->getWindow()); + } + else + { + addWidget(p->getWindow()); + } + } + + dePropertyLevels* propertyLevels = dynamic_cast(property); + if (propertyLevels) + { + deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); + dePropertyLevelsUI* p = new dePropertyLevelsUI(window, *propertyLevels, _layerProcessor, _index, layerWithSource, width); + + levels.push_back(p); + + addWidget(p->getWindow()); + } + + dePropertyCurves* propertyCurves = dynamic_cast(property); + if (propertyCurves) + { + deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); + dePropertyCurvesUI* p = new dePropertyCurvesUI(window, *propertyCurves, _layerProcessor, _index, layerWithSource, width); + + curves.push_back(p); + + addWidget(p->getWindow()); + } + + dePropertyMixer* propertyMixer = dynamic_cast(property); + if (propertyMixer) + { + deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); + dePropertyMixerUI* p = new dePropertyMixerUI(window, *propertyMixer, _layerProcessor, _index, layerWithSource, width); + + mixers.push_back(p); + + addWidget(p->getWindow()); + } + } + + addSizer("presets"); + + names.clear(); + if (layerWP) + { + layerWP->getPresets(names); + + for (i = names.begin(); i != names.end(); i++) + { + std::string n = *i; + dePresetButton* b = new dePresetButton(window, *layerWP, n, _layerProcessor, _index, *this); + + addWidget("presets", b->getWindow()); + } + } + + fit(); +} + +deGenericLayerFrame::~deGenericLayerFrame() +{ + // we need to destroy our UI data here + + std::vector::iterator i; + for (i = numerics.begin(); i != numerics.end(); i++) + { + delete (*i); + } + std::vector::iterator j; + for (j = levels.begin(); j != levels.end(); j++) + { + delete (*j); + } + { + std::vector::iterator j; + for (j = curves.begin(); j != curves.end(); j++) + { + delete (*j); + } + } + std::vector::iterator k; + for (k = choices.begin(); k != choices.end(); k++) + { + delete (*k); + } + std::vector::iterator l; + for (l = booleans.begin(); l != booleans.end(); l++) + { + delete (*l); + } + { + std::vector::iterator l; + for (l = mixers.begin(); l != mixers.end(); l++) + { + delete (*l); + } + } +} + +void deGenericLayerFrame::setUIFromLayer() +{ + layer.beforeSetUIFromLayer(); + + std::vector::iterator i; + for (i = numerics.begin(); i != numerics.end(); i++) + { + (*i)->setFromProperty(); + } + std::vector::iterator j; + for (j = levels.begin(); j != levels.end(); j++) + { + (*j)->setFromProperty(); + } + { + std::vector::iterator j; + for (j = curves.begin(); j != curves.end(); j++) + { + (*j)->setFromProperty(); + } + } + std::vector::iterator k; + for (k = choices.begin(); k != choices.end(); k++) + { + (*k)->setFromProperty(); + } + std::vector::iterator l; + for (l = booleans.begin(); l != booleans.end(); l++) + { + (*l)->setFromProperty(); + } + { + std::vector::iterator l; + for (l = mixers.begin(); l != mixers.end(); l++) + { + (*l)->setFromProperty(); + } + } +} + +bool deGenericLayerFrame::onImageClick(deValue x, deValue y) +{ + if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) + { + return false; + } + + { + std::vector::iterator j; + for (j = curves.begin(); j != curves.end(); j++) + { + (*j)->onImageClick(x,y); + } + } + + if (layer.onImageClick(x, y)) + { + setUIFromLayer(); + layerProcessor.markUpdateAllChannels(index); + return true; + } + + return false; +} + +bool deGenericLayerFrame::onKey(int key) +{ + { + std::vector::iterator j; + for (j = curves.begin(); j != curves.end(); j++) + { + if ((*j)->onKey(key)) + { + setUIFromLayer(); + layerProcessor.markUpdateAllChannels(index); + return true; + } + } + } + + return false; +} + diff -Nru delaboratory-0.7/core/generic_layer_frame.h delaboratory-0.8/core/generic_layer_frame.h --- delaboratory-0.7/core/generic_layer_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/generic_layer_frame.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,53 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GENERIC_LAYER_FRAME_H +#define _DE_GENERIC_LAYER_FRAME_H + +#include "layer_frame.h" +class deLayerProcessor; +#include +class dePropertyNumericUI; +class dePropertyChoiceUI; +class dePropertyBooleanUI; +class dePropertyLevelsUI; +class dePropertyCurvesUI; +class dePropertyMixerUI; + +class deGenericLayerFrame:public deLayerFrame +{ + protected: + std::vector numerics; + std::vector choices; + std::vector booleans; + std::vector levels; + std::vector curves; + std::vector mixers; + + deLayerProcessor& layerProcessor; + public: + deGenericLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager, int _index); + virtual ~deGenericLayerFrame(); + + virtual void setUIFromLayer(); + + virtual bool onImageClick(deValue x, deValue y); + virtual bool onKey(int key); +}; + +#endif diff -Nru delaboratory-0.7/core/histogram.cc delaboratory-0.8/core/histogram.cc --- delaboratory-0.7/core/histogram.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/histogram.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,211 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "histogram.h" +#include +#include "logger.h" + +deHistogram::deHistogram(int _size) +:size(_size) +{ + bars.reserve(size); + clear(); +} + +deHistogram::~deHistogram() +{ +} + +void deHistogram::clear() +{ + int i; + for (i = 0; i < size; i++) + { + bars[i] = 0 ; + } +} + +void deHistogram::put(deValue value) +{ + if ((value < 0) || (value > 1)) + { + return; + } + + int bar = (size-1) * value; + + bars[bar] ++; +} + + +int deHistogram::getMax() const +{ + int i; + int m = 0; + for (i = 0; i < size; i++) + { + if (bars[i] > m) + { + m = bars[i]; + } + } + return m; +} + +int deHistogram::get(int bar) const +{ + return bars[bar]; +} + +int deHistogram::getSize() const +{ + return size; +} + +void deHistogram::calc(const deValue* pixels, int n) +{ + if (!pixels) + { + logError("NULL pixels in histogram calc"); + return; + } + + static int counter = 0; + + int j; + int scale = size - 1; + for (j = 0; j < n; j++) + { + deValue value = pixels[j]; + counter++; + int bar = scale * value; + if ((bar >= 0) && (bar < size)) + { + bars[bar] ++; + } + } + +} + +bool deHistogram::render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2, int margin) +{ + int mm = getMax(); + if (mm <= 0) + { + return false; + } + + unsigned char g3 = 230; + + int x; + int y; + for (x = 0; x < sizeW; x++) + { + int xx = x - margin; + + if ((xx >= 0) && (xx < size)) + { + int hh = get(xx); + int h = sizeH * hh / mm; + if (h > sizeH) + { + h = sizeH; + } + for (y = 0; y < sizeH - h; y++) + { + data[3*(y*sizeW+x)] = g1; + data[3*(y*sizeW+x)+1] = g1; + data[3*(y*sizeW+x)+2] = g1; + } + for (y = sizeH - h; y < sizeH; y++) + { + data[3*(y*sizeW+x)] = g2; + data[3*(y*sizeW+x)+1] = g2; + data[3*(y*sizeW+x)+2] = g2; + } + } + else + { + for (y = 0; y < sizeH; y++) + { + data[3*(y*sizeW+x)] = g3; + data[3*(y*sizeW+x)+1] = g3; + data[3*(y*sizeW+x)+2] = g3; + } + } + } + + return true; +} + +void deHistogram::calcLevels(deValue margin1, deValue margin2, deValue& min, deValue& middle, deValue& max) +{ + int i; + + deValue sum = 0.0; + for (i = 0; i < size; i++) + { + deValue b = bars[i]; + sum += b; + } + + deValue left = -1; + deValue right = -1; + deValue leftMiddle = -1; + deValue rightMiddle = -1; + + deValue s = 0.0; + for (i = 0; i < size; i++) + { + deValue b = bars[i]; + s += b; + + deValue p = s / sum; + if ((p >= 1.0 - margin1) && (right < 0)) + { + right = (deValue) i / (size - 1); + } + if ((p >= 1.0 - margin2) && (rightMiddle < 0)) + { + rightMiddle = (deValue) i / (size - 1); + } + } + + s = 0.0; + for (i = size - 1; i >= 0; i--) + { + deValue b = bars[i]; + s += b; + + deValue p = s / sum; + if ((p >= 1.0 - margin1) && (left < 0)) + { + left = (deValue) i / (size - 1); + } + if ((p >= 1.0 - margin2) && (leftMiddle < 0)) + { + leftMiddle = (deValue) i / (size - 1); + } + } + + min = left; + max = right; + middle = (leftMiddle + rightMiddle) / 2.0; + +} + diff -Nru delaboratory-0.7/core/histogram.h delaboratory-0.8/core/histogram.h --- delaboratory-0.7/core/histogram.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/histogram.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,50 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HISTOGRAM_H +#define _DE_HISTOGRAM_H + +#include +#include +#include "value.h" + +class deHistogram +{ + private: + std::vector bars; + int size; + + public: + deHistogram(int _size); + virtual ~deHistogram(); + + void put(deValue value); + void calc(const deValue* pixels, int n); + int get(int bar) const; + void clear(); + + int getMax() const; + int getSize() const; + + bool render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2, int margin); + + void calcLevels(deValue margin1, deValue margin2, deValue& min, deValue& middle, deValue& max); + +}; + +#endif diff -Nru delaboratory-0.7/core/image.cc delaboratory-0.8/core/image.cc --- delaboratory-0.7/core/image.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/image.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,188 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "image.h" +#include "channel_manager.h" +#include "logger.h" +#include "str.h" +#include "color_space_utils.h" +#include + +deImage::deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager) +:colorSpace(_colorSpace), channelManager(_channelManager) +{ + logInfo("image constructor"); + int i; + int s = getColorSpaceSize(colorSpace); + for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) + { + if (i < s) + { + channelsAllocated[i] = channelManager.reserveNewChannel(); + } + else + { + channelsAllocated[i] = -1; + } + } +} + +deImage::~deImage() +{ + logInfo("image destructor"); + int i; + int s = getColorSpaceSize(colorSpace); + for (i = 0; i < s; i++) + { + int a = channelsAllocated[i]; + logInfo("destroying channel " + str(a)); + channelManager.freeChannel(a); + } +} + +void deImage::allocateChannels() +{ + int s = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < s; i++) + { + channelManager.tryAllocateChannel(channelsAllocated[i]); + } +} + +int deImage::getChannelIndex(int n) const +{ + if (n < 0) + { + logError("deImage::getChannelIndex n: " + str(n)); + } + else if (n >= MAX_COLOR_SPACE_SIZE) + { + logError("deImage::getChannelIndex n: " + str(n)); + } + return channelsAllocated[n]; +} + +deColorSpace deImage::getColorSpace() const +{ + return colorSpace; +} + +void deImage::updateChannelUsage(std::map& channelUsage, int index) const +{ + int i; + int s = getColorSpaceSize(colorSpace); + for (i = 0; i < s; i++) + { + int c = channelsAllocated[i]; + channelUsage[c] = index; + } +} + +const deValue* deImage::startRead(int channel) const +{ +#ifdef DEBUG_LOG + logInfo("image start read " + str(channel)); +#endif + + if (channel < 0) + { + logError("image start read " + str(channel)); + return NULL; + } + else if (channel >= MAX_COLOR_SPACE_SIZE) + { + logError("image start read " + str(channel)); + return NULL; + } + int index = channelsAllocated[channel]; + + const deValue* values = channelManager.startRead(index); + + return values; +} + +void deImage::finishRead(int channel) const +{ +#ifdef DEBUG_LOG + logInfo("image finish read " + str(channel)); +#endif + if (channel < 0) + { + logError("image finish read " + str(channel)); + return; + } + else if (channel >= MAX_COLOR_SPACE_SIZE) + { + logError("image finish read " + str(channel)); + return; + } + int index = channelsAllocated[channel]; + channelManager.finishRead(index); + +} + +deValue* deImage::startWrite(int channel) +{ +#ifdef DEBUG_LOG + logInfo("image start write " + str(channel)); +#endif + + if (channel < 0) + { + logError("image start write " + str(channel)); + return NULL; + } + else if (channel >= MAX_COLOR_SPACE_SIZE) + { + logError("image start write " + str(channel)); + return NULL; + } + + int index = channelsAllocated[channel]; + + deValue* values = channelManager.startWrite(index); + + return values; +} + +void deImage::finishWrite(int channel) +{ +#ifdef DEBUG_LOG + logInfo("image finish write " + str(channel)); +#endif + if (channel < 0) + { + logError("image finish write " + str(channel)); + return; + } + else if (channel >= MAX_COLOR_SPACE_SIZE) + { + logError("image finish write " + str(channel)); + return; + } + int index = channelsAllocated[channel]; + channelManager.finishWrite(index); + +} + +const deSize deImage::getChannelSize() const +{ + return channelManager.getChannelSizeFromChannelManager(); +} + diff -Nru delaboratory-0.7/core/image.h delaboratory-0.8/core/image.h --- delaboratory-0.7/core/image.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/image.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,64 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_IMAGE_H +#define _DE_IMAGE_H + +#include "color_space.h" +#include "value.h" +#include +class deChannelManager; +#include "size.h" +#include "mutex.h" + +class deImage +{ + private: + const deColorSpace colorSpace; + int channelsAllocated[MAX_COLOR_SPACE_SIZE]; + deChannelManager& channelManager; + mutable deMutex mutex; + + deImage(const deImage& i); + deImage& operator = (const deImage& i); + + public: + deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager); + + virtual ~deImage(); + + deColorSpace getColorSpace() const; + + int getChannelIndex(int n) const; + + void updateChannelUsage(std::map& channelUsage, int index) const; + + const deValue* startRead(int channel) const; + void finishRead(int channel) const; + + deValue* startWrite(int channel); + void finishWrite(int channel); + + const deSize getChannelSize() const; + + void allocateChannels(); + + +}; + +#endif diff -Nru delaboratory-0.7/core/layer_factory.cc delaboratory-0.8/core/layer_factory.cc --- delaboratory-0.7/core/layer_factory.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_factory.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,247 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_factory.h" +#include "layer_stack.h" +#include "curves_layer.h" +#include "equalizer_layer.h" +#include "fill_layer.h" +#include "tone_layer.h" +#include "saturation_layer.h" +#include "white_balance_layer.h" +#include "exposure_layer.h" +#include "vignette_layer.h" +#include "gradient_layer.h" +#include "gaussian_blur_layer.h" +#include "gaussian_blur_single_layer.h" +#include "recover_highlights_layer.h" +#include "recover_shadows_layer.h" +#include "mixer_layer.h" +#include "copy_layer.h" +#include "conversion_layer.h" +#include "source_image_layer.h" +#include "high_pass_layer.h" +#include "c2g_layer.h" +#include +#include "color_space_utils.h" +#include "levels_layer.h" +#include "local_contrast_layer.h" +#include "sharpen_layer.h" +#include "auto_dodge_layer.h" +#include "auto_burn_layer.h" + +deBaseLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, deStaticImage& sourceImage) +{ + if (type == "curves") + { + return new deCurvesLayer(colorSpace, source, _layerStack, _channelManager); + } + + if (type == "equalizer") + { + return new deEqualizerLayer(colorSpace, source, _layerStack, _channelManager, _viewManager); + } + + if (type == "mixer") + { + return new deMixerLayer(colorSpace, source, _layerStack, _channelManager, _viewManager); + } + + if (type == "copy") + { + return new deCopyLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "levels") + { + return new deLevelsLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "fill") + { + return new deFillLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "tone") + { + return new deToneLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "exposure") + { + return new deExposureLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "saturation") + { + return new deSaturationLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "white_balance") + { + return new deWhiteBalanceLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "local_contrast") + { + return new deLocalContrastLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "auto_dodge") + { + return new deAutoDodgeLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "auto_burn") + { + return new deAutoBurnLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "sharpen") + { + return new deSharpenLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "high_pass") + { + return new deHighPassLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "c2g") + { + return new deC2GLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "vignette") + { + return new deVignetteLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "gradient") + { + return new deGradientLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "gaussian_blur") + { + return new deGaussianBlurLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "gaussian_blur_single") + { + return new deGaussianBlurSingleLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "recover_highlights") + { + return new deRecoverHighlightsLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "recover_shadows") + { + return new deRecoverShadowsLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); + } + + if (type == "conversion") + { + return new deConversionLayer(colorSpace, _channelManager, source, _layerStack); + } + + if (type == "original") + { + return new deSourceImageLayer(_channelManager, _viewManager, sourceImage, colorSpace); + } + + return NULL; +} + +void getSupportedActions(std::vector& actions) +{ + actions.push_back("levels"); + actions.push_back("curves"); + actions.push_back("equalizer"); + actions.push_back("exposure"); + actions.push_back("saturation"); + actions.push_back("white_balance"); + actions.push_back("fill"); + actions.push_back("tone"); + actions.push_back("local_contrast"); + actions.push_back("auto_dodge"); + actions.push_back("auto_burn"); + actions.push_back("sharpen"); + actions.push_back("vignette"); + actions.push_back("gradient"); + actions.push_back("gaussian_blur"); + actions.push_back("recover_highlights"); + actions.push_back("recover_shadows"); + actions.push_back("mixer"); + actions.push_back("high_pass"); + actions.push_back("c2g"); + actions.push_back("copy"); +} + +std::string getActionDescription(const std::string& a) +{ + if (a == "shadows_highlights") + { + return "sh / hi"; + } + + if (a == "high_pass") + { + return "high pass"; + } + + if (a == "dodge_burn") + { + return "d / b"; + } + + if (a == "local_contrast") + { + return "loc contrast"; + } + + if (a == "gaussian_blur") + { + return "g. blur"; + } + + if (a == "gaussian_blur_single") + { + return "g. blur s"; + } + + if (a == "white_balance") + { + return "wb"; + } + + if (a == "recover_highlights") + { + return "highlights"; + } + + if (a == "recover_shadows") + { + return "shadows"; + } + + return a; +} + diff -Nru delaboratory-0.7/core/layer_factory.h delaboratory-0.8/core/layer_factory.h --- delaboratory-0.7/core/layer_factory.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_factory.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_FACTORY_H +#define _DE_LAYER_FACTORY_H + +class deLayer; +class deBaseLayer; +#include +#include +#include "color_space.h" +class deLayerStack; +class deLayerProcessor; +class deChannelManager; +class deViewManager; +class deImage; +class deStaticImage; + +deBaseLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, deStaticImage& sourceImage); +void getSupportedActions(std::vector& actions); +std::string getActionDescription(const std::string& a); + +#endif diff -Nru delaboratory-0.7/core/layer_frame.cc delaboratory-0.8/core/layer_frame.cc --- delaboratory-0.7/core/layer_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_frame.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,35 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_frame.h" +#include "layer_frame_manager.h" +#include "logger.h" +#include "str.h" + +deLayerFrame::deLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerFrameManager& _frameManager, int _index) +:deFrame(parent, name), layer(_layer), frameManager(_frameManager), index(_index) +{ + frameManager.addLayerFrame(index, this); +} + +deLayerFrame::~deLayerFrame() +{ + logInfo(" ~deLayerFrame"); + frameManager.removeLayerFrame(index); + logInfo(" ~deLayerFrame DONE"); +} diff -Nru delaboratory-0.7/core/layer_frame.h delaboratory-0.8/core/layer_frame.h --- delaboratory-0.7/core/layer_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_frame.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_FRAME_H +#define _DE_LAYER_FRAME_H + +#include "frame.h" +#include "value.h" +class deActionLayer; +class deBaseLayer; +class deLayerFrameManager; + +class deLayerFrame:public deFrame +{ + protected: + deBaseLayer& layer; + deLayerFrameManager& frameManager; + int index; + public: + deLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerFrameManager& _frameManager, int _index); + virtual ~deLayerFrame(); + + virtual void setUIFromLayer() = 0; + virtual bool onImageClick(deValue x, deValue y) {return false;}; + virtual bool onKey(int key) {return false;}; +}; + +#endif diff -Nru delaboratory-0.7/core/layer_processor.cc delaboratory-0.8/core/layer_processor.cc --- delaboratory-0.7/core/layer_processor.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_processor.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,660 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_processor.h" +#include "main_window.h" +#include "main_frame_events.h" +#include "layer_frame_manager.h" +#include "layer_stack.h" +#include "view_manager.h" +#include +#include "base_layer.h" +#include "channel_manager.h" +#include "str.h" +#include "progress_dialog.h" +#include +#include "logger.h" +#include "renderer.h" +#include "image_io.h" +#include "layer_processor_threads.h" +#include "flatten_layers.h" +#include "gui.h" + +deLayerProcessor::deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deMainWindow& _mainWindow) +: +layerStack(_layerStack), +layerFrameManager(_layerFrameManager), +renderer(_previewChannelManager), +previewChannelManager(_previewChannelManager), +mainWindow(_mainWindow) +{ +#ifdef DEBUG_LOG + logInfo("layer processor constructor"); +#endif + viewManager = NULL; + + firstLayerToUpdate = 0; + lastValidLayer = -1; + + layerProcessType = deLayerProcessInvalid; + layerProcessChannel = -1; + + closing = false; + + threads = new deLayerProcessorThreads(*this); + +} + +void deLayerProcessor::onDestroyAll() +{ + lockLayerProcessor(); + + lastValidLayer = -1; + + unlockLayerProcessor(); +} + +deLayerProcessor::~deLayerProcessor() +{ +#ifdef DEBUG_LOG + logInfo("layer processor destructor"); +#endif + delete threads; +} + +void deLayerProcessor::stopWorkerThread() +{ + closing = true; + threads->stopWorkerThread(); +} + +void deLayerProcessor::startWorkerThread() +{ + threads->startWorkerThread(); +} + +void deLayerProcessor::setViewManager(deViewManager* _viewManager) +{ + viewManager = _viewManager; +} + +void deLayerProcessor::repaintImageInLayerProcessor() +{ + if (closing) + { + logInfo("skip repaintImage because closing"); + return; + } +#ifdef DEBUG_LOG + logInfo("repaintImage"); +#endif + + threads->renderPost(); + generateHistogram(); + +} + +void deLayerProcessor::generateHistogram() +{ + if (closing) + { + logInfo("skip generateHistogram because closing"); + return; + } + + threads->histogramPost(); +} + +void deLayerProcessor::sendRepaintEvent() +{ + if (closing) + { + return; + } + + mainWindow.postEvent(DE_REPAINT_EVENT, 0 ); +} + +void deLayerProcessor::sendInfoEvent(int i) +{ + if (closing) + { + return; + } + + mainWindow.postEvent(DE_INFO_EVENT, i ); +} + +void deLayerProcessor::sendHistogramEvent() +{ + if (closing) + { + return; + } + + mainWindow.postEvent(DE_HISTOGRAM_EVENT, 0 ); +} + +void deLayerProcessor::updateAllImages(bool calcHistogram) +{ + updateImages(0, -1, true); +} + +void deLayerProcessor::lockLayers() const +{ +#ifdef DEBUG_LOG + logInfo("locking layer process mutex..."); +#endif + layerProcessMutex.lock(); +#ifdef DEBUG_LOG + logInfo("layer process mutex locked"); +#endif +} + +void deLayerProcessor::unlockLayers() const +{ +#ifdef DEBUG_LOG + logInfo("unlocking layer process mutex"); +#endif + layerProcessMutex.unlock(); +} + +void deLayerProcessor::lockHistogram() +{ +#ifdef DEBUG_LOG + logInfo("locking histogram mutex..."); +#endif + histogramMutex.lock(); +#ifdef DEBUG_LOG + logInfo("histogram mutex locked"); +#endif +} + +void deLayerProcessor::unlockHistogram() +{ +#ifdef DEBUG_LOG + logInfo("unlocking histogram mutex"); +#endif + histogramMutex.unlock(); +} + +void deLayerProcessor::lockUpdateImage() +{ +#ifdef DEBUG_LOG + logInfo("locking update image mutex..."); +#endif + updateImageMutex.lock(); +#ifdef DEBUG_LOG + logInfo("update image mutex locked"); +#endif +} + +void deLayerProcessor::unlockUpdateImage() +{ +#ifdef DEBUG_LOG + logInfo("unlocking update image mutex"); +#endif + updateImageMutex.unlock(); +} + +void deLayerProcessor::lockPrepareImage() +{ +#ifdef DEBUG_LOG + logInfo("locking prepare image mutex..."); +#endif + prepareImageMutex.lock(); +#ifdef DEBUG_LOG + logInfo("prepare image mutex locked"); +#endif +} + +void deLayerProcessor::unlockPrepareImage() +{ +#ifdef DEBUG_LOG + logInfo("unlocking prepare image mutex"); +#endif + prepareImageMutex.unlock(); +} + +void deLayerProcessor::updateImages(int a, int channel, bool action) +{ + if (closing) + { + return; + } + + lockLayers(); + + if (a == firstLayerToUpdate) + { + if (layerProcessChannel != channel) + { + channel = -1; + } + } + + if (a < firstLayerToUpdate) + { + firstLayerToUpdate = a; + } + + if (channel >= 0) + { + layerProcessType = deLayerProcessSingleChannel; + layerProcessChannel = channel; + } + else + { + if (action) + { + layerProcessType = deLayerProcessFull; + } + else + { + layerProcessType = deLayerProcessBlend; + } + } + + unlockLayers(); + + checkUpdateImagesRequest(); + +} + +bool deLayerProcessor::updateLayerImage() +{ +#ifdef DEBUG_LOG + logInfo("updateLayerImage"); +#endif + lockUpdateImage(); + + lockLayers(); + + bool ok = true; + bool result = false; + + if (firstLayerToUpdate > getLastLayerToUpdate()) + { + ok = false; + } + + int i = firstLayerToUpdate; + + deLayerProcessType type = deLayerProcessInvalid; + int channel = -1; + + deBaseLayer* layer = layerStack.getLayer(i); + + if ((layer) && (ok)) + { + layer->lockLayer(); + + type = layerProcessType; + channel = layerProcessChannel; + + layerProcessType = deLayerProcessFull; + + lastValidLayer = i; + firstLayerToUpdate = i + 1; + } + + unlockLayers(); + + if ((layer) && (ok)) + { + layer->processLayer(type, channel); + + layer->unlockLayer(); + + result = true; + } + + unlockUpdateImage(); + + updateWarning(); + + return result; + +} + +void deLayerProcessor::updateWarning() +{ + if (closing) + { + return; + } + + mainWindow.postEvent(DE_WARNING_EVENT, 0 ); +} + +bool deLayerProcessor::updateImagesSmart(deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, const deSize& size, deGUI& gui) +{ + gui.lockSize(); + + lockLayerProcessor(); + lockHistogram(); + lockPrepareImage(); + lockUpdateImage(); + + // remember original size of preview + deSize originalSize = previewChannelManager.getChannelSizeFromChannelManager(); + + // calculate final image in full size + int view = viewManager->getView(); + + previewChannelManager.setChannelSize(size, false); + + bool result = flattenLayers(view, progressDialog, fileName, type, saveAll, layerStack, previewChannelManager); + + // bring back original size of preview + previewChannelManager.setChannelSize(originalSize, true); + + unlockUpdateImage(); + unlockPrepareImage(); + unlockHistogram(); + unlockLayerProcessor(); + + gui.unlockSize(); + + return result; +} + +void deLayerProcessor::markUpdateSingleChannel(int index, int channel) +{ +#ifdef DEBUG_LOG + logInfo("markUpdateSingleChannel " +str(index) + " " + str(channel)); +#endif + updateImages(index, channel, true); +} + +void deLayerProcessor::markUpdateAllChannels(int index) +{ + updateImages(index, -1, true); +} + +void deLayerProcessor::markUpdateBlendAllChannels(int index) +{ + updateImages(index, -1, false); +} + +void deLayerProcessor::onChangeView(int a) +{ + updateImages(a + 1, -1, true); + updateWarning(); +} + +void deLayerProcessor::lockLayerProcessor() +{ +#ifdef DEBUG_LOG + logInfo("layer processor lock..."); +#endif + updateImagesMutex.lock(); +#ifdef DEBUG_LOG + logInfo("layer processor locked"); +#endif +} + +void deLayerProcessor::unlockLayerProcessor() +{ +#ifdef DEBUG_LOG + logInfo("layer processor unlock"); +#endif + updateImagesMutex.unlock(); +} + +void deLayerProcessor::tickWork() +{ + sendInfoEvent(DE_PROCESSING_START); + + bool result = updateLayerImage(); + + if (result) + { + checkUpdateImagesRequest(); + + repaintImageInLayerProcessor(); + } + + sendInfoEvent(DE_PROCESSING_END); +} + +void deLayerProcessor::onChangeViewMode() +{ + repaintImageInLayerProcessor(); +} + +void deLayerProcessor::onGUIUpdate() +{ + sendRepaintEvent(); +} + +void deLayerProcessor::removeTopLayerInLayerProcessor() +{ + logInfo("removeTopLayer"); + lockHistogram(); + lockPrepareImage(); + lockUpdateImage(); + + int index = layerStack.getSize() - 1; + logInfo("requested remove top layer " + str(index)); + if (index > 0) + { + layerStack.removeTopLayer(); + int view = viewManager->getView(); + if (view >= layerStack.getSize()) + { + viewManager->setView( layerStack.getSize() - 1 ); + } + repaintImageInLayerProcessor(); + } + + unlockUpdateImage(); + unlockPrepareImage(); + unlockHistogram(); + logInfo("removeTopLayer DONE"); +} + +void deLayerProcessor::removeAllLayers() +{ + logInfo("removeAllLayers"); + lockHistogram(); + lockPrepareImage(); + lockUpdateImage(); + + while (layerStack.getSize() > 0) + { + layerStack.removeTopLayer(); + } + + repaintImageInLayerProcessor(); + + unlockUpdateImage(); + unlockPrepareImage(); + unlockHistogram(); + logInfo("removeAllLayers DONE"); +} + +void deLayerProcessor::addLayerInLayerProcessor(deBaseLayer* layer) +{ + layerStack.addLayer(layer); + + int n = layerStack.getSize(); + + markUpdateAllChannels(n-1); + +} + +void deLayerProcessor::checkUpdateImagesRequest() +{ + lockLayers(); + + bool ok = true; + + if (firstLayerToUpdate > getLastLayerToUpdate()) + { + ok = false; + } + + if (ok) + { + threads->workerPost(); + } + + unlockLayers(); +} + +int deLayerProcessor::getLastLayerToUpdate() +{ + if (!viewManager) + { + return 0; + } + else + { + int n = viewManager->getView(); + return n; + } +} + +bool deLayerProcessor::prepareImage() +{ + if (previewChannelManager.isImageEmpty()) + { + return false; + } + +#ifdef DEBUG_LOG + logInfo("prepare image start"); +#endif + + sendInfoEvent(DE_RENDERING_START); + + bool result = false; + lockPrepareImage(); + lockLayerProcessor(); + + if (!closing) + { + if (viewManager) + { + result = renderer.prepareImage(*viewManager, *this, layerStack); + } + } + + unlockLayerProcessor(); + unlockPrepareImage(); + + sendInfoEvent(DE_RENDERING_END); +#ifdef DEBUG_LOG + logInfo("prepare image DONE"); +#endif + + return result; +} + +void deLayerProcessor::onGenerateHistogram() +{ + sendInfoEvent(DE_HISTOGRAM_START); + + lockHistogram(); + + if (!closing) + { + mainWindow.generateHistogram(); + } + + unlockHistogram(); + + sendInfoEvent(DE_HISTOGRAM_END); +} + +void deLayerProcessor::forceUpdateSize() +{ + mainWindow.forceUpdateSize(); +} + +void deLayerProcessor::setPreviewSize(const deSize& size, bool canSkip) +{ + deSize oldSize = previewChannelManager.getChannelSizeFromChannelManager(); + if ((oldSize == size) && (canSkip)) + { + logInfo("skip set preview size"); + return; + } + + if (size.getW() < 0) + { + logError("broken size passed to setPreviewSize, w: " + str(size.getW())); + } + + if (size.getH() < 0) + { + logError("broken size passed to setPreviewSize, h: " + str(size.getH())); + } + + logInfo("setPreviewSize start"); + + lockHistogram(); + lockPrepareImage(); + lockUpdateImage(); + + previewChannelManager.setChannelSize(size, true); + + updateAllImages(false); + + unlockUpdateImage(); + unlockPrepareImage(); + unlockHistogram(); + logInfo("setPreviewSize DONE"); +} + +void deLayerProcessor::onImageLoad() +{ + logInfo("onImageLoad"); + lockHistogram(); + lockPrepareImage(); + lockUpdateImage(); + + updateAllImages(false); + + unlockUpdateImage(); + unlockPrepareImage(); + unlockHistogram(); + logInfo("onImageLoad DONE"); +} + +void deLayerProcessor::render(deCanvas& canvas) +{ + renderer.render(canvas); +} + +void deLayerProcessor::setHistogramChannel(int channel) +{ + if (viewManager) + { + viewManager->setHistogramChannel(channel); + } +} + +int deLayerProcessor::getLastValidLayer() const +{ + lockLayers(); + int l = lastValidLayer; + unlockLayers(); + return l; +} diff -Nru delaboratory-0.7/core/layer_processor.h delaboratory-0.8/core/layer_processor.h --- delaboratory-0.7/core/layer_processor.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_processor.h 2012-06-27 18:13:03.000000000 +0000 @@ -0,0 +1,163 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_PROCESSOR_H +#define _DE_LAYER_PROCESSOR_H + +class deMainWindow; +class deLayerStack; +class deViewManager; +class deChannelManager; +class deProgressDialog; +class deLayer; +class deLogger; +class deLayerFrameManager; +class deLayerProcessorThreads; +class deGUI; +#include +#include "size.h" +#include "renderer.h" +#include "semaphore.h" +#include "base_layer.h" + +enum +{ + DE_PROCESSING_START, + DE_PROCESSING_END, + DE_RENDERING_START, + DE_RENDERING_END, + DE_HISTOGRAM_START, + DE_HISTOGRAM_END, + DE_DCRAW_START, + DE_DCRAW_END, + DE_DEBUG_START, + DE_DEBUG_END +}; + +class deLayerProcessor +{ + private: + deLayerProcessorThreads* threads; + deLayerStack& layerStack; + deViewManager* viewManager; + deLayerFrameManager& layerFrameManager; + mutable deMutex layerProcessMutex; + deMutex histogramMutex; + deMutex prepareImageMutex; + deMutex updateImageMutex; + deMutex updateImagesMutex; + deRenderer renderer; + deChannelManager& previewChannelManager; + deMainWindow& mainWindow; + + bool closing; + + deLayerProcessType layerProcessType; + int layerProcessChannel; + + int firstLayerToUpdate; + + int lastValidLayer; + + void updateImages(int a, int channel, bool action); + bool updateLayerImage(); + + void repaintImageInLayerProcessor(); + + deLayerProcessor(const deLayerProcessor&); + deLayerProcessor& operator = (const deLayerProcessor&); + + void checkUpdateImagesRequest(); + + int getLastLayerToUpdate(); + + void lockLayers() const; + void unlockLayers() const; + + void lockHistogram(); + void unlockHistogram(); + + void lockPrepareImage(); + void unlockPrepareImage(); + + void lockUpdateImage(); + void unlockUpdateImage(); + + void updateWarning(); + + public: + deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deMainWindow& _mainWindow); + virtual ~deLayerProcessor(); + + int getLastValidLayer() const; + + void setViewManager(deViewManager* _viewManager); + + void updateAllImages(bool calcHistogram); + bool updateImagesSmart(deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, const deSize& size, deGUI& gui); + + void markUpdateSingleChannel(int index, int channel); + void markUpdateAllChannels(int index); + + void markUpdateBlendAllChannels(int index); + + void onChangeView(int a); + + void lockLayerProcessor(); + void unlockLayerProcessor(); + + void startWorkerThread(); + + void tickWork(); + + void onDestroyAll(); + + void onChangeViewMode(); + + void onGUIUpdate(); + + void removeTopLayerInLayerProcessor(); + void addLayerInLayerProcessor(deBaseLayer* layer); + + void stopWorkerThread(); + + void sendRepaintEvent(); + + bool prepareImage(); + + void generateHistogram(); + void onGenerateHistogram(); + void sendHistogramEvent(); + + void setPreviewSize(const deSize& size, bool canSkip); + void onImageLoad(); + void forceUpdateSize(); + + bool isClosing() const {return closing;}; + + void render(deCanvas& canvas); + + void removeAllLayers(); + + void sendInfoEvent(int i); + + void setHistogramChannel(int channel); + +}; + +#endif diff -Nru delaboratory-0.7/core/layer_stack.cc delaboratory-0.8/core/layer_stack.cc --- delaboratory-0.7/core/layer_stack.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_stack.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,161 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_stack.h" +#include "base_layer.h" +#include "channel_manager.h" +#include "str.h" +#include "project.h" + +deLayerStack::deLayerStack() +{ +} + +deLayerStack::~deLayerStack() +{ + clear(); +} + +void deLayerStack::lock() const +{ +#ifdef DEBUG_LOG + logInfo("layer stack lock..."); +#endif + mutex.lock(); +#ifdef DEBUG_LOG + logInfo("layer stack locked"); +#endif +} + +void deLayerStack::unlock() const +{ +#ifdef DEBUG_LOG + logInfo("layer stack unlock"); +#endif + mutex.unlock(); +} + +void deLayerStack::clear() +{ + while (layers.size() > 0) + { + removeTopLayer(); + } +} + +void deLayerStack::removeTopLayer() +{ + lock(); + logInfo("layer stack remove top layer..."); + + int index = layers.size() - 1; + + mutexes[index]->lockWrite(); + + std::vector::iterator i; + i = layers.end(); + i--; + deBaseLayer* layer = *i; + + layers.erase(i); + +#ifdef DEBUG_LOG + logInfo("layer stack before delete layer"); +#endif + delete layer; +#ifdef DEBUG_LOG + logInfo("layer stack after delete layer"); +#endif + + mutexes[index]->unlockWrite(); + + unlock(); + +} + +void deLayerStack::addLayer(deBaseLayer* layer) +{ + lock(); + logInfo("layer stack add layer"); + + layers.push_back(layer); + mutexes.push_back(new deMutexReadWrite(4)); + + unlock(); +} + +int deLayerStack::getSize() const +{ + lock(); + + int n = layers.size(); + + unlock(); + + return n; +} + +deBaseLayer* deLayerStack::getLayer(int id) const +{ + lock(); + + unsigned int index = id; + deBaseLayer* layer = NULL; + + if ((index < layers.size()) && (id >= 0)) + { + layer = layers[index]; + } + + unlock(); + + return layer; +} + +const deBaseLayer* deLayerStack::startReadLayer(int id) const +{ +#ifdef DEBUG_LOG + logInfo("start read layer " + str(id)); +#endif + const deBaseLayer* layer = NULL; + lock(); + if ((id >= 0) && (id < layers.size())) + { + mutexes[id]->lockRead(); + layer = getLayer(id); + } + unlock(); +#ifdef DEBUG_LOG + logInfo("start read layer DONE"); +#endif + + return layer; +} + +void deLayerStack::finishReadLayer(int id) const +{ +#ifdef DEBUG_LOG + logInfo("finish read layer " + str(id)); +#endif + lock(); + if ((id >= 0) && (id < layers.size())) + { + mutexes[id]->unlockRead(); + } + unlock(); +} diff -Nru delaboratory-0.7/core/layer_stack.h delaboratory-0.8/core/layer_stack.h --- delaboratory-0.7/core/layer_stack.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_stack.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,62 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_STACK_H +#define _DE_LAYER_STACK_H + +#include +#include +#include "mutex.h" +#include "mutex_read_write.h" + +class deBaseLayer; +class deChannelManager; +class deMemoryInfoFrame; + +class deLayerStack +{ + private: + std::vector layers; + mutable deMutex mutex; + std::vector mutexes; + + deLayerStack(const deLayerStack& ); + deLayerStack& operator = (const deLayerStack& ); + + public: + deLayerStack(); + virtual ~deLayerStack(); + + void lock() const; + void unlock() const; + + void clear(); + void removeTopLayer(); + + void addLayer(deBaseLayer* layer); + + int getSize() const; + + deBaseLayer* getLayer(int id) const; + + const deBaseLayer* startReadLayer(int id) const; + void finishReadLayer(int id) const; + +}; + +#endif diff -Nru delaboratory-0.7/core/layer_with_blending.cc delaboratory-0.8/core/layer_with_blending.cc --- delaboratory-0.7/core/layer_with_blending.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_with_blending.cc 2012-07-26 00:36:01.000000000 +0000 @@ -0,0 +1,319 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_with_blending.h" +#include "channel_manager.h" +#include "blend_channel.h" +#include "color_space_utils.h" +#include +#include "str.h" +#include "property_numeric.h" +#include "property_boolean.h" +#include "logger.h" +#include "blend_color_luminosity.h" +#include "update_blend.h" + + +deLayerWithBlending::deLayerWithBlending(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) +:deSwitchableLayer(_colorSpace, _channelManager, _sourceLayerIndex, _layerStack), + imageBlendPass(_colorSpace, _channelManager) +{ + createPropertyNumeric("opacity", 0, 1); + createPropertyChoice("blend mode", getSupportedBlendModeNames(colorSpace)); + + dePropertyChoice* blendMode = getPropertyChoice("blend mode"); + if (blendMode) + { + blendMode->setSizer("blend"); + blendMode->setBlendOnly(); + } + + createPropertyBoolean("invert"); + getPropertyBoolean("invert")->setSizer("blend"); + + setBlendMode(deBlendNormal); + + deProperty* p = getPropertyNumeric("opacity"); + if (p) + { + p->setBlendOnly(); + } + + setOpacity(1.0); +} + +deLayerWithBlending::~deLayerWithBlending() +{ +} + +deValue deLayerWithBlending::getOpacity() const +{ + return getNumericValue("opacity"); +} + +void deLayerWithBlending::setOpacity(deValue _opacity) +{ + dePropertyNumeric* p = getPropertyNumeric("opacity"); + if (p) + { + p->set(_opacity); + } +} + +void deLayerWithBlending::setBlendMode(deBlendMode mode) +{ + dePropertyChoice* blendMode = getPropertyChoice("blend mode"); + if (blendMode) + { + blendMode->set(getBlendModeName(mode)); + } +} + +bool deLayerWithBlending::updateBlend(int i) +{ +#ifdef DEBUG_LOG + logInfo("update blend " + str(i) + " START"); +#endif + + const deValue* source = getSourceImage().startRead(i); + + const deValue* overlay = mainLayerImage.startRead(i); + + deValue* destination = imageBlendPass.startWrite(i); + + deValue* maskPixels = NULL; + + int channelSize = mainLayerImage.getChannelSize().getN(); + + deValue o = getOpacity(); + if (!isChannelEnabled(i)) + { + o = 0.0; + } + + dePropertyBoolean* pinv = getPropertyBoolean("invert"); + bool inverted = false; + if (pinv) + { + inverted = pinv->get(); + } + + if (inverted) + { + blendChannel(overlay, source, destination, maskPixels, getBlendMode(), o, channelSize); + } + else + { + blendChannel(source, overlay, destination, maskPixels, getBlendMode(), o, channelSize); + } + + getSourceImage().finishRead(i); + mainLayerImage.finishRead(i); + imageBlendPass.finishWrite(i); + +#ifdef DEBUG_LOG + logInfo("update blend " + str(i) + " DONE"); +#endif + + return true; + +} + +const deImage& deLayerWithBlending::getLayerImage() const +{ + return imageBlendPass; +} + +void deLayerWithBlending::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + getSourceImage().updateChannelUsage(channelUsage, layerIndex); + + mainLayerImage.updateChannelUsage(channelUsage, layerIndex); + + imageBlendPass.updateChannelUsage(channelUsage, layerIndex); +} + +bool deLayerWithBlending::updateBlendAllChannels() +{ + if (tryBlendSpecial()) + { + return true; + } + + updateBlendOnThread(*this); + + return true; + +} + +void deLayerWithBlending::processSingleChannel(int channel) +{ +#ifdef DEBUG_LOG + logInfo("layer with blending processs single channel " + str(channel)); +#endif + deBaseLayer::processSingleChannel(channel); + if (!tryBlendSpecial()) + { + updateBlend(channel); + } +#ifdef DEBUG_LOG + logInfo("layer with blending processs single channel DONE"); +#endif +} + +bool deLayerWithBlending::updateImage() +{ +#ifdef DEBUG_LOG + logInfo("layer with blending update image"); +#endif + + bool result = deBaseLayer::updateImage(); + + if (result) + { + result = updateBlendAllChannels(); + } + +#ifdef DEBUG_LOG + logInfo("layer with blending update image DONE"); +#endif + + return result; +} + +deBlendMode deLayerWithBlending::getBlendMode() const +{ + const dePropertyChoice* blendMode = getPropertyChoice("blend mode"); + std::string m = blendMode->get(); + deBlendMode mode = blendModeFromString(m); + return mode; +} + +void deLayerWithBlending::blendSpecial() +{ +#ifdef DEBUG_LOG + logInfo("blend special START"); +#endif + + deBlendMode mode = getBlendMode(); + int cs = getColorSpaceSize(colorSpace); + + const deValue* source0 = getSourceImage().startRead(0); + const deValue* source1 = getSourceImage().startRead(1); + const deValue* source2 = getSourceImage().startRead(2); + const deValue* source3 = NULL; + if (cs == 4) + { + source3 = getSourceImage().startRead(3); + } + + const deValue* overlay0 = mainLayerImage.startRead(0); + const deValue* overlay1 = mainLayerImage.startRead(1); + const deValue* overlay2 = mainLayerImage.startRead(2); + const deValue* overlay3 = NULL; + if (cs == 4) + { + overlay3 = mainLayerImage.startRead(3); + } + + deValue* destination0 = imageBlendPass.startWrite(0); + deValue* destination1 = imageBlendPass.startWrite(1); + deValue* destination2 = imageBlendPass.startWrite(2); + deValue* destination3 = NULL; + if (cs == 4) + { + destination3 = imageBlendPass.startWrite(3); + } + + int n = mainLayerImage.getChannelSize().getN(); + + deValue o = getOpacity(); + + if (mode == deBlendColor) + { + if (colorSpace == deColorSpaceRGB) + { + blendColorRGB(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); + } + if (colorSpace == deColorSpaceProPhoto) + { + blendColorProPhoto(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); + } + if (colorSpace == deColorSpaceCMYK) + { + blendColorCMYK(source0, source1, source2, source3, overlay0, overlay1, overlay2, overlay3, destination0, destination1, destination2, destination3, n, o); + } + } + + if (mode == deBlendLuminosity) + { + if (colorSpace == deColorSpaceRGB) + { + blendLuminosityRGB(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); + } + if (colorSpace == deColorSpaceProPhoto) + { + blendLuminosityProPhoto(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); + } + if (colorSpace == deColorSpaceCMYK) + { + blendLuminosityCMYK(source0, source1, source2, source3, overlay0, overlay1, overlay2, overlay3, destination0, destination1, destination2, destination3, n, o); + } + } + + getSourceImage().finishRead(0); + getSourceImage().finishRead(1); + getSourceImage().finishRead(2); + mainLayerImage.finishRead(0); + mainLayerImage.finishRead(1); + mainLayerImage.finishRead(2); + imageBlendPass.finishWrite(0); + imageBlendPass.finishWrite(1); + imageBlendPass.finishWrite(2); + if (cs == 4) + { + getSourceImage().finishRead(3); + mainLayerImage.finishRead(3); + imageBlendPass.finishWrite(3); + } +#ifdef DEBUG_LOG + logInfo("blend special DONE"); +#endif +} + +bool deLayerWithBlending::tryBlendSpecial() +{ + deBlendMode mode = getBlendMode(); + if (mode == deBlendColor) + { + blendSpecial(); + return true; + } + if (mode == deBlendLuminosity) + { + blendSpecial(); + return true; + } + return false; +} + +void deLayerWithBlending::allocateChannels() +{ + deBaseLayer::allocateChannels(); + imageBlendPass.allocateChannels(); +} diff -Nru delaboratory-0.7/core/layer_with_blending.h delaboratory-0.8/core/layer_with_blending.h --- delaboratory-0.7/core/layer_with_blending.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/layer_with_blending.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,61 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_WITH_BLENDING_H +#define _DE_LAYER_WITH_BLENDING_H + +#include "switchable_layer.h" +#include "blend_mode.h" +#include "property_choice.h" + +class deLayerWithBlending:public deSwitchableLayer +{ + private: + deImage imageBlendPass; + + virtual const deImage& getLayerImage() const; + virtual bool updateBlendAllChannels(); + + bool tryBlendSpecial(); + void blendSpecial(); + + protected: + virtual void processSingleChannel(int channel); + virtual bool updateImage(); + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + public: + deLayerWithBlending(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deLayerWithBlending(); + + deBlendMode getBlendMode() const; + deValue getOpacity() const; + + void setBlendMode(deBlendMode mode); + void setOpacity(deValue _opacity); + + bool updateBlend(int i); + + virtual void allocateChannels(); + + + +}; + +#endif diff -Nru delaboratory-0.7/core/operation_processor.cc delaboratory-0.8/core/operation_processor.cc --- delaboratory-0.7/core/operation_processor.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/operation_processor.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,277 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "operation_processor.h" +#include "layer_processor.h" +#include "logger.h" +#include "project.h" +#include "layer_stack.h" +#include "base_layer_with_properties.h" +#include "color_space_utils.h" + +deOperationProcessor::deOperationProcessor(deLayerProcessor& _layerProcessor, deProject& _project) +:layerProcessor(_layerProcessor), project(_project) +{ +} + +deOperationProcessor::~deOperationProcessor() +{ +} + +void deOperationProcessor::addNewLayerOnTop(deBaseLayer* layer) +{ + logInfo("before add new layer on top"); + layerProcessor.addLayerInLayerProcessor(layer); + logInfo("after add new layer on top"); +} + +void deOperationProcessor::removeTopLayer() +{ + logInfo("before remove top layer"); + layerProcessor.removeTopLayerInLayerProcessor(); + logInfo("after remove top layer"); +} + +void deOperationProcessor::execute(const std::string& operation) +{ + if (operation == "remove") + { + removeTopLayer(); + project.onRemoveTopLayer(); + return; + } + + bool ok = false; + if (tryExecuteBasicOperation(operation)) + { + ok = true; + } + else + { + deBaseLayer* layer = project.createNewLayer(operation); + + if (layer) + { + addNewLayerOnTop(layer); + ok = true; + } + } + + if (ok) + { + project.onAddNewLayer(); + } +} + +void deOperationProcessor::initProfile(const std::string& profile) +{ + if (profile == "cmyk_auto_levels") + { + execute("CMYK"); + execute("levels"); + } + if (profile == "bw") + { + execute("BW"); + } + if (profile == "c2g") + { + execute("c2g"); + } + if (profile == "vignette") + { + execute("LAB"); + execute("vignette"); + } +} + + +bool deOperationProcessor::executeOperation(deColorSpace colorSpace, const std::string& operation) +{ + deViewManager& viewManager = project.getViewManager(); + + viewManager.setLastView(); + + deColorSpace currentColorSpace = viewManager.getColorSpace(); + + if (colorSpace != currentColorSpace) + { + deBaseLayer* layer1 = project.createNewLayer(getColorSpaceName(colorSpace)); + + if (layer1) + { + addNewLayerOnTop(layer1); + viewManager.setLastView(); + } + else + { + return false; + } + } + + deBaseLayer* layer2 = project.createNewLayer(operation); + + if (layer2) + { + addNewLayerOnTop(layer2); + viewManager.setLastView(); + } + else + { + return false; + } + + project.openLayerFrame(project.getLayerStack().getSize() - 1); + + return true; +} + +bool deOperationProcessor::tryExecuteBasicOperation(const std::string& operation) +{ + if (operation == "CMYK curves") + { + return executeOperation(deColorSpaceCMYK, "curves"); + } + + if (operation == "CMYK levels") + { + return executeOperation(deColorSpaceCMYK, "levels"); + } + + if (operation == "LAB vignette") + { + return executeOperation(deColorSpaceLAB, "vignette"); + } + + if (operation == "LAB local contrast") + { + return executeOperation(deColorSpaceLAB, "local_contrast"); + } + + if (operation == "BW local contrast") + { + return executeOperation(deColorSpaceBW, "local_contrast"); + } + + if (operation == "RGB curves") + { + return executeOperation(deColorSpaceRGB, "curves"); + } + + if (operation == "RGB levels") + { + return executeOperation(deColorSpaceRGB, "levels"); + } + + if (operation == "LAB curves") + { + return executeOperation(deColorSpaceLAB, "curves"); + } + + if (operation == "BW curve") + { + return executeOperation(deColorSpaceBW, "curves"); + } + + if (operation == "BW vignette") + { + return executeOperation(deColorSpaceBW, "vignette"); + } + + if (operation == "RGB tone") + { + return executeOperation(deColorSpaceRGB, "tone"); + } + + if (operation == "RGB shadows") + { + return executeOperation(deColorSpaceRGB, "recover_shadows"); + } + + if (operation == "RGB highlights") + { + return executeOperation(deColorSpaceRGB, "recover_highlights"); + } + + if (operation == "BW gradient") + { + return executeOperation(deColorSpaceBW, "gradient"); + } + if (operation == "RGB gradient") + { + return executeOperation(deColorSpaceRGB, "gradient"); + } + if (operation == "CMYK gradient") + { + return executeOperation(deColorSpaceCMYK, "gradient"); + } + if (operation == "LAB gradient") + { + return executeOperation(deColorSpaceLAB, "gradient"); + } + + if (operation == "LAB wb") + { + return executeOperation(deColorSpaceLAB, "white_balance"); + } + + if (operation == "LAB saturation") + { + return executeOperation(deColorSpaceLAB, "saturation"); + } + + if (operation == "HSV equalizer") + { + return executeOperation(deColorSpaceHSV, "equalizer"); + } + + if (operation == "LCH equalizer") + { + return executeOperation(deColorSpaceLCH, "equalizer"); + } + + return false; +} + +void getSupportedColorsOperations(std::vector& actions) +{ + actions.push_back("CMYK curves"); + actions.push_back("CMYK levels"); + actions.push_back("RGB curves"); + actions.push_back("RGB levels"); + actions.push_back("LAB wb"); + actions.push_back("LAB saturation"); + actions.push_back("LAB curves"); + actions.push_back("BW curve"); + actions.push_back("HSV equalizer"); + actions.push_back("LCH equalizer"); +} + +void getSupportedOtherOperations(std::vector& actions) +{ + actions.push_back("RGB shadows"); + actions.push_back("RGB highlights"); + actions.push_back("LAB vignette"); + actions.push_back("LAB local contrast"); + actions.push_back("BW vignette"); + actions.push_back("BW local contrast"); + actions.push_back("LAB gradient"); + actions.push_back("BW gradient"); + actions.push_back("RGB gradient"); + actions.push_back("CMYK gradient"); +} diff -Nru delaboratory-0.7/core/operation_processor.h delaboratory-0.8/core/operation_processor.h --- delaboratory-0.7/core/operation_processor.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/operation_processor.h 2012-07-09 17:34:43.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_OPERATION_PROCESSOR_H +#define _DE_OPERATION_PROCESSOR_H + +class deLayerProcessor; +class deBaseLayer; +class deProject; +#include +#include +#include "color_space.h" + +class deOperationProcessor +{ + private: + deLayerProcessor& layerProcessor; + deProject& project; + + void removeTopLayer(); + void addNewLayerOnTop(deBaseLayer* layer); + + bool tryExecuteBasicOperation(const std::string& operation); + bool executeOperation(deColorSpace colorSpace, const std::string& operation); + + public: + deOperationProcessor(deLayerProcessor& _layerProcessor, deProject& _project); + virtual ~deOperationProcessor(); + + void execute(const std::string& operation); + + void initProfile(const std::string& profile); + +}; + +void getSupportedColorsOperations(std::vector& actions); +void getSupportedOtherOperations(std::vector& actions); + +#endif diff -Nru delaboratory-0.7/core/palette.cc delaboratory-0.8/core/palette.cc --- delaboratory-0.7/core/palette.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/palette.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,189 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "palette.h" + +dePalette3::dePalette3(deColorSpace _colorSpace) +:colorSpace(_colorSpace) +{ +} + +dePalette3::~dePalette3() +{ +} + +void dePalette3::addColor(const deColor4& color) +{ + colors.push_back(color); +} + +void dePalette3::optimize(const dePalette3& source, int n, deValue margin) +{ + int ss = source.colors.size(); + + deValue** distances = new deValue * [ss]; + + int i; + int j; + for (i = 0; i < ss; i++) + { + distances[i] = new deValue [ss]; + for (j = 0; j < ss; j++) + { + deValue d = 0; + if (i != j) + { + d = source.colors[i].calcDistance(source.colors[j]); + } + distances[i][j] = d; + } + + } + + bool no_more = false; + + while ((colors.size() < (unsigned int)n) && (!no_more)) + { + int winner = -1; + int max = 0; + + for (i = 0; i < ss; i++) + { + int counter = 0; + for (j = 0; j < ss; j++) + { + deValue d = distances[i][j]; + if (d != 0) + { + if ( d < margin ) + { + counter++; + } + } + } + if (counter > max) + { + winner = i; + max = counter; + } + } + + if (winner >= 0) + { + colors.push_back(source.colors[winner]); + for (i = 0; i < ss; i++) + { + deValue d = distances[winner][i]; + if (d != 0) + { + if ( d < margin ) + { + for (j = 0; j < ss; j++) + { + distances[i][j] = 0; + distances[j][i] = 0; + } + } + } + } + } + else + { + no_more = true; + } + } + + for (i = 0; i < ss; i++) + { + delete [] distances[i]; + } + delete [] distances; +} + +deColor4 dePalette3::getColor(int index) +{ + return colors[index]; +} + +void dePalette3::getMinMax(int index, deValue& min, deValue& max) +{ + int n = colors.size(); + int i; + min = -1; + max = -1; + for (i = 0; i < n; i++) + { + deColor4& color = colors[i]; + deValue v; + switch (index) + { + case 1: + v = color.getV1(); + break; + case 2: + v = color.getV2(); + break; + case 3: + v = color.getV3(); + break; + default: + break; + } + if (min < 0) + { + min = v; + max = v; + } + else + { + if (v < min) + { + min = v; + } + if (v > max) + { + max = v; + } + } + } +} + +bool dePalette3::find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& resultL) +{ + int n = colors.size(); + int i; + + deValue sum = 0.0; + int found = 0; + + for (i = 0; i < n; i++) + { + deColor4& color = colors[i]; + deValue L = color.getV1(); + deValue A = color.getV2(); + deValue B = color.getV3(); + if ((A >= minA) && (A < maxA) && (B >= minB) && (B < maxB)) + { + sum += L; + found++; + } + } + + resultL = sum / found; + return (found > 0); +} diff -Nru delaboratory-0.7/core/palette.h delaboratory-0.8/core/palette.h --- delaboratory-0.7/core/palette.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/palette.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,85 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PALETTE_H +#define _DE_PALETTE_H + +#include +#include "value.h" +#include "color_space.h" +#include + +class deColor4 +{ + private: + deValue v1; + deValue v2; + deValue v3; + deValue v4; + public: + deColor4(deValue _v1, deValue _v2, deValue _v3, deValue _v4) + :v1(_v1), + v2(_v2), + v3(_v3), + v4(_v4) + { + }; + virtual ~deColor4() + { + }; + + deValue getV1() {return v1;}; + deValue getV2() {return v2;}; + deValue getV3() {return v3;}; + deValue getV4() {return v4;}; + + deValue calcDistance(const deColor4& c) const + { + deValue d1 = c.v1 - v1; + deValue d2 = c.v2 - v2; + deValue d3 = c.v3 - v3; + deValue d4 = c.v4 - v4; + deValue d = d1 * d1 + d2 * d2 + d3 * d3 + d4 * d4; + return sqrt(d); + }; +}; + +class dePalette3 +{ + private: + deColorSpace colorSpace; + std::vector colors; + + public: + dePalette3(deColorSpace _colorSpace); + virtual ~dePalette3(); + + void addColor(const deColor4& color); + + void optimize(const dePalette3& source, int n, deValue margin); + + deColor4 getColor(int index); + + int getSize() const {return colors.size();}; + + void getMinMax(int index, deValue& min, deValue& max); + bool find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& L); + +}; + +#endif diff -Nru delaboratory-0.7/core/power.cc delaboratory-0.8/core/power.cc --- delaboratory-0.7/core/power.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/power.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,50 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "power.h" +#include +#include "logger.h" +#include "str.h" + +dePower::dePower(double _power, int s) +{ + power = _power; + + scale = (POWER_CACHE_SIZE - 1.0) / s; + + int i; + for (i = 0; i < POWER_CACHE_SIZE; i++) + { + double p = i / scale; + values[i] = pow(p, power); + } + +} + +dePower::~dePower() +{ +} + +double dePower::get(double v) +{ + int i = v * scale; + if ((i >= 0) && (i < POWER_CACHE_SIZE)) + return values[i]; + return pow(v, power); +} + diff -Nru delaboratory-0.7/core/power.h delaboratory-0.8/core/power.h --- delaboratory-0.7/core/power.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/power.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_POWER_H +#define _DE_POWER_H + +#define POWER_CACHE_SIZE 65536 + +class dePower +{ + private: + double power; + double values[POWER_CACHE_SIZE]; + double scale; + + public: + dePower(double _power, int s); + ~dePower(); + + double get(double v); +}; + +#endif diff -Nru delaboratory-0.7/core/preset_button.cc delaboratory-0.8/core/preset_button.cc --- delaboratory-0.7/core/preset_button.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/preset_button.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "preset_button.h" +#include "layer_processor.h" +#include "layer_frame.h" +#include "base_layer_with_properties.h" + +dePresetButton::dePresetButton(deWindow& window, deBaseLayerWithProperties& _layer, const std::string& name, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _frame) +:deButton(window, name), preset(name), layerProcessor(_layerProcessor), layer(_layer), layerIndex(_layerIndex), frame(_frame) +{ +} + +dePresetButton::~dePresetButton() +{ +} + +void dePresetButton::onClick() +{ + layer.applyPreset(preset); + frame.setUIFromLayer(); + layerProcessor.markUpdateAllChannels(layerIndex); +} diff -Nru delaboratory-0.7/core/preset_button.h delaboratory-0.8/core/preset_button.h --- delaboratory-0.7/core/preset_button.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/preset_button.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,45 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PRESET_BUTTON_H +#define _DE_PRESET_BUTTON_H + +class deLayerProcessor; +class deWindow; +class deBaseLayerWithProperties; +class deLayerFrame; +#include "button.h" + +class dePresetButton:public deButton +{ + private: + const std::string preset; + deLayerProcessor& layerProcessor; + deBaseLayerWithProperties& layer; + int layerIndex; + deLayerFrame& frame; + + + public: + dePresetButton(deWindow& window, deBaseLayerWithProperties& _layer, const std::string& name, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _frame); + virtual ~dePresetButton(); + + virtual void onClick(); +}; + +#endif diff -Nru delaboratory-0.7/core/preset.cc delaboratory-0.8/core/preset.cc --- delaboratory-0.7/core/preset.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/preset.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "preset.h" +#include "property_numeric.h" + +void dePreset::apply(deBaseLayerWithProperties& layer) const +{ + std::map::const_iterator i; + for (i = numericValues.begin(); i != numericValues.end(); i++) + { + dePropertyNumeric* p = layer.getPropertyNumeric(i->first); + if (p) + { + p->set(i->second); + } + } + + std::vector::const_iterator j; + for (j = operations.begin(); j != operations.end(); j++) + { + layer.executeOperation(*j); + } +} + +void dePreset::addNumericValue(const std::string& n, deValue v) +{ + numericValues[n] = v; +} + +void dePreset::addOperation(const std::string& n) +{ + operations.push_back(n); +} diff -Nru delaboratory-0.7/core/preset.h delaboratory-0.8/core/preset.h --- delaboratory-0.7/core/preset.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/preset.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,57 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PRESET_H +#define _DE_PRESET_H + +#include +#include "value.h" +#include "base_layer_with_properties.h" + +class dePreset +{ + private: + dePreset(const dePreset&); + dePreset& operator =(const dePreset&); + + std::map numericValues; + std::vector operations; + + protected: + const std::string name; + + public: + dePreset(const std::string& _name) + :name(_name) + { + } + + virtual ~dePreset() + { + } + + std::string getName() {return name;}; + + void apply(deBaseLayerWithProperties& layer) const; + void addNumericValue(const std::string& n, deValue v); + void addOperation(const std::string& n); + +}; + + +#endif diff -Nru delaboratory-0.7/core/project.cc delaboratory-0.8/core/project.cc --- delaboratory-0.7/core/project.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/project.cc 2012-07-28 01:55:24.000000000 +0000 @@ -0,0 +1,563 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "project.h" +#include "message_box.h" +#include "image_io.h" +#include +#include +#include "source_image_layer.h" +#include "curves_layer.h" +#include "conversion_layer.h" +#include "str.h" +#include +#include "layer_factory.h" +#include +#include "layer_processor.h" +#include "external_editor.h" +#include "channel_manager.h" +#include "layer_stack.h" +#include "layer_frame_manager.h" +#include "static_image.h" +#include "zoom_manager.h" +#include "color_space_utils.h" +#include "operation_processor.h" +#include "main_window.h" +#include "conversion_processor.h" +#include "test_image.h" +#include "main_frame_events.h" + +#include "raw_module.h" +#include "dcraw_support.h" +#include "tmp.h" + +deProject::deProject(deLayerProcessor& _processor, deChannelManager& _channelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager, deMainWindow& _mainWindow, deGUI& _gui) +:layerProcessor(_processor), + channelManager(_channelManager), + viewManager(*this, _processor, _zoomManager), + sourceImage(_sourceImage), + layerStack(_layerStack), + layerFrameManager(_layerFrameManager), + rawModule(_rawModule), + zoomManager(_zoomManager), + mainWindow(_mainWindow), + gui(_gui) +{ + imageFileName = ""; + sourceImageFileName = ""; + + logInfo("project constructor"); + + layerProcessor.setViewManager(&viewManager); + + resetLayerStack(deColorSpaceRGB); +} + +deProject::~deProject() +{ + logInfo("project destructor"); + layerProcessor.lockLayerProcessor(); + layerProcessor.unlockLayerProcessor(); + layerStack.clear(); +} + +void deProject::setHistogramChannel(int channel) +{ + logInfo("project set histogram channel " + str(channel)); + gui.updateHistogramMode(channel); + layerProcessor.generateHistogram(); +} + +void deProject::onKey(int key) +{ + if (key == '`') + { + viewManager.setNormal(); + } + if (key == '1') + { + viewManager.setSingleChannel(0); + } + if (key == '2') + { + viewManager.setSingleChannel(1); + } + if (key == '3') + { + viewManager.setSingleChannel(2); + } + if (key == '4') + { + viewManager.setSingleChannel(3); + } + /* + if (key == WXK_F1) + { + setHistogramChannel(0); + } + if (key == WXK_F2) + { + setHistogramChannel(1); + } + if (key == WXK_F3) + { + setHistogramChannel(2); + } + if (key == WXK_F4) + { + setHistogramChannel(3); + } + */ + + layerFrameManager.onKey(key); +} + +void deProject::init(const std::string& fileName) +{ + bool ok = false; + if (openImage(fileName, true, false, false)) + { + ok = true; + } else if (openImage(fileName, false, false, false)) + { + ok = true; + } + if (!ok) + { + std::string s = "unable to open image: " + fileName; + logError(s); + showMessageBox(s); + return; + } +} + +void deProject::freeImage() +{ +} + +void deProject::setTestImage(int s) +{ + if (rawModule.isActive()) + { + showMessageBox("RAW module is already active"); + return; + } + + generateTestImage(sourceImage, s); + gui.updateImageAreaSize(); + resetLayerStack(sourceImage.getColorSpace()); + imageFileName = "test"; + +} + +void deProject::resetLayerStack(deColorSpace colorSpace) +{ + logInfo("reset layer stack"); + + layerProcessor.removeAllLayers(); + + deBaseLayer* layer = createLayer("original", -1, colorSpace, layerStack, channelManager, viewManager, sourceImage); + + if (layer) + { + layer->allocateChannels(); + layerProcessor.addLayerInLayerProcessor(layer); + } + + layerProcessor.updateAllImages(true); + + updateLayerGrid(); + + viewManager.setLastView(); + +} + +deChannelManager& deProject::getPreviewChannelManager() +{ + return channelManager; +} + +deSize deProject::getSourceImageSize() +{ + deSize size = sourceImage.getStaticImageSize(); + + deValue x1; + deValue y1; + deValue x2; + deValue y2; + + zoomManager.getZoom(x1, y1, x2, y2); + + deValue w = size.getW() * (x2 - x1); + deValue h = size.getH() * (y2 - y1); + + return deSize(w, h); +} + +deValue deProject::getSourceAspect() const +{ + const deBaseLayer* layer = layerStack.startReadLayer(0); + deValue aspect = -1; + + const deSourceImageLayer* source = dynamic_cast(layer); + if (source) + { + deValue x1; + deValue y1; + deValue x2; + deValue y2; + + zoomManager.getZoom(x1, y1, x2, y2); + + deValue dx = x2 - x1; + deValue dy = y2 - y1; + if ((dx > 0) && (dy > 0)) + { + deValue a = dy / dx; + + aspect = source->getAspect() / a; + } + } + + layerStack.finishReadLayer(0); + return aspect; +} + +deLayerStack& deProject::getLayerStack() +{ + return layerStack; +} + +deLayerProcessor& deProject::getLayerProcessor() +{ + return layerProcessor; +} + +void deProject::onChangeView(int a) +{ + logInfo("change view from " + str(a) + " START"); + layerProcessor.onChangeView(a); + + gui.updateViewModePanelNames(); + gui.updateHistogramNames(); + mainWindow.rebuild(); + logInfo("change view from " + str(a) + " DONE"); +} + +const deViewManager& deProject::getViewManager() const +{ + return viewManager; +} + +deViewManager& deProject::getViewManager() +{ + return viewManager; +} + +bool deProject::exportFinalImage(const std::string& app, const std::string& type, const std::string& name, deProgressDialog& progressDialog, bool saveAll, const std::string& dir) +{ + // FIXME without dynamic channel allocation all channels are allocated from start - so it will crash with out of memory + + logInfo("exportFinalImage..."); + + zoomManager.fullZoomOut(); + + // name is taken from file dialog, it can be empty when we are exporting to external editor + // but in this case we need correct imageFileName + if ((name == "") && (imageFileName == "")) + { + showMessageBox( "exporting final image failed - no file name set"); + return false; + } + + std::string fileName; + + if (name == "") + { + // path is a directory for temporary save, used only when exporting to external editor + std::string path = getTmp(); + + if (dir.size() > 0) + { + // now used also when exporting all images into one dir + path = dir; + } + + // we save file in the temporary directory + fileName = path + "/" + imageFileName + "." + type; + } + else + { + // wa save file in the location taken from file dialog + fileName = name; + } + + bool result = processFullSizeImage(fileName, type, saveAll, progressDialog); + + if (!result) + { + showMessageBox( "exporting final image failed - error during update images\n(probably out of memory)"); + } + + if (result) + { + // execute external editor + if (app.size() > 0) + { + executeExternalEditor(fileName, app); + } + } + + // calculate image in preview size to continue editing + layerProcessor.updateAllImages(true); + + gui.updateImageAreaSize(); + + return result; +} + +bool deProject::processFullSizeImage(const std::string& fileName, const std::string& type, bool saveAll, deProgressDialog& progressDialog) +{ + logInfo("processFullSizeImage..."); + + bool result = layerProcessor.updateImagesSmart(progressDialog, fileName, type, saveAll, sourceImage.getStaticImageSize(), gui); + + return result; +} + + +void deProject::onChangeViewMode() +{ + gui.updateViewModePanelMode(); +} + +void deProject::newProject() +{ + resetLayerStack(deColorSpaceRGB); + viewManager.setLastView(); + updateLayerGrid(); +} + +bool deProject::openImageRAW(const std::string& fileName, bool srgb, bool brighten) +{ + + bool valid = isRawValid(fileName); + if (!valid) + { + logError("not a valid RAW " + fileName); + return false; + } + +/* + std::string info; + info = getRawInfo(fileName); + + if (info.size() == 0) + { + logError("empty RAW info in " + fileName); + return false; + } + */ + + layerProcessor.sendInfoEvent(DE_DCRAW_START); + if (rawModule.loadRAW(fileName, sourceImage, true, srgb, brighten)) + { + logInfo("found RAW " + fileName); + bool failure = false; + while (!rawModule.updateRawLoading(failure)) + { + sleep(200); + if (failure) + { + logError("failed RAW load " + fileName); + layerProcessor.sendInfoEvent(DE_DCRAW_END); + return false; + } + } + bool result = rawModule.loadRAW(fileName, sourceImage, false, srgb, brighten); + if (!result) + { + return false; + } + + mainWindow.startRawTimer(); + + } + else + { + logError("failed RAW " + fileName); + layerProcessor.sendInfoEvent(DE_DCRAW_END); + return false; + } + + return true; +} + +bool deProject::openImage(const std::string& fileName, bool raw, bool srgb, bool brighten) +{ + freeImage(); + + logInfo("open image " + fileName); + + deColorSpace oldColorSpace = sourceImage.getColorSpace(); + + if (raw) + { + if (!openImageRAW(fileName, srgb, brighten)) + { + return false; + } + } + else + { + logInfo("trying JPEG/TIFF image " + fileName); + if (!loadImage(fileName, sourceImage)) + { + logError("load JPEG/TIFF image failed: " + fileName); + return false; + } + } + + + imageFileName = removePathAndExtension(fileName); + onImageNameUpdate(); + sourceImageFileName = fileName; + + gui.updateImageAreaSize(); + layerProcessor.updateAllImages(true); + + deColorSpace newColorSpace = sourceImage.getColorSpace(); + + if (oldColorSpace != newColorSpace) + { + resetLayerStack(newColorSpace); + onChangeView(0); + } + + return true; +} + +bool deProject::isSourceValid() const +{ + return (!channelManager.isImageEmpty()); +} + +deBaseLayer* deProject::createNewLayer(const std::string& type) +{ + logInfo("createNewLayer " + type); + + int s = viewManager.getView(); + + deBaseLayer* layer = NULL; + + const deBaseLayer* vLayer = layerStack.startReadLayer(s); + if (vLayer) + { + deColorSpace colorSpace = vLayer->getColorSpace(); + + layer = createLayer(type, s, colorSpace, layerStack, channelManager, viewManager, sourceImage); + } + layerStack.finishReadLayer(s); + + if (!layer) + { + deColorSpace colorSpace = colorSpaceFromString(type); + + if (colorSpace != deColorSpaceInvalid) + { + layer = createLayer("conversion", s, colorSpace, layerStack, channelManager, viewManager, sourceImage); + } + } + + if (layer) + { + logInfo("allocate channels in new layer " + type); + layer->allocateChannels(); + } + + return layer; +} + +void deProject::onImageNameUpdate() +{ + mainWindow.setImageName(imageFileName, sourceImage.getStaticImageSize()); +} + +void deProject::onTimerUpdate() +{ + bool failure = false; + + bool result = rawModule.updateRawLoading(failure); + + if ((result) || (failure)) + { + layerProcessor.sendInfoEvent(DE_DCRAW_END); + mainWindow.stopRawTimer(); + } + + if (result) + { + mainWindow.postEvent(DE_IMAGE_LOAD_EVENT, 0); + } + +} + +void deProject::updateLayerGrid() +{ + gui.updateLayerGrid(); +} + +void deProject::onAddNewLayer() +{ + viewManager.setLastView(); + updateLayerGrid(); +} + +void deProject::onRemoveTopLayer() +{ + viewManager.setLastView(); + updateLayerGrid(); +} + +deSize deProject::onImageAreaChangeSize(const deSize& ps, bool canSkip) +{ + deValue aspect = getSourceAspect(); + + if (aspect <= 0) + { + logInfo("image area panel update size skipped, aspect is 0"); + return deSize(0,0); + } + + deSize fit = fitInside(ps, aspect); + + layerProcessor.setPreviewSize(fit, canSkip); + + return fit; +} + + +void deProject::openLayerFrame(int index) +{ + deBaseLayer* layer = layerStack.getLayer(index); + if (layer) + { + gui.openLayerFrame(*layer, layerProcessor, layerFrameManager, index); + } + +} diff -Nru delaboratory-0.7/core/project.h delaboratory-0.8/core/project.h --- delaboratory-0.7/core/project.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/project.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,120 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROJECT_H +#define _DE_PROJECT_H + +#include "sampler_manager.h" +#include "view_manager.h" +#include "logger.h" +#include "image.h" +#include "size.h" +#include "gui.h" + +class deImagePanel; +class deHistogramPanel; +class deMainWindow; +class deLayerProcessor; +class deLayerStack; +class deLayerFrameManager; +class deLayer; +class deStaticImage; +class deRawModule; +class deZoomManager; +class deBaseLayer; +class deProgressDialog; + +class deProject +{ + private: + deProject(const deProject& project); + deProject& operator =(const deProject& project); + + deLayerProcessor& layerProcessor; + std::string imageFileName; + std::string sourceImageFileName; + deChannelManager& channelManager; + deViewManager viewManager; + deStaticImage& sourceImage; + deLayerStack& layerStack; + deLayerFrameManager& layerFrameManager; + deRawModule& rawModule; + deZoomManager& zoomManager; + deMainWindow& mainWindow; + deGUI& gui; + + void onImageNameUpdate(); + + bool processFullSizeImage(const std::string& fileName, const std::string& type, bool saveAll, deProgressDialog& progressDialog); + + void freeImage(); + + void onScaleSet(); + + void updateLayerGrid(); + + bool openImageRAW(const std::string& fileName, bool srgb, bool brighten); + + public: + deProject(deLayerProcessor& _processor, deChannelManager& _channelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager, deMainWindow& _mainWindow, deGUI& _gui); + + virtual ~deProject(); + void onKey(int key); + void init(const std::string& fileName); + void resetLayerStack(deColorSpace colorSpace); + + deChannelManager& getPreviewChannelManager(); + deSize getSourceImageSize(); + deLayerStack& getLayerStack(); + deLayerProcessor& getLayerProcessor(); + + bool isSourceValid() const; + + const deViewManager& getViewManager() const; + deViewManager& getViewManager(); + + void onChangeView(int a); + + bool exportFinalImage(const std::string& app, const std::string& type, const std::string& name, deProgressDialog& progressDialog, bool saveAll, const std::string& dir); + + void onChangeViewMode(); + + bool openImage(const std::string& fileName, bool raw, bool srgb, bool brighten); + void newProject(); + void setTestImage(int s); + + + void setHistogramChannel(int channel); + + void onTimerUpdate(); + + deBaseLayer* createNewLayer(const std::string& type); + + void onAddNewLayer(); + void onRemoveTopLayer(); + + deLayerFrameManager& getLayerFrameManager() {return layerFrameManager;}; + deValue getSourceAspect() const; + + deSize onImageAreaChangeSize(const deSize& ps, bool canSkip); + + void openLayerFrame(int index); + +}; + +#endif diff -Nru delaboratory-0.7/core/property.cc delaboratory-0.8/core/property.cc --- delaboratory-0.7/core/property.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/property.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,69 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property.h" + +deProperty::deProperty(const std::string& _name) +:name(_name) +{ + label = ""; + blendOnly = false; + size = false; + others = false; +} + +deProperty::~deProperty() +{ +} + +std::string deProperty::getName() const +{ + return name; +} + +std::string deProperty::getLabel() const +{ + if (label == "") + { + return name; + } + else + { + return label; + } +} + +void deProperty::setLabel(const std::string& _label) +{ + label = _label; +} + +void deProperty::setBlendOnly() +{ + blendOnly = true; +} + +void deProperty::setSize() +{ + size = true; +} + +void deProperty::setOthers() +{ + others = true; +} diff -Nru delaboratory-0.7/core/property.h delaboratory-0.8/core/property.h --- delaboratory-0.7/core/property.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/property.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,58 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_H +#define _DE_PROPERTY_H + +#include + +class deProperty +{ + private: + std::string sizer; + std::string label; + bool blendOnly; + bool size; + bool others; + + protected: + std::string name; + + public: + deProperty(const std::string& _name); + virtual ~deProperty(); + + std::string getLabel() const; + void setLabel(const std::string& _label); + + std::string getName() const; + + virtual bool updateBlendOnly() const {return blendOnly;}; + void setBlendOnly(); + + void setSizer(const std::string& _sizer) {sizer = _sizer;}; + std::string getSizer() const {return sizer;}; + + bool affectSize() const {return size;}; + void setSize(); + + bool affectOthers() const {return others;}; + void setOthers(); +}; + +#endif diff -Nru delaboratory-0.7/core/renderer.cc delaboratory-0.8/core/renderer.cc --- delaboratory-0.7/core/renderer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/renderer.cc 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,168 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "renderer.h" +#include "project.h" +#include "image.h" +#include "base_layer.h" +#include +#include "layer_processor.h" +#include "str.h" +#include "logger.h" +#include "channel_manager.h" +#include "layer_stack.h" +#include "conversion_processor.h" +#include "canvas.h" + +void renderChannel(const deImage& image, int c, unsigned char* data, deChannelManager& channelManager, bool reversed) +{ + const deSize& s = image.getChannelSize(); + + const deValue* pixels = image.startRead(c); + + if (!pixels) + { + logError("can't render channel - NULL pixels"); + return; + } + + int n = s.getN(); + int i; + int pos = 0; + for (i = 0; i < n; i++) + { + deValue s = pixels[i]; + + if (reversed) + { + s = 1.0 - s; + } + + unsigned char ss = 255 * s; + + data[pos] = ss; + pos++; + data[pos] = ss; + pos++; + data[pos] = ss; + pos++; + } + + image.finishRead(c); + +} + +deRenderer::deRenderer(deChannelManager& _channelManager) +:size(0,0), + channelManager(_channelManager) +{ +} + +deRenderer::~deRenderer() +{ +} + +bool deRenderer::prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack) +{ + if (channelManager.isImageEmpty()) + { + logError("image is empty"); + return false; + } + + mutex.lock(); + + int viewV = viewManager.getView(); + int view = layerProcessor.getLastValidLayer(); + if (view > viewV) + { + view = viewV; + } + + if (view < 0) + { + logError("view < 0"); + mutex.unlock(); + return false; + } + + const deBaseLayer* layer = layerStack.startReadLayer(view); + + if (layer) + { + const deImage& layerImage = layer->getLayerImage(); + + if (viewManager.isSingleChannel()) + { + bool reversed = false; + deColorSpace colorSpace = layerImage.getColorSpace(); + if (colorSpace == deColorSpaceCMYK) + { + reversed = true; + } + renderChannel(layerImage, viewManager.getChannel(), getCurrentImageData(), channelManager, reversed); + renderedImage.clearError(); + } + else + { + deConversionProcessor p; + if (!p.renderImageToRGBNew(layerImage, getCurrentImageData())) + { + logError("render image FAILED"); + renderedImage.setError(); + } + else + { + renderedImage.clearError(); + } + } + } + else + { + logError("no layer in renderer"); + } + + layerStack.finishReadLayer(view); + + mutex.unlock(); + + return true; +} + +bool deRenderer::render(deCanvas& canvas) +{ + mutex.lock(); + + bool result = renderedImage.render(canvas); + + if (!result) + { + canvas.clear(); + } + + mutex.unlock(); + + return result; +} + +unsigned char* deRenderer::getCurrentImageData() +{ + const deSize& s = channelManager.getChannelSizeFromChannelManager(); + renderedImage.setSize(s); + return renderedImage.getCurrentImageData(); +} diff -Nru delaboratory-0.7/core/renderer.h delaboratory-0.8/core/renderer.h --- delaboratory-0.7/core/renderer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/renderer.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,48 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RENDERER_H +#define _DE_RENDERER_H + +class deChannelManager; +class deViewManager; +class deLayerProcessor; +class deLayerStack; +#include "size.h" +#include "rendered_image.h" +#include "mutex.h" + +class deRenderer +{ + private: + deRenderedImage renderedImage; + deSize size; + deChannelManager& channelManager; + deMutex mutex; + + unsigned char* getCurrentImageData(); + + public: + deRenderer(deChannelManager& _channelManager); + virtual ~deRenderer(); + + bool render(deCanvas& canvas); + bool prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack); +}; + +#endif diff -Nru delaboratory-0.7/core/sampler.cc delaboratory-0.8/core/sampler.cc --- delaboratory-0.7/core/sampler.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/sampler.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,68 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sampler.h" + +deSampler::deSampler() +{ + x = -1; + y = -1; + colorSpace = deColorSpaceCMYK; + enabled = false; + selected = false; +} + +deSampler::~deSampler() +{ +} + +void deSampler::setPosition(deValue _x, deValue _y) +{ + x = _x; + y = _y; +} + +void deSampler::setColorSpace(deColorSpace c) +{ + colorSpace = c; +} + +bool deSampler::isEnabled() const +{ + return enabled; +} + +void deSampler::enable() +{ + enabled = true; +} + +void deSampler::disable() +{ + enabled = false; +} + +bool deSampler::isSelected() const +{ + return selected; +} + +void deSampler::setSelected(bool s) +{ + selected = s; +} diff -Nru delaboratory-0.7/core/sampler.h delaboratory-0.8/core/sampler.h --- delaboratory-0.7/core/sampler.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/sampler.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,55 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SAMPLER_H +#define _DE_SAMPLER_H + +#include "color_space.h" +#include "value.h" + +class deSampler +{ + private: + deValue x; + deValue y; + deColorSpace colorSpace; + bool enabled; + bool selected; + + public: + deSampler(); + virtual ~deSampler(); + + deValue getX() const {return x;}; + deValue getY() const {return y;}; + + void setPosition(deValue _x, deValue _y); + + deColorSpace getColorSpace() const {return colorSpace;}; + void setColorSpace(deColorSpace c); + + bool isEnabled() const; + void enable(); + void disable(); + + bool isSelected() const; + void setSelected(bool s); + +}; + +#endif diff -Nru delaboratory-0.7/core/sampler_manager.cc delaboratory-0.8/core/sampler_manager.cc --- delaboratory-0.7/core/sampler_manager.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/sampler_manager.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,175 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sampler_manager.h" +#include "layer_processor.h" +#include + +deSamplerManager::deSamplerManager() +{ + size = 5; + + int i; + for (i = 0; i < size; i++) + { + deSampler s; + samplers.push_back(s); + } + + selected = -1; + moving = false; +} + +deSamplerManager::~deSamplerManager() +{ +} + + +deSampler* deSamplerManager::getSampler(int index) +{ + if ((index < 0) || ((unsigned int)index >= samplers.size())) + { + return NULL; + } + + return &(samplers[index]); +} + +bool deSamplerManager::select(deValue x, deValue y) +{ + int i; + + for (i = 0; i < size; i++) + { + deSampler& s = samplers[i]; + s.setSelected(false); + } + + for (i = 0; i < size; i++) + { + deSampler& s = samplers[i]; + if (s.isEnabled()) + { + deValue dx = s.getX() - x; + deValue dy = s.getY() - y; + deValue r = sqrt(dx*dx + dy*dy); + + if (r < 0.01) + { + selected = i; + s.setSelected(true); + return true; + } + } + } + + for (i = 0; i < size; i++) + { + deSampler& s = samplers[i]; + if (!s.isEnabled()) + { + s.enable(); + selected = i; + s.setSelected(true); + return true; + } + } + + return false; +} + +bool deSamplerManager::onClick(deValue x, deValue y) +{ + if (!moving) + { + return false; + } + + if (select(x,y)) + { + deSampler& s = samplers[selected]; + s.setPosition(x, y); + + return true; + } + + return false; + +} + +bool deSamplerManager::onMove(deValue x, deValue y) +{ + if (!moving) + { + return false; + } + + if (selected >= 0) + { + deSampler& s = samplers[selected]; + + if ((x < -0.01) || (y < -0.01) || (x>1.01) || (y>1.01)) + { + s.disable(); + selected = -1; + s.setSelected(false); + } + else + { + s.setPosition(x, y); + } + + return true; + } + + return false; +} + +bool deSamplerManager::onRelease() +{ + int i; + + for (i = 0; i < size; i++) + { + deSampler& s = samplers[i]; + s.setSelected(false); + } + + selected = -1; + + return true; +} + +void deSamplerManager::setMoving(bool m) +{ + moving = m; +} + +bool deSamplerManager::getMoving() const +{ + return moving; +} + +void deSamplerManager::clear() +{ + std::vector::iterator i; + for (i = samplers.begin(); i != samplers.end(); i++) + { + (*i).disable(); + } +} diff -Nru delaboratory-0.7/core/sampler_manager.h delaboratory-0.8/core/sampler_manager.h --- delaboratory-0.7/core/sampler_manager.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/sampler_manager.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,60 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SAMPLER_MANAGER_H +#define _DE_SAMPLER_MANAGER_H + +#include "sampler.h" +#include + +class deSamplerManager +{ + private: + std::vector samplers; + + int selected; + int size; + + bool moving; + + bool select(deValue x, deValue y); + + deSamplerManager(const deSamplerManager&); + deSamplerManager& operator =(const deSamplerManager&); + + public: + deSamplerManager(); + virtual ~deSamplerManager(); + + int getNumberOfSamplers() const {return samplers.size();}; + deSampler* getSampler(int index); + + bool onClick(deValue x, deValue y); + bool onMove(deValue x, deValue y); + bool onRelease(); + + int getSelected() const {return selected;}; + + void setMoving(bool m); + + bool getMoving() const; + + void clear(); +}; + +#endif diff -Nru delaboratory-0.7/core/size.cc delaboratory-0.8/core/size.cc --- delaboratory-0.7/core/size.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/size.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,94 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "size.h" +#include + +deSize::deSize(int _w, int _h) +{ + w = _w; + h = _h; +} + +deSize::~deSize() +{ +} + +bool operator ==(const deSize& a, const deSize& b) +{ + return ( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); +} + +bool operator !=(const deSize& a, const deSize& b) +{ + return !( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); +} + +deSize fitInside(const deSize& area, deValue aspect) +{ + if (aspect == 0) + { + return deSize(0,0); + } + + int w = area.getW(); + int h = w / aspect; + + if (h > area.getH()) + { + h = area.getH(); + w = h * aspect; + } + + return deSize(w,h); +} + +std::string deSize::str() const +{ + std::ostringstream oss; + oss << "[w: " << w << " h: " << h << "]"; + return oss.str(); +} + +bool deSize::isEmpty() const +{ + if (w > 0) + { + return false; + } + if (h > 0) + { + return false; + } + return true; +} + +deSize deSize::rotated() const +{ + deSize s(h, w); + return s; +} + +float deSize::getAspect() const +{ + if (h > 0) + { + return (float) w / h; + } + return 0; +} diff -Nru delaboratory-0.7/core/size.h delaboratory-0.8/core/size.h --- delaboratory-0.7/core/size.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/size.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SIZE_H +#define _DE_SIZE_H + +#include +#include "value.h" + +class deSize +{ + private: + int w; + int h; + + public: + deSize(int _w, int _h); + virtual ~deSize(); + + deSize rotated() const; + + int getW() const {return w;}; + int getH() const {return h;}; + + int getN() const {return w*h;}; + + float getAspect() const; + + std::string str() const; + + bool isEmpty() const; +}; + +bool operator ==(const deSize& a, const deSize& b); +bool operator !=(const deSize& a, const deSize& b); + +deSize fitInside(const deSize& area, deValue aspect); + +#endif diff -Nru delaboratory-0.7/core/skin_color_chart.cc delaboratory-0.8/core/skin_color_chart.cc --- delaboratory-0.7/core/skin_color_chart.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/skin_color_chart.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,105 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "skin_color_chart.h" + +void getFelixVonLuschan(std::vector& skins) +{ + skins.push_back(deSkinRGB(244, 242, 245)); + skins.push_back(deSkinRGB(236, 235, 233)); + skins.push_back(deSkinRGB(250, 249, 247)); + skins.push_back(deSkinRGB(253, 251, 230)); + skins.push_back(deSkinRGB(253, 246, 230)); + + skins.push_back(deSkinRGB(254, 247, 229)); + skins.push_back(deSkinRGB(249, 241, 239)); + skins.push_back(deSkinRGB(243, 234, 229)); + skins.push_back(deSkinRGB(244, 241, 234)); + skins.push_back(deSkinRGB(251, 252, 244)); + + skins.push_back(deSkinRGB(251, 247, 235)); + skins.push_back(deSkinRGB(254, 246, 225)); + skins.push_back(deSkinRGB(255, 249, 225)); + skins.push_back(deSkinRGB(255, 249, 224)); + skins.push_back(deSkinRGB(241, 231, 195)); + + skins.push_back(deSkinRGB(239, 226, 173)); + skins.push_back(deSkinRGB(224, 210, 147)); + skins.push_back(deSkinRGB(242, 226, 151)); + skins.push_back(deSkinRGB(235, 214, 159)); + skins.push_back(deSkinRGB(235, 217, 133)); + skins.push_back(deSkinRGB(227, 196, 103)); + + skins.push_back(deSkinRGB(225, 193, 106)); + skins.push_back(deSkinRGB(223, 193, 123)); + skins.push_back(deSkinRGB(222, 184, 119)); + skins.push_back(deSkinRGB(199, 164, 100)); + skins.push_back(deSkinRGB(188, 151, 98)); + skins.push_back(deSkinRGB(155, 107, 67)); + skins.push_back(deSkinRGB(142, 88, 62)); + + skins.push_back(deSkinRGB(121, 77, 48)); + skins.push_back(deSkinRGB(100, 49, 22)); + skins.push_back(deSkinRGB(101, 48, 32)); + skins.push_back(deSkinRGB(96, 49, 33)); + skins.push_back(deSkinRGB(87, 50, 41)); + skins.push_back(deSkinRGB(64, 32, 21)); + skins.push_back(deSkinRGB(49, 37, 41)); + skins.push_back(deSkinRGB(27, 28, 27)); + +} + +void getSkinRanges(std::vector& ranges) +{ + deSkinRange t1; + t1.first = 1; + t1.last = 5; + t1.description = "Very light or \"white\" type"; + ranges.push_back(t1); + + deSkinRange t2; + t2.first = 6; + t2.last = 10; + t2.description = "Light"; + ranges.push_back(t2); + + deSkinRange t3; + t3.first = 11; + t3.last = 15; + t3.description = "Light intermediate"; + ranges.push_back(t3); + + deSkinRange t4; + t4.first = 16; + t4.last = 21; + t4.description = "Dark intermediate"; + ranges.push_back(t4); + + deSkinRange t5; + t5.first = 22; + t5.last = 28; + t5.description = "Dark or \"brown\" type"; + ranges.push_back(t5); + + deSkinRange t6; + t6.first = 29; + t6.last = 36; + t6.description = "Very dark or \"black\" type"; + ranges.push_back(t6); + +} diff -Nru delaboratory-0.7/core/skin_color_chart.h delaboratory-0.8/core/skin_color_chart.h --- delaboratory-0.7/core/skin_color_chart.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/skin_color_chart.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,63 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SKIN_COLOR_CHART_H +#define _DE_SKIN_COLOR_CHART_H + +#include "value.h" + +#include +#include + +struct deSkinCMYK +{ + deValue c; + deValue m; + deValue y; + deValue k; + + deSkinCMYK(int _c, int _m, int _y, int _k) + :c(_c), m(_m), y(_y), k(_k) + { + } +}; + +struct deSkinRGB +{ + int r; + int g; + int b; + + deSkinRGB(int _r, int _g, int _b) + :r(_r), g(_g), b(_b) + { + } + +}; + +struct deSkinRange +{ + int first; + int last; + std::string description; +}; + +void getFelixVonLuschan(std::vector& skins); +void getSkinRanges(std::vector& ranges); + +#endif diff -Nru delaboratory-0.7/core/static_image.cc delaboratory-0.8/core/static_image.cc --- delaboratory-0.7/core/static_image.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/static_image.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,210 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "static_image.h" +#include "logger.h" +#include "color_space_utils.h" +#include "str.h" +#include "copy_channel.h" +#include "scale_channel.h" + +deStaticImage::deStaticImage() +:colorSpace(deColorSpaceInvalid), + size(0,0) +{ + lastRotate = -1; + + int n = 3; + int i; + for (i = 0; i < n; i++) + { + channels.push_back(NULL); + mutexes.push_back(new deMutexReadWrite(4)); + } +} + +void deStaticImage::setColorSpace(deColorSpace c) +{ + if (getColorSpaceSize(c) == 3) + { + colorSpace = c; + } +} + +deStaticImage::~deStaticImage() +{ + unsigned int i; + for (i = 0; i < channels.size(); i++) + { + if (channels[i]) + { + delete [] channels[i]; + } + delete mutexes[i]; + } +} + +deColorSpace deStaticImage::getColorSpace() const +{ + return colorSpace; +} + +void deStaticImage::setSize(const deSize& _size) +{ + if (size == _size) + { + return; + } + size = _size; + logInfo("static image set size " + str(size.getW()) + "x" + str(size.getH())); + int n = 3; + int i; + for (i = 0; i < n; i++) + { + if (channels[i]) + { + delete [] channels[i]; + } + channels[i] = new deValue[size.getN()]; + } +} + +void deStaticImage::lock() +{ + mutex.lock(); +} + +void deStaticImage::unlock() +{ + mutex.unlock(); +} + +const deValue* deStaticImage::startReadStatic(int index) +{ + int n = 3; + if (index < 0) + { + logError("deStaticImage::startReadStatic index: " + str(index)); + return NULL; + } + if (index >= n) + { + logError("deStaticImage::startReadStatic index: " + str(index)); + return NULL; + } + mutexes[index]->lockRead(); + return channels[index]; +} + +deValue* deStaticImage::startWriteStatic(int index) +{ + int n = 3; + if (index < 0) + { + logError("deStaticImage::startWriteStatic index: " + str(index)); + return NULL; + } + if (index >= n) + { + logError("deStaticImage::startWriteStatic index: " + str(index)); + return NULL; + } + mutexes[index]->lockWrite(); + return channels[index]; +} + +void deStaticImage::finishReadStatic(int index) +{ + int n = 3; + if (index < 0) + { + logError("deStaticImage::finishReadStatic index: " + str(index)); + return; + } + if (index >= n) + { + logError("deStaticImage::finishReadStatic index: " + str(index)); + return; + } + mutexes[index]->unlockRead(); +} + +void deStaticImage::finishWriteStatic(int index) +{ + int n = 3; + if (index < 0) + { + logError("deStaticImage::finishWriteStatic index: " + str(index)); + return; + } + if (index >= n) + { + logError("deStaticImage::finishWriteStatic index: " + str(index)); + return; + } + mutexes[index]->unlockWrite(); +} + +bool deStaticImage::isEmpty() const +{ + return size.isEmpty(); +} + +void deStaticImage::copyToChannel(int channel, deValue* destination, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, deSize ds, bool mirrorX, bool mirrorY, int rotate, deValue contrast) +{ + lastRotate = rotate; + + int w = ds.getW(); + int h = ds.getH(); + if (w <= 0) + { + logError("can't copy static image w: " + str(w)); + return; + } + if (h <= 0) + { + logError("can't copy static image h: " + str(h)); + return; + } + const deValue* source = startReadStatic(channel); + + int ws = size.getW(); + int hs = size.getH(); + + scaleChannel(source, destination, z_x1, z_y1, z_x2, z_y2, w, h, mirrorX, mirrorY, rotate, ws, hs, contrast); + + finishReadStatic(channel); +} + +deSize deStaticImage::getStaticImageSize() const +{ + if ((lastRotate == 90) || (lastRotate==270)) + { + return size.rotated(); + } + else + { + return size; + } +} + +deValue deStaticImage::getAspect() const +{ + deValue aspect = size.getAspect(); + return aspect; +} diff -Nru delaboratory-0.7/core/static_image.h delaboratory-0.8/core/static_image.h --- delaboratory-0.7/core/static_image.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/static_image.h 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,70 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_STATIC_IMAGE_H +#define _DE_STATIC_IMAGE_H + +#include "color_space.h" +#include "mutex_read_write.h" +#include "size.h" +#include "mutex.h" +#include + +class deStaticImage +{ + private: + deColorSpace colorSpace; + std::vector channels; + std::vector mutexes; + deSize size; + mutable deMutex mutex; + int lastRotate; + + const deValue* startReadStatic(int index); + void finishReadStatic(int index); + + deStaticImage(const deStaticImage& i); + deStaticImage& operator = (const deStaticImage& i); + + public: + deStaticImage(); + + virtual ~deStaticImage(); + + void setColorSpace(deColorSpace c); + deColorSpace getColorSpace() const; + + deValue* startWriteStatic(int index); + void finishWriteStatic(int index); + + void setSize(const deSize& _size); + deSize getStaticImageSize() const; + + void lock(); + void unlock(); + + void setInfo(const std::string& s); + + bool isEmpty() const; + + void copyToChannel(int channel, deValue* destination, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, deSize destinationSize, bool mirrorX, bool mirrorY, int rotate, deValue contrast); + + deValue getAspect() const; +}; + +#endif diff -Nru delaboratory-0.7/core/str.cc delaboratory-0.8/core/str.cc --- delaboratory-0.7/core/str.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/str.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,142 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "str.h" +#include + +std::string getBaseName(const std::string& s) +{ + int pos = s.rfind("."); + return s.substr(0, pos); +} + +std::string getExtension(const std::string& s) +{ + int pos = s.rfind("."); + return s.substr(pos + 1, s.size() - pos - 1); +} + +std::string removePathAndExtension(const std::string& fileName) +{ + size_t posDot = fileName.rfind("."); +#ifdef _WIN32 + size_t posSlash = fileName.rfind("\\"); +#else + size_t posSlash = fileName.rfind("/"); +#endif + int posStart; + if (posSlash > fileName.size()) + { + posStart= 0; + } + else + { + posStart = posSlash + 1; + } + return fileName.substr(posStart, posDot - posStart ); +} + +std::string getPath(const std::string& fileName) +{ +#ifdef _WIN32 + size_t posSlash = fileName.rfind("\\"); +#else + size_t posSlash = fileName.rfind("/"); +#endif + return fileName.substr(0, posSlash ); +} + +std::string str(int n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + +std::string str(long n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + +std::string str(unsigned int n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + +std::string str(deValue n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + +deValue getValue(const std::string& s) +{ + deValue v; + std::istringstream iss(s); + iss >> v; + return v; +} + +int getInt(const std::string& s) +{ + int v; + std::istringstream iss(s); + iss >> v; + return v; +} + +bool getBool(const std::string& s) +{ + if (s == "true") + { + return true; + } + else + { + // TODO some kind of assert of exception in other case? + return false; + } +} + +std::string str(bool b) +{ + if (b) + { + return "true"; + } + else + { + return "false"; + } +} + + +std::string insertIndex(const std::string& s, int index) +{ + std::string b = getBaseName(s); + std::string e = getExtension(s); + + return b + "_" + str(index) + "." + e; +} + + diff -Nru delaboratory-0.7/core/str.h delaboratory-0.8/core/str.h --- delaboratory-0.7/core/str.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/str.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,48 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_STR_H +#define _DE_STR_H + +#include +#include "value.h" + +/* returns str before ".", so for "abcde.jpg" returns "abcde" */ +std::string getBaseName(const std::string& s); + +/* returns str after ".", so for "abcde.jpg" returns "jpg" */ +std::string getExtension(const std::string& s); + +std::string removePathAndExtension(const std::string& fileName); +std::string getPath(const std::string& fileName); + +std::string str(deValue n); +std::string str(int n); +std::string str(long n); +std::string str(unsigned int n); +std::string str(bool b); + +deValue getValue(const std::string& s); +int getInt(const std::string& s); +bool getBool(const std::string& s); + + +std::string insertIndex(const std::string& s, int index); + + +#endif diff -Nru delaboratory-0.7/core/switchable_layer.cc delaboratory-0.8/core/switchable_layer.cc --- delaboratory-0.7/core/switchable_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/switchable_layer.cc 2012-07-26 00:31:57.000000000 +0000 @@ -0,0 +1,108 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "switchable_layer.h" +#include "color_space_utils.h" +#include "property_boolean.h" + +deSwitchableLayer::deSwitchableLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) +:deBaseLayerWithSource(_colorSpace, _channelManager, _sourceLayerIndex, _layerStack) +{ + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + std::string n = getChannelName(colorSpace, i); + createPropertyBoolean(n); + getPropertyBoolean(n)->setSizer("channels"); + getPropertyBoolean(n)->setBlendOnly(); + enableChannel(i); + } +} + +deSwitchableLayer::~deSwitchableLayer() +{ +} + +void deSwitchableLayer::disableNotLuminance() +{ + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + if (!isChannelLuminance(colorSpace, i)) + { + disableChannel(i); + } + } +} + +void deSwitchableLayer::disableNotForSharpen() +{ + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + if (!shouldChannelBeSharpened(colorSpace, i)) + { + disableChannel(i); + } + } +} + +void deSwitchableLayer::disableAll() +{ + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + disableChannel(i); + } +} + +bool deSwitchableLayer::isChannelEnabled(int index) const +{ + std::string n = getChannelName(colorSpace, index); + const dePropertyBoolean* p = getPropertyBoolean(n); + if (!p) + { + return false; + } + return p->get(); +} + +void deSwitchableLayer::enableChannel(int index) +{ + std::string n = getChannelName(colorSpace, index); + dePropertyBoolean* p = getPropertyBoolean(n); + if (p) + { + p->set(true); + } +} + +void deSwitchableLayer::disableChannel(int index) +{ + std::string n = getChannelName(colorSpace, index); + dePropertyBoolean* p = getPropertyBoolean(n); + if (p) + { + p->set(false); + } +} + diff -Nru delaboratory-0.7/core/switchable_layer.h delaboratory-0.8/core/switchable_layer.h --- delaboratory-0.7/core/switchable_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/switchable_layer.h 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SWITCHABLE_LAYER_H +#define _DE_SWITCHABLE_LAYER_H + +#include "base_layer_with_source.h" +#include + +class deSwitchableLayer:public deBaseLayerWithSource +{ + protected: + void disableAll(); + void disableNotLuminance(); + void disableNotForSharpen(); + virtual bool isChannelNeutral(int index) {return false;}; + + public: + deSwitchableLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deSwitchableLayer(); + + bool isChannelEnabled(int index) const; + void enableChannel(int index); + void disableChannel(int index); + + + + +}; + +#endif diff -Nru delaboratory-0.7/core/test_image.cc delaboratory-0.8/core/test_image.cc --- delaboratory-0.7/core/test_image.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/test_image.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,108 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "test_image.h" +#include "static_image.h" +#include +#include + +void generateImage1(deValue* pixels0, deValue* pixels1, deValue* pixels2, int w, int h) +{ + int x; + int y; + int p = 0; + + deValue margin = 0.1; + + deValue L = 0.8; + deValue A; + deValue B; + + for (y = 0; y < h; y++) + { + deValue yy = (deValue) y / h; + if ((yy > margin) && (yy < 1 - margin)) + { + B = (yy - margin) / (1.0 - 2 * margin); + } + else + { + B = 0; + } + + for (x = 0; x < w; x++) + { + deValue xx = (deValue) x / w; + if ((xx > margin) && (xx < 1 - margin)) + { + A = (xx - margin) / (1.0 - 2 * margin); + } + else + { + A = 0; + } + + if ((A == 0) || (B == 0)) + { + deValue m = yy; + if (xx > m) + { + m = xx; + } + pixels0[p] = m; + pixels1[p] = 0.5; + pixels2[p] = 0.5; + } + else + { + pixels0[p] = L; + pixels1[p] = A; + pixels2[p] = B; + } + + p++; + } + } +} + +void generateTestImage(deStaticImage& image, int s) +{ + int w = s; + int h = s; + deColorSpace colorSpace = deColorSpaceLAB; + + image.lock(); + + deSize size(w, h); + image.setSize(size); + + image.setColorSpace(colorSpace); + + deValue* pixels0 = image.startWriteStatic(0); + deValue* pixels1 = image.startWriteStatic(1); + deValue* pixels2 = image.startWriteStatic(2); + + generateImage1(pixels0, pixels1, pixels2, w, h); + + image.finishWriteStatic(0); + image.finishWriteStatic(1); + image.finishWriteStatic(2); + + image.unlock(); +} + diff -Nru delaboratory-0.7/core/test_image.h delaboratory-0.8/core/test_image.h --- delaboratory-0.7/core/test_image.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/test_image.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_TEST_IMAGE_H +#define _DE_TEST_IMAGE_H + +class deStaticImage; + +void generateTestImage(deStaticImage& image, int s); + +#endif diff -Nru delaboratory-0.7/core/value.cc delaboratory-0.8/core/value.cc --- delaboratory-0.7/core/value.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/value.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "value.h" + +void clip(deValue& v) +{ + if (v < 0) + { + v = 0; + } + else if (v > 1) + { + v = 1; + } +} diff -Nru delaboratory-0.7/core/value.h delaboratory-0.8/core/value.h --- delaboratory-0.7/core/value.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/value.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_VALUE_H +#define _DE_VALUE_H + +#define deValue float + +void clip(deValue& v); + +#endif diff -Nru delaboratory-0.7/core/view_manager.cc delaboratory-0.8/core/view_manager.cc --- delaboratory-0.7/core/view_manager.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/view_manager.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,119 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "view_manager.h" +#include "project.h" +#include "base_layer.h" +#include "layer_processor.h" +#include "str.h" +#include "channel_manager.h" +#include "layer_stack.h" +#include "zoom_manager.h" + +deViewManager::deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager) +:project(_project), layerProcessor(_processor), zoomManager(_zoomManager) +{ + view = 0; + single = false; +} + +deViewManager::~deViewManager() +{ +} + +int deViewManager::getView() const +{ + return view; +} + +void deViewManager::setView(int v) +{ + logInfo("view manager set view " + str(v)); + int old = view; + view = v; + project.onChangeView(old); +} + +void deViewManager::setLastView() +{ + int n = project.getLayerStack().getSize(); + n--; + setView(n); +} + +void deViewManager::setSingleChannel(int _channel) +{ + single = true; + channel = _channel; + project.onChangeViewMode(); + layerProcessor.onChangeViewMode(); + +} + +void deViewManager::setNormal() +{ + single = false; + project.onChangeViewMode(); + layerProcessor.onChangeViewMode(); +} + +deColorSpace deViewManager::getColorSpace() const +{ + deColorSpace colorSpace = deColorSpaceInvalid; + + deLayerStack& layerStack = project.getLayerStack(); + + const deBaseLayer* layer = layerStack.startReadLayer(view); + + if (layer) + { + colorSpace = layer->getColorSpace(); + } + + layerStack.finishReadLayer(view); + + return colorSpace; +} + +void deViewManager::setHistogramChannel(int channel) +{ + project.setHistogramChannel(channel); +} + +deValue deViewManager::getRealScale() const +{ + deSize ps = project.getPreviewChannelManager().getChannelSizeFromChannelManager(); + + deSize ss = project.getSourceImageSize(); + + deValue sx = (deValue) ps.getW() / ss.getW(); + deValue sy = (deValue) ps.getH() / ss.getH(); + + deValue s = sx; + if (sy < s) + { + s = sy; + } + + return s; +} + +void deViewManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) +{ + return zoomManager.getZoom(_x1, _y1, _x2, _y2); +} diff -Nru delaboratory-0.7/core/view_manager.h delaboratory-0.8/core/view_manager.h --- delaboratory-0.7/core/view_manager.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/view_manager.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,63 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PREVIEW_MANAGER_H +#define _DE_PREVIEW_MANAGER_H + +class deProject; +class deLayerProcessor; +class deZoomManager; +#include "color_space.h" +#include "value.h" + +class deViewManager +{ + private: + int view; + deProject& project; + deLayerProcessor& layerProcessor; + deZoomManager& zoomManager; + bool single; + int channel; + + public: + deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager); + virtual ~deViewManager(); + + void setView(int v); + int getView() const; + + void setSingleChannel(int _channel); + void setNormal(); + + deColorSpace getColorSpace() const; + + bool isSingleChannel() const {return single;}; + int getChannel() const {return channel;}; + + void setHistogramChannel(int channel); + + deValue getRealScale() const; + + void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); + + void setLastView(); + +}; + +#endif diff -Nru delaboratory-0.7/core/zoom_manager.cc delaboratory-0.8/core/zoom_manager.cc --- delaboratory-0.7/core/zoom_manager.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/zoom_manager.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,150 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "zoom_manager.h" +#include "str.h" +#include "logger.h" + +deZoomManager::deZoomManager() +{ + selectionMode = false; + fullZoomOut(); +} + +deZoomManager::~deZoomManager() +{ +} + +void deZoomManager::fullZoomOut() +{ + z_x1 = 0; + z_y1 = 0; + z_x2 = 1; + z_y2 = 1; +} + +bool deZoomManager::isInSelectionMode() const +{ + return selectionMode; +} + +void deZoomManager::enableSelectionMode() +{ + selectionMode = true; + s_x1 = 0; + s_x2 = 0; + s_y1 = 0; + s_y2 = 0; +} + +bool deZoomManager::onClick(deValue x, deValue y) +{ + s_x1 = x; + s_x2 = x; + s_y1 = y; + s_y2 = y; + return true; +} + +bool deZoomManager::onMove(deValue x, deValue y) +{ + if (x > 1) + { + x = 1; + } + if (y > 1) + { + y = 1; + } + if (x < s_x1) + { + x = s_x1; + } + if (y < s_y1) + { + y = s_y1; + } + + s_x2 = x; + s_y2 = y; + return true; +} + +bool deZoomManager::onRelease() +{ + if ((s_x1 < s_x2) && (s_y1 < s_y2)) + { + deValue x1 = z_x1 + s_x1 * (z_x2 - z_x1); + deValue x2 = z_x1 + s_x2 * (z_x2 - z_x1); + deValue y1 = z_y1 + s_y1 * (z_y2 - z_y1); + deValue y2 = z_y1 + s_y2 * (z_y2 - z_y1); + z_x1 = x1; + z_x2 = x2; + z_y1 = y1; + z_y2 = y2; + logInfo("set zoom x1: " + str(z_x1) + " x2: " + str(z_x2) + " y1: " + str(z_y1) + " y2: " + str(z_y2)); + } + else + { + fullZoomOut(); + } + + selectionMode = false; + return true; +} + +void deZoomManager::getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) +{ + _x1 = s_x1; + _y1 = s_y1; + _x2 = s_x2; + _y2 = s_y2; +} + +void deZoomManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) +{ + _x1 = z_x1; + _y1 = z_y1; + _x2 = z_x2; + _y2 = z_y2; +} + +bool deZoomManager::isZoomed() const +{ + if (z_x1 > 0.0) + { + return true; + } + + if (z_y1 > 0.0) + { + return true; + } + + if (z_x2 < 1.0) + { + return true; + } + + if (z_y2 < 1.0) + { + return true; + } + + return false; +} diff -Nru delaboratory-0.7/core/zoom_manager.h delaboratory-0.8/core/zoom_manager.h --- delaboratory-0.7/core/zoom_manager.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/core/zoom_manager.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,58 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_ZOOM_MANAGER_H +#define _DE_ZOOM_MANAGER_H + +#include "value.h" + +class deZoomManager +{ + private: + bool selectionMode; + + deValue s_x1; + deValue s_y1; + deValue s_x2; + deValue s_y2; + + deValue z_x1; + deValue z_y1; + deValue z_x2; + deValue z_y2; + + public: + deZoomManager(); + virtual ~deZoomManager(); + + bool isInSelectionMode() const; + void enableSelectionMode(); + + bool onClick(deValue x, deValue y); + bool onMove(deValue x, deValue y); + bool onRelease(); + + void getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); + void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); + + void fullZoomOut(); + + bool isZoomed() const; +}; + +#endif diff -Nru delaboratory-0.7/debian/changelog delaboratory-0.8/debian/changelog --- delaboratory-0.7/debian/changelog 2012-04-10 15:16:06.000000000 +0000 +++ delaboratory-0.8/debian/changelog 2012-07-30 10:34:30.000000000 +0000 @@ -1,3 +1,9 @@ +delaboratory (0.8-1dhor~precise) precise; urgency=low + + * 0.8 + + -- Dariusz Duma Mon, 30 Jul 2012 12:33:56 +0200 + delaboratory (0.7-1dhor~precise) precise; urgency=low * support for RAW files diff -Nru delaboratory-0.7/debian/patches/debian-changes-0.7-1dhor~oneiric delaboratory-0.8/debian/patches/debian-changes-0.7-1dhor~oneiric --- delaboratory-0.7/debian/patches/debian-changes-0.7-1dhor~oneiric 2012-04-10 15:16:04.000000000 +0000 +++ delaboratory-0.8/debian/patches/debian-changes-0.7-1dhor~oneiric 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -Description: Upstream changes introduced in version 0.7-1dhor~oneiric - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - delaboratory (0.7-1dhor~oneiric) oneiric; urgency=low - . - * support for RAW files - * image zoom - * basic settings (brightness, contrast, saturation, etc.) - * equalizer layer - * double vignette layer - * ProPhoto RGB colorspace - * improved GUI and bugfixes - . - The person named in the Author field signed this changelog entry. -Author: Dariusz Duma - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- delaboratory-0.7.orig/Makefile -+++ delaboratory-0.7/Makefile -@@ -46,7 +46,7 @@ else - # release stuff - # CXXFLAGS+=-ffast-math -fpermissive ${OPTFLAGS} -DNDEBUG - # -Ofast -fpermissive ${OPTFLAGS} -DNDEBUG --CXXFLAGS+=-Ofast -fpermissive ${OPTFLAGS} -DNDEBUG -+CXXFLAGS+=-ffast-math -fpermissive ${OPTFLAGS} -DNDEBUG - endif - - # warnings from wxWidgets diff -Nru delaboratory-0.7/debian/patches/series delaboratory-0.8/debian/patches/series --- delaboratory-0.7/debian/patches/series 2012-04-10 15:15:38.000000000 +0000 +++ delaboratory-0.8/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian-changes-0.7-1dhor~oneiric diff -Nru delaboratory-0.7/gui_wx/bitmap.cc delaboratory-0.8/gui_wx/bitmap.cc --- delaboratory-0.7/gui_wx/bitmap.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/bitmap.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "bitmap.h" + +deBitmap::deBitmap() +{ +} + +deBitmap::~deBitmap() +{ +} + diff -Nru delaboratory-0.7/gui_wx/bitmap.h delaboratory-0.8/gui_wx/bitmap.h --- delaboratory-0.7/gui_wx/bitmap.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/bitmap.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,34 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BITMAP_H +#define _DE_BITMAP_H + +class deBitmap +{ + private: + public: + deBitmap(); + virtual ~deBitmap(); + + virtual void resize(int w, int h) = 0; + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/bitmap_wx.cc delaboratory-0.8/gui_wx/bitmap_wx.cc --- delaboratory-0.7/gui_wx/bitmap_wx.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/bitmap_wx.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "bitmap_wx.h" + +deBitmapWX::deBitmapWX() +{ + bitmap = NULL; +} + +deBitmapWX::~deBitmapWX() +{ + if (bitmap) + { + delete bitmap; + } +} + +void deBitmapWX::resize(int w, int h) +{ + if (bitmap) + { + delete bitmap; + bitmap = NULL; + } + + bitmap = new wxBitmap(w, h, 24); +} + diff -Nru delaboratory-0.7/gui_wx/bitmap_wx.h delaboratory-0.8/gui_wx/bitmap_wx.h --- delaboratory-0.7/gui_wx/bitmap_wx.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/bitmap_wx.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,40 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BITMAP_WX_H +#define _DE_BITMAP_WX_H + +#include "bitmap.h" +#include + +class deBitmapWX:public deBitmap +{ + private: + wxBitmap* bitmap; + public: + deBitmapWX(); + virtual ~deBitmapWX(); + + virtual void resize(int w, int h); + + wxBitmap* getBitmap() {return bitmap;}; + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/button.cc delaboratory-0.8/gui_wx/button.cc --- delaboratory-0.7/gui_wx/button.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/button.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,67 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "button.h" +#include +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" + +class deButtonImpl:public dePanelWX +{ + private: + deButton& parent; + wxButton* button; + public: + deButtonImpl(deButton& _parent, deWindow& _parentWindow, const std::string& _name) + :dePanelWX(_parentWindow), parent(_parent) + { + button = new wxButton(this, wxID_ANY, wxString::FromAscii(_name.c_str())); + + Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deButtonImpl::click)); + } + + virtual ~deButtonImpl() + { + } + + void click(wxCommandEvent &event) + { + parent.onClick(); + } + + +}; + +deButton::deButton(deWindow& window, const std::string& _name) +{ + impl = new deButtonImpl(*this, window, _name); +} + +deButton::~deButton() +{ + if (impl) + { + delete impl; + } +} + +deWindow& deButton::getWindow() +{ + return impl->getWindow(); +} diff -Nru delaboratory-0.7/gui_wx/button.h delaboratory-0.8/gui_wx/button.h --- delaboratory-0.7/gui_wx/button.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/button.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_BUTTON_H +#define _DE_BUTTON_H + +#include "value.h" +#include +class dePanel; +class deWindow; +class deLayerProcessor; + +class deButtonImpl; + +class deButton +{ + private: + deButtonImpl* impl; + public: + deButton(deWindow& window, const std::string& _name); + virtual ~deButton(); + + virtual void onClick() = 0; + + deWindow& getWindow(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/canvas.cc delaboratory-0.8/gui_wx/canvas.cc --- delaboratory-0.7/gui_wx/canvas.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/canvas.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "canvas.h" + +deCanvas::deCanvas() +{ +} + +deCanvas::~deCanvas() +{ +} + diff -Nru delaboratory-0.7/gui_wx/canvas.h delaboratory-0.8/gui_wx/canvas.h --- delaboratory-0.7/gui_wx/canvas.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/canvas.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,42 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CANVAS_H +#define _DE_CANVAS_H + +class deBitmap; + +class deCanvas +{ + private: + public: + deCanvas(); + ~deCanvas(); + + virtual void clear() = 0; + virtual void drawCircle(int x, int y, int r) = 0; + virtual void drawLine(int x1, int y1, int x2, int y2) = 0; + virtual void setPen(int r, int g, int b) = 0; + virtual void setBrush(int r, int g, int b) = 0; + virtual void drawBitmap(deBitmap& bitmap) = 0; + virtual void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) = 0; + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/canvas_wx.cc delaboratory-0.8/gui_wx/canvas_wx.cc --- delaboratory-0.7/gui_wx/canvas_wx.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/canvas_wx.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,78 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "canvas_wx.h" +#include "bitmap_wx.h" + +deCanvasWX::deCanvasWX(wxDC& _dc) +:dc(_dc) +{ +} + +deCanvasWX::~deCanvasWX() +{ +} + +void deCanvasWX::clear() +{ + dc.Clear(); +} + +void deCanvasWX::drawCircle(int x, int y, int r) +{ + dc.DrawCircle(x, y, r); +} + +void deCanvasWX::drawLine(int x1, int y1, int x2, int y2) +{ + dc.DrawLine(x1, y1, x2, y2); +} + +void deCanvasWX::setPen(int r, int g, int b) +{ + wxPen pen(wxColour(r, g, b)); + + dc.SetPen(pen); +} + +void deCanvasWX::setBrush(int r, int g, int b) +{ + wxBrush brush(wxColour(r, g, b)); + + dc.SetBrush(brush); +} + +void deCanvasWX::drawBitmap(deBitmap& bitmap) +{ + deBitmapWX& bitmapWX = dynamic_cast(bitmap); + + wxBitmap* b = bitmapWX.getBitmap(); + if (b) + { + dc.DrawBitmap(*b, 0, 0, false); + } +} + +void deCanvasWX::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) +{ + wxPoint points[3]; + points[0] = wxPoint(x1, y1); + points[1] = wxPoint(x2, y2); + points[2] = wxPoint(x3, y3); + dc.DrawPolygon(3, points); +} diff -Nru delaboratory-0.7/gui_wx/canvas_wx.h delaboratory-0.8/gui_wx/canvas_wx.h --- delaboratory-0.7/gui_wx/canvas_wx.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/canvas_wx.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CANVAS_WX_H +#define _DE_CANVAS_WX_H + +#include "canvas.h" +#include + +class deCanvasWX:public deCanvas +{ + private: + wxDC& dc; + public: + deCanvasWX(wxDC& _dc); + ~deCanvasWX(); + + virtual void clear(); + + virtual void setPen(int r, int g, int b); + virtual void setBrush(int r, int g, int b); + + virtual void drawCircle(int x, int y, int r); + virtual void drawLine(int x1, int y1, int x2, int y2); + virtual void drawBitmap(deBitmap& bitmap); + virtual void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/channel_selector.cc delaboratory-0.8/gui_wx/channel_selector.cc --- delaboratory-0.7/gui_wx/channel_selector.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/channel_selector.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,122 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "channel_selector.h" +#include +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" +#include "logger.h" +#include "str.h" +#include "color_space_utils.h" + +class deChannelSelectorImpl:public dePanelWX +{ + private: + deChannelSelector& parent; + deColorSpace colorSpace; + std::vector buttons; + public: + deChannelSelectorImpl(deChannelSelector& _parent, deWindow& _parentWindow, deColorSpace _colorSpace) + :dePanelWX(_parentWindow), parent(_parent), colorSpace(_colorSpace) + { + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(sizer); + + int n = getColorSpaceSize(colorSpace); + + int i; + for (i = 0; i < n; i++) + { + int style = 0; + if (i == 0) + { + style = wxRB_GROUP; + } + std::string s = getChannelName(colorSpace, i); + wxRadioButton* b = new wxRadioButton(this, wxID_ANY, wxString::FromAscii(s.c_str()), wxDefaultPosition, wxDefaultSize, style); + sizer->Add(b); + buttons.push_back(b); + } + + Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deChannelSelectorImpl::select)); + + } + + virtual ~deChannelSelectorImpl() + { + logInfo("~deChannelSelectorImpl"); + } + + void setValue(int channel) + { + buttons[channel]->SetValue(1); + } + + void select(wxCommandEvent &event) + { + int i = event.GetId(); + unsigned int j; + for (j = 0; j < buttons.size(); j++) + { + if (buttons[j]->GetId() == i) + { + parent.onValueChange(j); + } + } + + } + + +}; + +deChannelSelector::deChannelSelector(deWindow& window, deColorSpace colorSpace) +{ + logInfo("deChannelSelector constructor"); + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new deChannelSelectorImpl(*this, window, colorSpace); + } + else + { + impl = NULL; + } +} + +deChannelSelector::~deChannelSelector() +{ + logInfo("deChannelSelector destructor"); + if (impl) + { + delete impl; + } +} + +void deChannelSelector::setValue(int channel) +{ + if (impl) + { + impl->setValue(channel); + } +} + +deWindow& deChannelSelector::getWindow() +{ + return impl->getWindow(); +} diff -Nru delaboratory-0.7/gui_wx/channel_selector.h delaboratory-0.8/gui_wx/channel_selector.h --- delaboratory-0.7/gui_wx/channel_selector.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/channel_selector.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CHANNEL_SELECTOR_H +#define _DE_CHANNEL_SELECTOR_H + +#include +#include "value.h" +#include "color_space.h" +class dePanel; +class deWindow; +class deLayerProcessor; + +class deChannelSelectorImpl; + +class deChannelSelector +{ + private: + deChannelSelectorImpl* impl; + public: + deChannelSelector(deWindow& window, deColorSpace colorSpace); + virtual ~deChannelSelector(); + + void setValue(int channel); + virtual void onValueChange(int channel) = 0; + + deWindow& getWindow(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/check_box.cc delaboratory-0.8/gui_wx/check_box.cc --- delaboratory-0.7/gui_wx/check_box.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/check_box.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,98 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "check_box.h" +#include "window_wx.h" +#include "panel_wx.h" + +class deCheckBoxImpl:public dePanelWX +{ + private: + deCheckBox& parent; + wxCheckBox* checkBox; + public: + deCheckBoxImpl(deCheckBox& _parent, deWindow& _parentWindow, const std::string& _name) + :dePanelWX(_parentWindow), parent(_parent) + { + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(sizer); + + checkBox = new wxCheckBox(this, wxID_ANY, wxString::FromAscii(_name.c_str())); + sizer->Add(checkBox); + + Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deCheckBoxImpl::check)); + } + + void check(wxCommandEvent &event) + { + if (checkBox->IsChecked()) + { + parent.onCheck(true); + } + else + { + parent.onCheck(false); + } + } + + void set(bool b) + { + if (b) + { + checkBox->SetValue(1); + } + else + { + checkBox->SetValue(0); + } + } +}; + +deCheckBox::deCheckBox(deWindow& window, const std::string& _name) +{ + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new deCheckBoxImpl(*this, window, _name); + } + else + { + impl = NULL; + } +} + +deCheckBox::~deCheckBox() +{ + if (impl) + { + delete impl; + } +} + +void deCheckBox::set(bool c) +{ + if (impl) + { + impl->set(c); + } +} + +deWindow& deCheckBox::getWindow() +{ + return impl->getWindow(); +} diff -Nru delaboratory-0.7/gui_wx/check_box.h delaboratory-0.8/gui_wx/check_box.h --- delaboratory-0.7/gui_wx/check_box.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/check_box.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,41 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CHECK_BOX_H +#define _DE_CHECK_BOX_H + +#include +#include "window.h" + +class deCheckBoxImpl; + +class deCheckBox +{ + private: + deCheckBoxImpl* impl; + public: + deCheckBox(deWindow& window, const std::string& _name); + virtual ~deCheckBox(); + + virtual void onCheck(bool c) = 0; + void set(bool c); + + deWindow& getWindow(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/choice.cc delaboratory-0.8/gui_wx/choice.cc --- delaboratory-0.7/gui_wx/choice.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/choice.cc 2012-07-28 13:01:26.000000000 +0000 @@ -0,0 +1,99 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "choice.h" +#include "window_wx.h" +#include "panel_wx.h" + +class deChoiceImpl:public dePanelWX +{ + private: + deChoice& parent; + wxChoice* choice; + public: + deChoiceImpl(deChoice& _parent, deWindow& _parentWindow, const std::string& _name, const std::vector& choices) + :dePanelWX(_parentWindow), parent(_parent) + { + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(sizer); + + if (_name.size() > 0) + { + int widthn = 100; + wxStaticText* label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(_name.c_str()), wxDefaultPosition, wxSize(widthn, 30)); + sizer->Add(label, 0, wxCENTER); + } + + wxString* ws = new wxString [choices.size()]; + unsigned int i; + for (i = 0; i < choices.size(); i++) + { + ws[i] = wxString::FromAscii(choices[i].c_str()); + } + + choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), choices.size(), ws); + sizer->Add(choice); + + Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deChoiceImpl::choose)); + } + + void choose(wxCommandEvent &event) + { + int i = event.GetInt(); + parent.onChoose(i); + } + + void set(int index) + { + choice->SetSelection(index); + } +}; + +deChoice::deChoice(deWindow& window, const std::string& _name, const std::vector& _choices) +{ + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new deChoiceImpl(*this, window, _name, _choices); + } + else + { + impl = NULL; + } +} + +deChoice::~deChoice() +{ + if (impl) + { + delete impl; + } +} + +void deChoice::set(int index) +{ + if (impl) + { + impl->set(index); + } +} + +deWindow& deChoice::getWindow() +{ + return impl->getWindow(); +} diff -Nru delaboratory-0.7/gui_wx/choice.h delaboratory-0.8/gui_wx/choice.h --- delaboratory-0.7/gui_wx/choice.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/choice.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CHOICE_H +#define _DE_CHOICE_H + +#include +#include +#include "window.h" + +class deChoiceImpl; + +class deChoice +{ + private: + deChoiceImpl* impl; + public: + deChoice(deWindow& window, const std::string& _name, const std::vector& choices); + virtual ~deChoice(); + + virtual void onChoose(int index) = 0; + void set(int index); + + deWindow& getWindow(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/color_matrix_frame.cc delaboratory-0.8/gui_wx/color_matrix_frame.cc --- delaboratory-0.7/gui_wx/color_matrix_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/color_matrix_frame.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,425 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "color_matrix_frame.h" +#include "color_matrix.h" +#include "gradient_panel.h" +#include "project.h" +#include "layer_stack.h" +#include "base_layer.h" +#include "channel_manager.h" +#include "wx/notebook.h" +#include "conversion_processor.h" + +#define LAB_TILE_SIZE 20 +#define ALL_TILES_SIZE 800 + +deColorMatrixFrame2::deColorMatrixFrame2(wxWindow *parent, deProject& project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette) +:deHelpFrame(parent, "color matrix") +{ + + const deViewManager& viewManager = project.getViewManager(); + int view = viewManager.getView(); + + deLayerStack& layerStack = project.getLayerStack(); + + const deBaseLayer* layer = layerStack.startReadLayer(view); + + const deImage& originalImage = layer->getLayerImage(); + + deChannelManager& channelManager = project.getPreviewChannelManager(); + deSize channelSize = originalImage.getChannelSize(); + int n = channelSize.getN(); + + deImage LABImage(deColorSpaceLAB, channelManager); + LABImage.allocateChannels(); + + deConversionProcessor p; + deConversionCPU cpu(4); + p.convertImage(originalImage, LABImage, cpu); + + int nn = width * height; + + int min = (n / 1.5) / nn; + + const deValue* valuesVertical = LABImage.startRead(channelVertical); + const deValue* valuesHorizontal = LABImage.startRead(channelHorizontal); + const deValue* valuesAverage = LABImage.startRead(channelAverage); + + if ((!valuesVertical) || (!valuesHorizontal) || (!valuesAverage)) + { + logError("LABImage broken in color matrix frame"); + } + + int tilesW = width; + int tilesH = height; + + deColorMatrix colorMatrix(tilesW , tilesH); + + colorMatrix.buildZoomed(valuesHorizontal, valuesVertical, valuesAverage, n, min); + + wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(mainSizer); + + int s = 0; + + wxSizer* LABMapSizer = new wxFlexGridSizer(tilesW, s, s); + mainSizer->Add(LABMapSizer); + + deConversionProcessor cp; + + int x; + int y; + for (y = tilesH - 1; y >= 0; y--) + { + for (x = 0; x < tilesW; x++) + { + int style = 0; + + deValue vx = 0; + deValue vy = 0; + bool center; + deValue a = colorMatrix.get(x, y, min, vx, vy, center); + + style = wxBORDER_NONE; + if ((center) && (a < 0)) + { + style = wxBORDER_SIMPLE; + } + + deColorPanelOld* colorPanel = new deColorPanelOld(this, wxSize(ALL_TILES_SIZE / width, ALL_TILES_SIZE / height), style); + LABMapSizer->Add(colorPanel); + + if (a >= 0) + { + + deValue v1 = 0; + deValue v2 = 0; + deValue v3 = 0; + switch (channelHorizontal) + { + case 0: + v1 = vx; + break; + case 1: + { + v2 = vx; + break; + } + case 2: + v3 = vx; + break; + default: + break; + } + switch (channelVertical) + { + case 0: + v1 = vy; + break; + case 1: + v2 = vy; + break; + case 2: + v3 = vy; + break; + default: + break; + } + switch (channelAverage) + { + case 0: + v1 = a; + break; + case 1: + v2 = a; + break; + case 2: + v3 = a; + break; + default: + break; + } + + deValue r; + deValue g; + deValue b; + deValue z; + cp.convert(deColorSpaceLAB, v1, v2, v3, 0, deColorSpaceRGB, r, g, b, z); + colorPanel->setRGB(r, g, b); + } + else + { + } + + } + } + LABImage.finishRead(channelVertical); + LABImage.finishRead(channelHorizontal); + LABImage.finishRead(channelAverage); + Fit(); + + layerStack.finishReadLayer(view); +} + +deColorMatrixFrame2::~deColorMatrixFrame2() +{ +} + +#define LAB_TILES 20 + +deColorMatrixFrame::deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin) +:deHelpFrame(parent, "color matrix"), project(_project) +{ + wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(mainSizer); + + wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); + mainSizer->Add(notebook, 1, wxEXPAND); + + wxPanel* imagePanel = new wxPanel(notebook); + notebook->AddPage(imagePanel, _T("image")); + wxSizer* imageSizer = new wxBoxSizer(wxVERTICAL); + imagePanel->SetSizer(imageSizer); + + wxPanel* LABPanel = new wxPanel(notebook); + notebook->AddPage(LABPanel, _T("LAB")); + wxSizer* LABSizer = new wxBoxSizer(wxVERTICAL); + LABPanel->SetSizer(LABSizer); + + wxPanel* palettePanel = new wxPanel(notebook); + notebook->AddPage(palettePanel, _T("palette")); + wxSizer* paletteSizer = new wxBoxSizer(wxVERTICAL); + palettePanel->SetSizer(paletteSizer); + + palette = NULL; + palette2 = NULL; + paletteLAB = NULL; + + const deViewManager& viewManager = project.getViewManager(); + int view = viewManager.getView(); + + deLayerStack& layerStack = project.getLayerStack(); + + const deBaseLayer* layer = layerStack.startReadLayer(view); + + const deImage& image = layer->getLayerImage(); + deColorSpace colorSpace = image.getColorSpace(); + + deConversionProcessor cp; + + palette = new dePalette3(colorSpace); + paletteLAB = new dePalette3(deColorSpaceLAB); + + deSize channelSize = image.getChannelSize(); + + int cs = channelSize.getW(); + + int w = channelSize.getW() / tileW; + int h = channelSize.getH() / tileH; + + int n = w * h; + + int s = 2; + + wxSizer* sizer = new wxFlexGridSizer(w, s, s); + imageSizer->Add(sizer); + + int i; + + int y = 0; + int x = 0; + + for (i = 0; i < n; i++) + { + deColorPanelOld* colorPanel = new deColorPanelOld(imagePanel, wxSize(tileRW, tileRH), 0); + sizer->Add(colorPanel); + + int x1 = x * tileW; + int x2 = (x + 1) * tileW; + int y1 = y * tileH; + int y2 = (y + 1) * tileH; + + deValue sum1 = 0; + deValue sum2 = 0; + deValue sum3 = 0; + + deValue v1; + deValue v2; + deValue v3; + + int xx; + int yy; + const deValue* values1 = image.startRead(0); + const deValue* values2 = image.startRead(1); + const deValue* values3 = image.startRead(2); + + for (yy = y1; yy < y2; yy++) + { + int p = cs * yy + x1; + for (xx = x1; xx < x2; xx++) + { + v1 = values1[p]; + v2 = values2[p]; + v3 = values3[p]; + sum1 += v1; + sum2 += v2; + sum3 += v3; + p++; + } + } + + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + + int ts = tileW * tileH; + + sum1 /= ts; + sum2 /= ts; + sum3 /= ts; + deValue sum4 = 0; + + palette->addColor(deColor4(sum1, sum2, sum3, sum4)); + + deValue r; + deValue g; + deValue b; + + deValue z; + cp.convert(colorSpace, sum1, sum2, sum3, 0, deColorSpaceRGB, r, g, b, z); + + deValue L; + deValue A; + deValue B; + + cp.convert(colorSpace, sum1, sum2, sum3, 0, deColorSpaceLAB, L, A, B, z); + + paletteLAB->addColor(deColor4(L, A, B, 0)); + + colorPanel->setRGB(r, g, b); + + x++; + if (x == w) + { + x = 0; + y++; + } + } + + deValue minA; + deValue maxA; + paletteLAB->getMinMax(2, minA, maxA); + deValue minB; + deValue maxB; + paletteLAB->getMinMax(3, minB, maxB); + + deValue deltaA = maxA - minA; + deValue deltaB = maxB - minB; + deValue delta = deltaA; + if (deltaB > delta) + { + delta = deltaB; + } + + deValue step = delta / LAB_TILES; + + int tiles = deltaA / step + 1; + + wxSizer* LABMapSizer = new wxFlexGridSizer(tiles, s, s); + LABSizer->Add(LABMapSizer); + + deValue A; + deValue B; + deValue rB; + + + for (rB = minB; rB < maxB; rB += step) + { + B = maxB + minB - rB; + + for (A = minA; A < maxA; A += step) + { + deColorPanelOld* colorPanel = new deColorPanelOld(LABPanel, wxSize(LAB_TILE_SIZE, LAB_TILE_SIZE), 0); + LABMapSizer->Add(colorPanel); + + deValue L = 1.0; + + if (paletteLAB->find23(A, A + step, B, B + step, L)) + { + deValue r; + deValue g; + deValue b; + deValue z; + cp.convert(deColorSpaceLAB, L, A, B, 0, deColorSpaceRGB, r, g, b, z); + colorPanel->setRGB(r, g, b); + } + } + } + + palette2 = new dePalette3(colorSpace); + + palette2->optimize(*palette, palSize, margin); + + int s2 = 5; + + wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, palettePanel, _T("palette")); + paletteSizer->Add(sizerS); + + wxSizer* palSizer = new wxFlexGridSizer(palSize / 2, s2, s2); + sizerS->Add(palSizer); + + for (i = 0; i < palette2->getSize(); i++) + { + deColorPanelOld* colorPanel = new deColorPanelOld(palettePanel, wxSize(palW, palH), 0); + palSizer->Add(colorPanel); + + deValue r; + deValue g; + deValue b; + + deColor4 c = palette2->getColor(i); + + deValue z; + cp.convert(colorSpace, c.getV1(), c.getV2(), c.getV3(), 0, deColorSpaceRGB, r, g, b, z); + + colorPanel->setRGB(r, g, b); + } + + Fit(); + + layerStack.finishReadLayer(view); + +} + +deColorMatrixFrame::~deColorMatrixFrame() +{ + if (palette) + { + delete palette; + } + if (palette2) + { + delete palette2; + } + if (paletteLAB) + { + delete paletteLAB; + } +} + diff -Nru delaboratory-0.7/gui_wx/color_matrix_frame.h delaboratory-0.8/gui_wx/color_matrix_frame.h --- delaboratory-0.7/gui_wx/color_matrix_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/color_matrix_frame.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COLOR_MARTIX_FRAME6_H +#define _DE_COLOR_MATRIX_FRAME6_H + +#include "help_frame.h" +#include "palette.h" +class deProject; + +class deColorMatrixFrame:public deHelpFrame +{ + private: + deProject& project; + dePalette3* palette; + dePalette3* palette2; + dePalette3* paletteLAB; + public: + deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin); + virtual ~deColorMatrixFrame(); +}; + +class deColorMatrixFrame2:public deHelpFrame +{ + private: + public: + deColorMatrixFrame2(wxWindow *parent, deProject& _project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette); + virtual ~deColorMatrixFrame2(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/color_space_utils.cc delaboratory-0.8/gui_wx/color_space_utils.cc --- delaboratory-0.7/gui_wx/color_space_utils.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/color_space_utils.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,479 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "color_space_utils.h" +#include "channels.h" + +int getEqualizerChannel(deColorSpace colorSpace) +{ + switch (colorSpace) + { + case deColorSpaceBW: + return 0; + case deColorSpaceRGB: + return -1; + case deColorSpaceProPhoto: + return -1; + case deColorSpaceHSL: + return 0; + case deColorSpaceHSV: + return 0; + case deColorSpaceLAB: + return 0; + case deColorSpaceLCH: + return 2; + case deColorSpaceCMY: + return -1; + case deColorSpaceCMYK: + return 3; + default: + return 0; + } +} + +int getColorSpaceSize(const deColorSpace& colorSpace) +{ + switch (colorSpace) + { + case deColorSpaceBW: + return 1; + case deColorSpaceRGB: + return 3; + case deColorSpaceProPhoto: + return 3; + case deColorSpaceHSL: + return 3; + case deColorSpaceHSV: + return 3; + case deColorSpaceLAB: + return 3; + case deColorSpaceLCH: + return 3; + case deColorSpaceXYZ: + return 3; + case deColorSpaceCMY: + return 3; + case deColorSpaceCMYK: + return 4; + default: + return 0; + } +} + +void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max) +{ + min = 0; + max = 1; +} + +std::string getColorSpaceName(deColorSpace colorSpace) +{ + switch (colorSpace) + { + case deColorSpaceInvalid: + return "invalid"; + case deColorSpaceBW: + return "BW"; + case deColorSpaceRGB: + return "sRGB"; + case deColorSpaceProPhoto: + return "ProPhoto"; + case deColorSpaceHSL: + return "HSL"; + case deColorSpaceHSV: + return "HSV"; + case deColorSpaceLAB: + return "LAB"; + case deColorSpaceLCH: + return "LCH"; + case deColorSpaceXYZ: + return "XYZ"; + case deColorSpaceCMY: + return "CMY"; + case deColorSpaceCMYK: + return "CMYK"; + default: + return "unknown"; + } +} + +deColorSpace colorSpaceFromString(const std::string& name) +{ + if (name == "sRGB") + { + return deColorSpaceRGB; + } + if (name == "ProPhoto") + { + return deColorSpaceProPhoto; + } + if (name == "LAB") + { + return deColorSpaceLAB; + } + if (name == "LCH") + { + return deColorSpaceLCH; + } + if (name == "CMYK") + { + return deColorSpaceCMYK; + } + if (name == "HSL") + { + return deColorSpaceHSL; + } + if (name == "HSV") + { + return deColorSpaceHSV; + } + if (name == "BW") + { + return deColorSpaceBW; + } + if (name == "XYZ") + { + return deColorSpaceXYZ; + } + if (name == "CMY") + { + return deColorSpaceCMY; + } + + return deColorSpaceInvalid; +} + +std::string getChannelName(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceInvalid: + return "invalid"; + case deColorSpaceBW: + return "BW"; + case deColorSpaceRGB: + case deColorSpaceProPhoto: + { + switch (channel) + { + case DE_CHANNEL_RED: + return "red"; + case DE_CHANNEL_GREEN: + return "green"; + case DE_CHANNEL_BLUE: + return "blue"; + } + } + case deColorSpaceLAB: + switch (channel) + { + case DE_CHANNEL_L: + return "L"; + case DE_CHANNEL_A: + return "A"; + case DE_CHANNEL_B: + return "B"; + } + case deColorSpaceLCH: + switch (channel) + { + case DE_CHANNEL_L: + return "lightness"; + case DE_CHANNEL_C: + return "chroma"; + case DE_CHANNEL_H: + return "hue"; + } + case deColorSpaceXYZ: + switch (channel) + { + case DE_CHANNEL_X: + return "X"; + case DE_CHANNEL_Y: + return "Y"; + case DE_CHANNEL_Z: + return "Z"; + } + case deColorSpaceHSL: + switch (channel) + { + case DE_CHANNEL_HUE: + return "hue"; + case DE_CHANNEL_SATURATION: + return "saturation"; + case DE_CHANNEL_LIGHTNESS: + return "lightness"; + } + case deColorSpaceHSV: + switch (channel) + { + case DE_CHANNEL_HUE: + return "hue"; + case DE_CHANNEL_SATURATION: + return "saturation"; + case DE_CHANNEL_VALUE: + return "value"; + } + case deColorSpaceCMY: + case deColorSpaceCMYK: + switch (channel) + { + case DE_CHANNEL_CYAN: + return "cyan"; + case DE_CHANNEL_MAGENTA: + return "magenta"; + case DE_CHANNEL_YELLOW: + return "yellow"; + case DE_CHANNEL_KEY: + return "key"; + } + default: + return "unknown"; + } +} + +void getSupportedColorSpaces(std::vector& result) +{ + result.push_back(deColorSpaceRGB); + result.push_back(deColorSpaceProPhoto); + result.push_back(deColorSpaceBW); + result.push_back(deColorSpaceLAB); + result.push_back(deColorSpaceLCH); + result.push_back(deColorSpaceHSL); + result.push_back(deColorSpaceHSV); + result.push_back(deColorSpaceCMYK); +} + +deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v) +{ + if (colorSpace == deColorSpaceLAB) + { + if (channel == DE_CHANNEL_L) + { + return 100 * v; + } + else + { + return 200 * v - 100.0; + } + } + if (colorSpace == deColorSpaceRGB) + { + return 255 * v; + } + if (colorSpace == deColorSpaceProPhoto) + { + return 255 * v; + } + if ((colorSpace == deColorSpaceCMYK) || (colorSpace == deColorSpaceCMY)) + { + return 100 * v; + } + if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) + { + if (channel == DE_CHANNEL_HUE) + { + return 360 * v; + } + else + { + return 100 * v; + } + } + if (colorSpace == deColorSpaceLCH) + { + if (channel == DE_CHANNEL_H) + { + return 360 * v; + } + else + { + return 100 * v; + } + } + return v; +} + +bool shouldUseAutoLevels(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceLCH: + { + if (channel == 2) + { + return false; + } + break; + } + case deColorSpaceHSV: + case deColorSpaceHSL: + { + if (channel == 0) + { + return false; + } + break; + } + case deColorSpaceCMYK: + { + if (channel == 3) + { + return false; + } + break; + } + default: + { + break; + } + } + + return true; +} + +bool shouldChannelBeSharpened(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceLAB: + case deColorSpaceLCH: + { + if (channel == 0) + { + return true; + } + break; + } + case deColorSpaceHSV: + case deColorSpaceHSL: + { + if (channel == 2) + { + return true; + } + break; + } + case deColorSpaceCMYK: + { + if (channel == 3) + { + return true; + } + break; + } + default: + { + return true; + break; + } + } + + return false; +} + +bool isChannelLuminance(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceLAB: + case deColorSpaceLCH: + { + if (channel == 0) + { + return true; + } + break; + } + case deColorSpaceHSV: + case deColorSpaceHSL: + { + if (channel == 2) + { + return true; + } + break; + } + default: + { + return true; + break; + } + } + + return false; +} + +bool isChannelWrapped(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceLCH: + { + if (channel == 2) + { + return true; + } + break; + } + case deColorSpaceHSV: + case deColorSpaceHSL: + { + if (channel == 0) + { + return true; + } + break; + } + default: + break; + } + + return false; +} + +bool isActionSupported(const std::string& action, deColorSpace colorSpace) +{ + if ((action == "equalizer8") || (action == "equalizer16")) + { + switch (colorSpace) + { + case deColorSpaceRGB: + case deColorSpaceCMY: + case deColorSpaceProPhoto: + return false; + default: + return true; + } + } + return true; +} + +std::vector getChannelNames(deColorSpace colorSpace) +{ + std::vector result; + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + std::string s = getChannelName(colorSpace, i); + result.push_back(s); + } + + return result; +} diff -Nru delaboratory-0.7/gui_wx/color_space_utils.h delaboratory-0.8/gui_wx/color_space_utils.h --- delaboratory-0.7/gui_wx/color_space_utils.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/color_space_utils.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,50 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COLOR_SPACE_UTILS_H +#define _DE_COLOR_SPACE_UTILS_H + +#include "color_space.h" +#include "value.h" +#include +#include + +int getColorSpaceSize(const deColorSpace& colorSpace); +void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max); +std::string getColorSpaceName(deColorSpace colorSpace); +std::string getChannelName(deColorSpace colorSpace, int channel); +deColorSpace colorSpaceFromString(const std::string& name); + +void getSupportedColorSpaces(std::vector& result); +void getSupportedConversions(const deColorSpace& colorSpace, std::vector& result); + +deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v); + +bool isChannelLuminance(deColorSpace colorSpace, int channel); +bool shouldChannelBeSharpened(deColorSpace colorSpace, int channel); + +int getEqualizerChannel(deColorSpace colorSpace); +bool isChannelWrapped(deColorSpace colorSpace, int channel); + +bool isActionSupported(const std::string& action, deColorSpace colorSpace); + +bool shouldUseAutoLevels(deColorSpace colorSpace, int channel); + +std::vector getChannelNames(deColorSpace colorSpace); + +#endif diff -Nru delaboratory-0.7/gui_wx/control_panel.cc delaboratory-0.8/gui_wx/control_panel.cc --- delaboratory-0.7/gui_wx/control_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/control_panel.cc 2012-07-26 00:29:19.000000000 +0000 @@ -0,0 +1,183 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "control_panel.h" +#include "project.h" +#include "base_layer.h" +#include "layer_factory.h" +#include "file_dialogs.h" +#include "layer_processor.h" +#include "wx/notebook.h" +#include "layer_stack.h" +#include "layer_frame_manager.h" +#include "color_space_utils.h" +#include "operation_processor.h" + +const int g_txt = 220; + +deControlPanel::deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deOperationProcessor& _operationProcessor, deChannelManager& _channelManager) +:wxPanel(parent), project(_project), layerProcessor(_processor), operationProcessor(_operationProcessor), channelManager(_channelManager) +{ + mainSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(mainSizer); + + int bw2 = 140; + int bw3 = 90; + int bh = 32; + + wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); + mainSizer->Add(notebook, 1, wxEXPAND); + + { + wxPanel* basicPanel = new wxPanel(notebook); + notebook->AddPage(basicPanel, _T("colors")); + + std::vector operations; + getSupportedColorsOperations(operations); + + wxSizer* gridSizer = new wxGridSizer(2); + basicPanel->SetSizer(gridSizer); + + std::vector::iterator j; + for (j = operations.begin(); j != operations.end(); j++) + { + std::string d = *j; + wxButton* b = new wxButton(basicPanel, wxID_ANY, wxString::FromAscii(d.c_str()), wxDefaultPosition, wxSize(bw2,bh)); + gridSizer->Add(b); + actionButtons.push_back(b); + actionButtonsNames[b->GetId()] = *j; + } + } + { + wxPanel* basicPanel = new wxPanel(notebook); + notebook->AddPage(basicPanel, _T("other")); + + std::vector operations; + getSupportedOtherOperations(operations); + + wxSizer* gridSizer = new wxGridSizer(2); + basicPanel->SetSizer(gridSizer); + + std::vector::iterator j; + for (j = operations.begin(); j != operations.end(); j++) + { + std::string d = *j; + wxButton* b = new wxButton(basicPanel, wxID_ANY, wxString::FromAscii(d.c_str()), wxDefaultPosition, wxSize(bw2,bh)); + gridSizer->Add(b); + actionButtons.push_back(b); + actionButtonsNames[b->GetId()] = *j; + } + + } + + { + std::vector actions; + getSupportedActions(actions); + + wxPanel* actionsPanel = new wxPanel(notebook); + notebook->AddPage(actionsPanel, _T("expert")); + + wxSizer* gridSizer = new wxGridSizer(3); + actionsPanel->SetSizer(gridSizer); + + std::vector::iterator j; + for (j = actions.begin(); j != actions.end(); j++) + { + std::string actionDescription = getActionDescription(*j); + wxButton* b = new wxButton(actionsPanel, wxID_ANY, wxString::FromAscii(actionDescription.c_str()), wxDefaultPosition, wxSize(bw3,bh)); + gridSizer->Add(b); + actionButtons.push_back(b); + actionButtonsNames[b->GetId()] = *j; + } + + } + + { + wxPanel* conversionsPanel = new wxPanel(notebook); + notebook->AddPage(conversionsPanel, _T("colorspace")); + + std::vector colorSpaces; + getSupportedColorSpaces(colorSpaces); + + wxSizer* gridSizer = new wxGridSizer(3); + conversionsPanel->SetSizer(gridSizer); + + std::vector::iterator i; + for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) + { + std::string n = getColorSpaceName(*i); + wxButton* b = new wxButton(conversionsPanel, wxID_ANY, wxString::FromAscii(n.c_str()), wxDefaultPosition, wxSize(bw3,bh)); + gridSizer->Add(b); + convertButtons.push_back(b); + convertButtonsColorSpaces[b->GetId()] = *i; + } + } + + + wxSizer* hSizer = new wxBoxSizer(wxHORIZONTAL); + mainSizer->Add(hSizer, 0, wxCENTER); + + wxSizer* sizerD = new wxStaticBoxSizer(wxVERTICAL, this, _T("delete")); + hSizer->Add(sizerD, 1, wxCENTER); + { + deleteLayer = new wxButton(this, wxID_ANY, _T("delete top layer")); + sizerD->Add(deleteLayer, 0, wxCENTER); + } + + Layout(); + Fit(); + + Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deControlPanel::click)); +} + +deControlPanel::~deControlPanel() +{ +} + +void deControlPanel::click(wxCommandEvent &event) +{ + int id = event.GetId(); + + if (deleteLayer->GetId() == id) + { + logInfo("delete layer clicked"); + deLayerStack& layerStack = project.getLayerStack(); + int index = layerStack.getSize() - 1; + project.getLayerFrameManager().onDestroyLayer(index); + operationProcessor.execute("remove"); + } + + std::map::iterator c = convertButtonsColorSpaces.find(id); + if (c != convertButtonsColorSpaces.end()) + { + deColorSpace colorSpace = c->second; + + operationProcessor.execute(getColorSpaceName(colorSpace)); + } + + std::map::iterator a = actionButtonsNames.find(id); + if (a != actionButtonsNames.end()) + { + std::string action = a->second; + + operationProcessor.execute(action); + } + +} + + diff -Nru delaboratory-0.7/gui_wx/control_panel.h delaboratory-0.8/gui_wx/control_panel.h --- delaboratory-0.7/gui_wx/control_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/control_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,65 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CONTROL_PANEL_H +#define _DE_CONTROL_PANEL_H + +#include +#include +#include +#include "color_space.h" +class deProject; +class deLayerProcessor; +class deOperationProcessor; +class deChannelManager; + +class deControlPanel:public wxPanel +{ + private: + deProject& project; + deLayerProcessor& layerProcessor; + deOperationProcessor& operationProcessor; + wxSizer* mainSizer; + + wxButton* exportSingle; + wxButton* exportAll; + wxButton* externalEditor; + + std::map convertButtonsColorSpaces; + std::vector convertButtons; + + std::map actionButtonsNames; + std::vector actionButtons; + + deChannelManager& channelManager; + + wxButton* deleteLayer; + + void click(wxCommandEvent &event); + + //bool generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir); + + public: + deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deOperationProcessor& _operationProcessor, deChannelManager& _channelManager); + ~deControlPanel(); + + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/curves_panel.cc delaboratory-0.8/gui_wx/curves_panel.cc --- delaboratory-0.7/gui_wx/curves_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/curves_panel.cc 2012-07-29 13:15:59.000000000 +0000 @@ -0,0 +1,460 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curves_panel.h" +#include +#include "curves_layer.h" +#include "layer_processor.h" +#include "logger.h" +#include "channels.h" +#include "color_space_utils.h" +#include "channel_manager.h" +#include "property_curves.h" +#include "str.h" +#include "str_wx.h" + +wxColour getChannelwxColour(deColorSpace colorSpace, int channel) +{ + switch (colorSpace) + { + case deColorSpaceRGB: + case deColorSpaceProPhoto: + { + int g = 200; + switch (channel) + { + case DE_CHANNEL_RED: + return wxColour(g, 0, 0); + case DE_CHANNEL_GREEN: + return wxColour(0, g, 0); + case DE_CHANNEL_BLUE: + return wxColour(0, 0, g); + } + } + case deColorSpaceCMYK: + case deColorSpaceCMY: + { + int g = 240; + int g2 = 100; + switch (channel) + { + case DE_CHANNEL_CYAN: + return wxColour(0, g, g); + case DE_CHANNEL_MAGENTA: + return wxColour(g, 0, g); + case DE_CHANNEL_YELLOW: + return wxColour(g, g, 0); + case DE_CHANNEL_KEY: + return wxColour(g2, g2, g2); + } + } + default: + { + // in any other cases just use dark gray + int g = 50; + return wxColour(g, g, g); + } + } + +} + + +BEGIN_EVENT_TABLE(deCurvesPanel, wxPanel) +EVT_PAINT(deCurvesPanel::paintEvent) +END_EVENT_TABLE() + +deCurvesPanel::deCurvesPanel(wxWindow* parent, deLayerProcessor& _layerProcessor, int _layerIndex, dePropertyCurves& _property, deColorSpace _colorSpace, wxStaticText* _infoEntry) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(CURVES_PANEL_SIZE_X, CURVES_PANEL_SIZE_Y)), +sizeX(CURVES_PANEL_SIZE_X), sizeY(CURVES_PANEL_SIZE_Y), +layerProcessor(_layerProcessor), layerIndex(_layerIndex), property(_property), colorSpace(_colorSpace), infoEntry(_infoEntry) +{ + SetFocus(); + Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deCurvesPanel::click)); + Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deCurvesPanel::release)); + Connect(wxEVT_MOTION, wxMouseEventHandler(deCurvesPanel::move)); + channel = 0; + selectedPoint = -1; + lastSelectedPoint = -1; + marker = -1; + + backgroundBitmap = NULL; + clickPosition = -1; + + bitmap.Create(CURVES_PANEL_SIZE_X, CURVES_PANEL_SIZE_Y); + +} + +deCurvesPanel::~deCurvesPanel() +{ + delete backgroundBitmap; +} + +void deCurvesPanel::generateBackground(const deValue* c, int n) +{ + if (backgroundBitmap) + { + delete backgroundBitmap; + } + + deHistogram histogram(CURVES_PANEL_SIZE_X); + + histogram.clear(); + histogram.calc(c, n); + + wxImage* image = new wxImage(sizeX, sizeY); + unsigned char* data = image->GetData(); + + unsigned char g1 = 255; + unsigned char g2 = 200; + wxColour colour = getChannelwxColour(colorSpace, channel); + + int margin = 0; + + histogram.render(data, sizeX, sizeY, g1, g2, margin); + + backgroundBitmap = new wxBitmap(*image); + delete image; +} + + +void deCurvesPanel::render(wxDC& dc_orig) +{ + wxBufferedDC dc(&dc_orig, bitmap, wxBUFFER_CLIENT_AREA); + + int g = 50; + wxColour colourB(g, g, g); + wxBrush brush(colourB); + + if (backgroundBitmap) + { + dc.DrawBitmap(*backgroundBitmap, 0, 0, false); + } + else + { + dc.Clear(); + } + + drawLines(dc); + + wxColour colour = getChannelwxColour(colorSpace, channel); + wxPen pen(colour); + dc.SetPen(pen); + + drawCurve(dc); +} + +void deCurvesPanel::drawPoint(wxDC& dc, deValue x, deValue y) +{ + int xx = (sizeX - 1) * x; + int yy = (sizeY - 1) * (1 - y); + dc.DrawCircle(xx, yy, 5); +} + + +void deCurvesPanel::drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2) +{ + int xx1 = (sizeX - 1) * x1; + int xx2 = (sizeX - 1) * x2; + int yy1 = (sizeY - 1) * (1 - y1); + int yy2 = (sizeY - 1) * (1 - y2); + dc.DrawLine(xx1, yy1, xx2, yy2); +} + +void deCurvesPanel::drawLines(wxDC& dc) +{ + int g1 = 180; + int g2 = 80; + + wxPen pen1(wxColour(g1, g1, g1)); + wxPen pen2(wxColour(g2, g2, g2)); + + dc.SetPen(pen1); + + float y; + for (y = 0.0; y <= 1.0; y += (1/8.0)) + { + drawLine(dc, 0.0, y, 1.0, y); + } + + float x; + for (x = 0.0; x <= 1.0; x += (1/8.0)) + { + drawLine(dc, x, 0.0, x, 1.0); + } + + dc.SetPen(pen2); + + if (marker >= 0) + { + drawLine(dc, 0.0, marker, 1.0, marker); + drawLine(dc, marker, 0.0, marker, 1.0); + } +} + +void deCurvesPanel::drawCurve(wxDC& dc) +{ + deBaseCurve* curve = property.getCurve(channel); + + if (!curve) + { + return; + } + + int i; + deValue lastY = 0.0; + deValue lastX = 0.0; + for (i = 0; i < sizeX; i++) + { + deValue x = (deValue) i / (sizeX - 1.0); + deValue y = curve->calcValue(x); + if (i > 0) + { + drawLine(dc, lastX, lastY, x, y); + } + lastY = y; + lastX = x; + } + + const deCurvePoints& controlPoints = curve->getControlPoints(); + deCurvePoints::const_iterator j; + + int index = 0; + for (j = controlPoints.begin(); j != controlPoints.end(); j++) + { + const deCurvePoint& point = *j; + deValue x = point.getX(); + deValue y = point.getY(); + drawPoint(dc, x, y); + index++; + } +} + +void deCurvesPanel::click(wxMouseEvent &event) +{ + deBaseCurve* curve = property.getCurve(channel); + + if (!curve) + { + return; + } + + selectedPoint = -1; + + deValue x; + deValue y; + getPosition(event, x, y); + + setInfo(x,y); + + int n = curve->findPoint(x, y); + + if (n >= 0) + { + selectedPoint = n; + } + else + { + selectedPoint = curve->addPoint(x, y); + curve->build(); + } + + lastSelectedPoint = selectedPoint; + + const deCurvePoint& point = curve->getPoint(selectedPoint); + grabX = point.getX() - x; + grabY = point.getY() - y; + + update(false); +} + +void deCurvesPanel::update(bool finished) +{ + paint(); + layerProcessor.markUpdateSingleChannel(layerIndex, channel); +} + +void deCurvesPanel::release(wxMouseEvent &event) +{ + if (selectedPoint) + { + deValue x; + deValue y; + getPosition(event, x, y); + if ((x < -0.1) || (y < -0.1) || (x>1.1) || (y>1.1)) + { + removeSelectedPoint(); + return; + } + } + + selectedPoint = -1; + + update(true); + +} + +bool deCurvesPanel::removeSelectedPoint() +{ + deBaseCurve* curve = property.getCurve(channel); + + if (!curve) + { + logError("no curve in remove selected point"); + return false;; + } + + if (selectedPoint < 0) + { + selectedPoint = lastSelectedPoint; + } + + if (selectedPoint >= 0) + { + curve->deletePoint(selectedPoint); + curve->build(); + lastSelectedPoint = -1; + selectedPoint = -1; + update(true); + + return true; + } + + return false; +} + +void deCurvesPanel::move(wxMouseEvent &event) +{ + if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT)) + { + selectedPoint = -1; + return; + } + + deBaseCurve* curve = property.getCurve(channel); + + if (!curve) + { + return; + } + + if (selectedPoint >= 0) + { + deValue x; + deValue y; + getPosition(event, x, y); + + x+= grabX; + y+= grabY; + + if (x < 0) + { + x = 0; + } + if (y < 0) + { + y = 0; + } + if (x > 1) + { + x = 1; + } + if (y > 1) + { + y = 1; + } + + curve->movePoint(selectedPoint, x, y); + setInfo(x,y); + curve->build(); + update(false); + } +} + +void deCurvesPanel::getPosition(wxMouseEvent &event, deValue& x, deValue &y) +{ + deValue dX = 1.0 / (sizeX - 1); + deValue dY = 1.0 / (sizeY - 1); + x = event.GetX() * dX; + y = 1 - (event.GetY() * dY); +} + +void deCurvesPanel::paint() +{ + wxClientDC dc(this); + + render(dc); +} + +void deCurvesPanel::paintEvent(wxPaintEvent & evt) +{ + wxPaintDC dc(this); + + render(dc); +} + + +void deCurvesPanel::changeChannel(int _channel) +{ + logInfo("curves panel change channel start"); + layerProcessor.lockLayerProcessor(); + channel = _channel; + layerProcessor.unlockLayerProcessor(); + + layerProcessor.setHistogramChannel(channel); + paint(); + + logInfo("curves panel change channel DONE"); +} + +void deCurvesPanel::onImageClick(deValue x, deValue y, const deValue* c, const deSize& size) +{ + if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) + { + return; + } + clickPosition = (y * size.getH() ) * size.getW() + (x * size.getW()); + setMarker(c, size.getN()); + paint(); +} + +void deCurvesPanel::setMarker(const deValue* c, int n) +{ + if ((clickPosition < 0) || (clickPosition > n)) + { + marker = -1; + } + else + { + marker = c[clickPosition]; + } + paint(); +} + +int deCurvesPanel::getClickPosition() const +{ + return clickPosition; +} + +void deCurvesPanel::setInfo(deValue x, deValue y) +{ + if (infoEntry) + { + std::string s = str(getPresentationValue(colorSpace, channel, x)) + " " + str(getPresentationValue(colorSpace, channel, y)); + infoEntry->SetLabel(str2wx(s)); + } +} diff -Nru delaboratory-0.7/gui_wx/curves_panel.h delaboratory-0.8/gui_wx/curves_panel.h --- delaboratory-0.7/gui_wx/curves_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/curves_panel.h 2012-07-15 07:47:57.000000000 +0000 @@ -0,0 +1,103 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVES_PANEL_H +#define _DE_CURVES_PANEL_H + +#define CURVES_PANEL_SIZE_X 384 +#define CURVES_PANEL_SIZE_Y 256 + +#include "wx/wx.h" +class deCurvesLayer; +class deLayerProcessor; +class deChannelManager; +class deCanvas; +class dePropertyCurves; +#include "value.h" +#include "histogram.h" +#include "color_space.h" +#include "size.h" + +class deCurvesPanel:public wxPanel +{ +private: + wxBitmap bitmap; + wxBitmap* backgroundBitmap; + int sizeX; + int sizeY; + int channel; + + bool realtime; + + void drawPoint(wxDC& dc, deValue x, deValue y); + void drawCurve(wxDC& dc); + + void click(wxMouseEvent &event); + void release(wxMouseEvent &event); + void move(wxMouseEvent &event); + void update(bool finished); + + int selectedPoint; + int lastSelectedPoint; + + deValue grabX; + deValue grabY; + + void getPosition(wxMouseEvent &event, deValue& x, deValue &y); + void setInfo(deValue x, deValue y); + + deValue marker; + + int clickPosition; + + deLayerProcessor& layerProcessor; + + int layerIndex; + + dePropertyCurves& property; + + deColorSpace colorSpace; + + wxStaticText* infoEntry; + + void drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2); + void drawLines(wxDC& dc); + +public: + deCurvesPanel(wxWindow* parent, deLayerProcessor& _layerProcessor, int _layerIndex, dePropertyCurves& _property, deColorSpace _colorSpace, wxStaticText* _infoEntry); + ~deCurvesPanel(); + + void paintEvent(wxPaintEvent & evt); + void render(wxDC& dc); + void paint(); + + void changeChannel(int _channel); + void onImageClick(deValue x, deValue y, const deValue* c, const deSize& size); + + void setMarker(const deValue* c, int n); + + void generateBackground(const deValue* c, int n); + int getClickPosition() const; + + bool removeSelectedPoint(); + + DECLARE_EVENT_TABLE() + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/dcraw_support.cc delaboratory-0.8/gui_wx/dcraw_support.cc --- delaboratory-0.7/gui_wx/dcraw_support.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/dcraw_support.cc 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,423 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "dcraw_support.h" +#include +#include +#include +#include "logger.h" +#include "str.h" +#include "str_wx.h" +#include "size.h" +#include "static_image.h" + +#define DCRAW_EXECUTABLE "dcraw" + +std::string getDcrawVersion() +{ + const char* com = DCRAW_EXECUTABLE; + wxString s(com, wxConvUTF8); + + wxProcess* process = wxProcess::Open(s); + + wxInputStream* input = process->GetInputStream(); + + std::string vs = ""; + + int counter = 0; + + char c = ' '; + char c2 = ' '; + + do + { + c2 = c; + c = input->GetC(); + counter++; + if (counter > 40) + { + return ""; + } + } + while ((c2 != ' ') || (c != 'v')); + + do + { + c = input->GetC(); + if (c != '\n') + { + vs += c; + } + } + while (c != '\n'); + + return vs; +} + +bool isRawValid(const std::string& f) +{ + std::string command = std::string(DCRAW_EXECUTABLE) + " -i -v \"" + f + "\""; + logInfo("calling: " + command); + + const char* c = command.c_str(); + wxString s(c, wxConvUTF8); + + int result = wxExecute(s, wxEXEC_SYNC); + logInfo("result: " + str(result)); + + return (result == 0); +} + +std::string getRawInfo(const std::string& f) +{ + std::string command = std::string(DCRAW_EXECUTABLE) + " -i -v \"" + f + "\""; + logInfo("calling: " + command); + + const char* c = command.c_str(); + wxString s(c, wxConvUTF8); + + wxProcess* process = wxProcess::Open(s); + + wxInputStream* input = process->GetInputStream(); + + std::string result; + + bool finished = false; + logInfo("before input reading..."); + while (!finished) + { + unsigned char c = input->GetC(); + if (!input->Eof()) + { + result+= c; + } + else + { + finished = true; + } + } + logInfo("after input reading..."); + + logInfo("raw info: " + result); + + return result; +} + +deRawLoader::deRawLoader(const std::string& f, deStaticImage& _image, bool _half, bool srgb, bool brighten) +:filename(f), image(_image), half(_half) +{ + logInfo("deRawLoader constructor"); + + std::string options = "-w -c -6"; + if (!srgb) + { + options += " -o 4"; + colorSpace = deColorSpaceProPhoto; + } + else + { + colorSpace = deColorSpaceRGB; + } + if (!brighten) + { + options += " -W"; + } + if (half) + { + options += " -h"; + } + else + { + options += " -q 3"; + } + + std::string command = std::string(DCRAW_EXECUTABLE) + " " + options + " \"" + f + "\" >abc "; + logInfo("calling: " + command); + + const char* c = command.c_str(); + wxString s(c, wxConvUTF8); + + process = wxProcess::Open(s); + + input = process->GetInputStream(); +} + +deRawLoader::~deRawLoader() +{ + logInfo("deRawLoader destructor"); +} + + +bool deRawLoader::load(bool& failure) +{ + if (!input->CanRead()) + { + logInfo("deRawLoader load - can't read yet"); + return false; + } + + logInfo("deRawLoader::load() - CanRead"); + + char c1 = input->GetC(); + char c2 = input->GetC(); + + if (c1 != 'P') + { + logError("first character not P"); + failure = true; + return false; + } + if (c2 != '6') + { + logError("second character not 6"); + failure = true; + return false; + } + + logInfo("P6 loaded"); + + char c; + + std::string ws = ""; + do + { + c = input->GetC(); + if (c != ' ') + ws += c; + } + while (c != ' '); + + int w = getInt(ws); + if (w <= 0) + { + logError("width 0"); + failure = true; + return false; + } + + std::string hs = ""; + do + { + c = input->GetC(); + if (c != '\n') + hs += c; + } + while (c != '\n'); + + int h = getInt(hs); + if (h <= 0) + { + logError("height 0"); + failure = true; + return false; + } + + std::string ms = ""; + do + { + c = input->GetC(); + if (c != '\n') + ms += c; + } + while (c != '\n'); + + + int max = getInt(ms); + if (max <= 256) + { + logError("max <= 256"); + failure = true; + return false; + } + + logInfo("w: " + str(w) + " h: " + str(h) + " max: " + str(max)); + + if (half) + { + w *= 2; + h *= 2; + logInfo("after half w: " + str(w) + " h: " + str(h) + " max: " + str(max)); + } + + image.lock(); + + + deSize size(w, h); + image.setSize(size); + + deValue* pixels0 = image.startWriteStatic(0); + deValue* pixels1 = image.startWriteStatic(1); + deValue* pixels2 = image.startWriteStatic(2); + + deValue scale = 1.0 / max; + + int pos = 0; + + unsigned char cc1; + unsigned char cc2; + + char* buffer; + + int bufsize=500000; + + logInfo("allocating buffer of size " + str(bufsize)); + + buffer = new char[bufsize]; + + int n = w * h; + + if (half) + { + n /= 4; + } + + int offset = 0; + + int steps = 0; + + int maxRead = 0; + + image.setColorSpace(colorSpace); + + int tx = 0; + int ty = 0; + + logInfo("start loading PPM data"); + + while ((pos < n) && (!input->Eof())) + { + steps++; + + input->Read(buffer + offset, bufsize - offset); + + int r = input->LastRead(); + if (r > maxRead) + { + maxRead = r; + } + + r += offset; + + int p = 0; + while (p + 6 <= r) + { + deValue r; + deValue g; + deValue b; + + c = buffer[p]; + p++; + cc1 = (unsigned char)(c); + c = buffer[p]; + p++; + cc2 = (unsigned char)(c); + r = (256 * cc1 + cc2) * scale; + + c = buffer[p]; + p++; + cc1 = (unsigned char)(c); + c = buffer[p]; + p++; + cc2 = (unsigned char)(c); + g = (256 * cc1 + cc2) * scale; + + c = buffer[p]; + p++; + cc1 = (unsigned char)(c); + c = buffer[p]; + p++; + cc2 = (unsigned char)(c); + b = (256 * cc1 + cc2) * scale; + + if (half) + { + pixels0[(2 * ty + 0) * w + 2 * tx + 0] = r; + pixels0[(2 * ty + 1) * w + 2 * tx + 0] = r; + pixels0[(2 * ty + 0) * w + 2 * tx + 1] = r; + pixels0[(2 * ty + 1) * w + 2 * tx + 1] = r; + + pixels1[(2 * ty + 0) * w + 2 * tx + 0] = g; + pixels1[(2 * ty + 1) * w + 2 * tx + 0] = g; + pixels1[(2 * ty + 0) * w + 2 * tx + 1] = g; + pixels1[(2 * ty + 1) * w + 2 * tx + 1] = g; + + pixels2[(2 * ty + 0) * w + 2 * tx + 0] = b; + pixels2[(2 * ty + 1) * w + 2 * tx + 0] = b; + pixels2[(2 * ty + 0) * w + 2 * tx + 1] = b; + pixels2[(2 * ty + 1) * w + 2 * tx + 1] = b; + + tx++; + if (tx >= w / 2) + { + tx = 0; + ty++; + } + } + else + { + pixels0[pos] = r; + pixels1[pos] = g; + pixels2[pos] = b; + } + + pos++; + } + + int left = r - p; + int i; + for (i = 0; i < left; i++) + { + buffer[i] = buffer[p + i]; + } + offset = left; + + } + + image.finishWriteStatic(0); + image.finishWriteStatic(1); + image.finishWriteStatic(2); + + logInfo("pos: " + str(pos) + " n: " + str(n) + " steps: " + str(steps) + " maxRead: " + str(maxRead)); + if (input->Eof()) + { + logInfo("input stream EOF"); + } + + logInfo("deallocating buffer"); + delete [] buffer; + + + image.unlock(); + + + logInfo("loading ppm done"); + return true; +} + +bool deRawLoader::getStatus() +{ + if (!process) + { + return false; + } + if (!input) + { + return false; + } + return true; +} diff -Nru delaboratory-0.7/gui_wx/dcraw_support.h delaboratory-0.8/gui_wx/dcraw_support.h --- delaboratory-0.7/gui_wx/dcraw_support.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/dcraw_support.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,51 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_DCRAW_SUPPORT_H +#define _DE_DCRAW_SUPPORT_H + +#include +class deStaticImage; +#include "color_space.h" + +std::string getDcrawVersion(); +std::string getRawInfo(const std::string& f); +bool isRawValid(const std::string& f); +class wxProcess; +class wxInputStream; + +class deRawLoader +{ + private: + wxProcess* process; + wxInputStream* input; + const std::string& filename; + deStaticImage& image; + deColorSpace colorSpace; + bool half; + public: + + deRawLoader(const std::string& f, deStaticImage& image, bool half, bool srgb, bool brighten); + virtual ~deRawLoader(); + + bool load(bool& failure); + bool getStatus(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/delaboratory.cc delaboratory-0.8/gui_wx/delaboratory.cc --- delaboratory-0.7/gui_wx/delaboratory.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/delaboratory.cc 2012-07-28 22:06:31.000000000 +0000 @@ -0,0 +1,203 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + + +#include "wx/wx.h" +#include "project.h" +#include "str.h" +#include "str_wx.h" +#include "layer_processor.h" +#include "logger.h" +#include "channel_manager.h" +#include "layer_stack.h" +#include "layer_frame_manager.h" +#include "static_image.h" +#include "raw_module.h" +#include "zoom_manager.h" +#include "operation_processor.h" +#include "main_window.h" +#include "gui.h" +#include "wx/stdpaths.h" + +const std::string LOG_FILE_NAME = "debug.log"; +const std::string LOG_LOCKS_FILE_NAME = "locks.log"; + +class deInitLogger +{ + private: + wxString message; + + public: + deInitLogger() + { +// std::string ucd = getUserConfigDir(); + std::string ucd = getUserDataDir(); + wxString ucd_wx = str2wx(ucd); + + if (wxDirExists(ucd_wx)) + { + message = _T(""); + } + else + { + if (wxMkdir(ucd_wx)) + { + message = _T("created user config dir ") + ucd_wx; + } + else + { + message = _T("unable to create user config dir ") + ucd_wx; + } + } + + deLogger::getLogger().setFile(ucd + "/" + LOG_FILE_NAME); + } + + wxString getMessage() + { + return message; + } +}; + + +class deLaboratory: public wxApp +{ + public: + deLaboratory() + :wxApp(), + sourceImage(), + processor(previewChannelManager, layerStack, layerFrameManager, mainWindow), + project(processor, previewChannelManager, layerStack, layerFrameManager, sourceImage, rawModule, zoomManager, mainWindow, gui), + operationProcessor(processor, project) + { + logInfo("deLaboratory constructor"); + + } + + ~deLaboratory() + { + logInfo("deLaboratory destructor"); + } + + private: + virtual bool OnInit(); + virtual int OnExit(); + deInitLogger initLogger; + deMainWindow mainWindow; + deSamplerManager samplerManager; + deLayerStack layerStack; + deLayerFrameManager layerFrameManager; + deChannelManager previewChannelManager; + deStaticImage sourceImage; + deLayerProcessor processor; + deRawModule rawModule; + deZoomManager zoomManager; + deGUI gui; + deProject project; + deOperationProcessor operationProcessor; + + virtual int FilterEvent(wxEvent& event); + +}; + + +IMPLEMENT_APP(deLaboratory) + +int deLaboratory::FilterEvent(wxEvent& event) +{ + if (event.GetEventType()==wxEVT_KEY_DOWN ) + { + int key = ((wxKeyEvent&)event).GetKeyCode(); + + project.onKey(key); + mainWindow.onKey(key); + return true; + } + + return -1; +} + + +int deLaboratory::OnExit() +{ + logInfo("OnExit"); + return 0; +} + +bool deLaboratory::OnInit() +{ + logInfo("deLaboratory::OnInit"); + + rawModule.onInit(); + + std::string dcraw_version = rawModule.getVersion(); + + if (dcraw_version == "") + { + dcraw_version = "dcraw not found"; + } + else + { + dcraw_version = "dcraw version " + dcraw_version; + } + + wxInitAllImageHandlers(); + + int width = 1200; + int height = 960; + + mainWindow.init( width, height, project, processor, samplerManager, zoomManager, dcraw_version, operationProcessor, previewChannelManager, gui); + + logInfo("show main frame"); + + mainWindow.show(); + + logInfo("set top level"); + + mainWindow.setTopWindow(); + + logInfo("startWorkerThread..."); + + wxString ws = initLogger.getMessage(); + if (ws.size() > 0) + { + wxMessageBox(ws); + } + + processor.startWorkerThread(); + + logInfo("process argc/argv..."); + + if (argc > 1) + { + wxString a = argv[1]; + project.init(str(a)); + if (argc > 2) + { + wxString a2 = argv[2]; + operationProcessor.initProfile(str(a2)); + } + } + + logInfo("OnInit done"); + + return TRUE; +} + + + diff -Nru delaboratory-0.7/gui_wx/delaboratory.h delaboratory-0.8/gui_wx/delaboratory.h --- delaboratory-0.7/gui_wx/delaboratory.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/delaboratory.h 2012-07-29 13:05:47.000000000 +0000 @@ -0,0 +1,36 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + + +#include + +std::string getApplicationName() +{ + return "delaboratory"; +} + +std::string getVersion() +{ + return "0.8"; +} + +std::string getCopyright() +{ + return "(c) 2012 Jacek Poplawski"; +} + diff -Nru delaboratory-0.7/gui_wx/external_editor.cc delaboratory-0.8/gui_wx/external_editor.cc --- delaboratory-0.7/gui_wx/external_editor.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/external_editor.cc 2012-07-24 10:21:32.000000000 +0000 @@ -0,0 +1,60 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "external_editor.h" +#include +#include "str.h" +#include "str_wx.h" +#include +#include +#include "logger.h" + +#define WINDOWS_GIMP_EXE "gimp-2.8.exe" + +void executeExternalEditor(const std::string& fileName, const std::string& app) +{ + const char* c = fileName.c_str(); + wxString s(c, wxConvUTF8); + + std::string executable; + +#ifdef _WIN32 + char * editor = getenv( "GR_EDITOR" ); + if( editor != NULL ) + { + logInfo("using editor variable"); + executable = editor; + } + else + { + logInfo("editor variable not found, using GIMP"); + executable = WINDOWS_GIMP_EXE; + } + +#else + executable = app; +#endif + + + const wxString command = str2wx(executable) + _T(" ") + s; + std::string command_s = str(command); + logInfo("executing command: " + command_s); + wxExecute(command); + +} + diff -Nru delaboratory-0.7/gui_wx/external_editor.h delaboratory-0.8/gui_wx/external_editor.h --- delaboratory-0.7/gui_wx/external_editor.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/external_editor.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_EXTERNAL_EDITOR_H +#define _DE_EXTERNAL_EDITOR_H + +#include + +void executeExternalEditor(const std::string& fileName, const std::string& app); + +#endif diff -Nru delaboratory-0.7/gui_wx/file_dialogs.cc delaboratory-0.8/gui_wx/file_dialogs.cc --- delaboratory-0.7/gui_wx/file_dialogs.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/file_dialogs.cc 2012-07-29 12:06:49.000000000 +0000 @@ -0,0 +1,115 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "file_dialogs.h" +#include "str.h" +#include "str_wx.h" +#include "logger.h" + +wxString getFileType(const std::string& t) +{ + if (t == "image") + { + return _T("TIFF / JPEG (*.tiff;*.tif;*.jpeg;*.jpg) | ;*.tiff;*.tif;*.jpeg;*.jpg"); + } + if (t == "raw") + { + return _T("RAW (*.*) | ;*.*;"); + } + if (t == "tiff") + { + return _T("TIFF (*.tiff;*.tif) | ;*.tiff;*.tif"); + } + if (t == "jpeg") + { + return _T("JPEG (*.jpeg;*.jpg) | ;*.jpeg;*.jpg"); + } + if (t == "delab") + { + return _T("delab (*.delab) | ;*.delab"); + } + + return _T(""); +} + + +std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir) +{ + logInfo("getSaveFile info: " + info + " t: " + t + " dir: " + dir); + + wxString type = getFileType(t); + + wxString directory = str2wx(dir); + + wxFileDialog saveFileDialog(parent, wxString::FromAscii(info.c_str()), directory, _T(""), type, wxFD_SAVE); + + if (saveFileDialog.ShowModal() == wxID_CANCEL) + { + return ""; + } + + wxString path = saveFileDialog.GetPath(); + + std::string result = str(path); + + logInfo("getSaveFile result: " + result); + + return result; +} + +std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir) +{ + logInfo("getOpenFile info: " + info + " t: " + t + " dir: " + dir); + + wxString type = getFileType(t); + + wxString directory = str2wx(dir); + + wxFileDialog openFileDialog(parent, wxString::FromAscii(info.c_str()), directory, _T(""), type, wxFD_OPEN); + + if (openFileDialog.ShowModal() == wxID_CANCEL) + { + return ""; + } + + wxString path = openFileDialog.GetPath(); + + std::string result = str(path); + + logInfo("getOpenFile result: " + result); + + return result; +} + +std::string getDir(wxWindow* parent, const std::string& info) +{ + wxDirDialog saveFileDialog(parent, wxString::FromAscii(info.c_str())); + + if (saveFileDialog.ShowModal() != wxID_OK) + { + logInfo("getDir hit cancel"); + return ""; + } + + wxString path = saveFileDialog.GetPath(); + std::string result = str(path); + + logInfo("getDir result: " + result); + return result; + +} diff -Nru delaboratory-0.7/gui_wx/file_dialogs.h delaboratory-0.8/gui_wx/file_dialogs.h --- delaboratory-0.7/gui_wx/file_dialogs.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/file_dialogs.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,29 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_FILE_DIALOGS_H +#define _DE_FILE_DIALOGS_H + +#include +#include + +std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir); +std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir); +std::string getDir(wxWindow* parent, const std::string& info); + +#endif diff -Nru delaboratory-0.7/gui_wx/frame.cc delaboratory-0.8/gui_wx/frame.cc --- delaboratory-0.7/gui_wx/frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/frame.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,145 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "frame.h" +#include "window_wx.h" +#include "panel_wx.h" +#include +#include "logger.h" +#include "str.h" + +class deFrameImpl:public wxFrame +{ + private: + wxSizer* sizer; + std::map sizers; + deWindowWX window; + deFrame* frame; + public: + deFrameImpl(deWindow& parent, const std::string& name, deFrame* _frame) + :wxFrame((dynamic_cast(parent)).getWindow(), wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT), window(this), frame(_frame) + { + sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + } + + virtual ~deFrameImpl() + { + logInfo(" ~deFrameImpl"); + if (frame->clearImpl()) + { + delete frame; + } + logInfo(" ~deFrameImpl DONE"); + } + + void addWidget(wxWindow* widget) + { + sizer->Add(widget); + } + + void addWidget(const std::string& _name, wxWindow* widget) + { + sizers[_name]->Add(widget); + } + + void addSizer(const std::string& _name) + { + wxSizer* s = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(s); + sizers[_name] = s; + } + + deWindow& getWindow() + { + return window; + } + + void fit() + { + Fit(); + } +}; + +deFrame::deFrame(deWindow& parent, const std::string& name) +{ + impl = new deFrameImpl(parent, name, this); +} + +deFrame::~deFrame() +{ + logInfo(" ~deFrame"); + if (impl) + { + deFrameImpl* i = impl; + clearImpl(); + delete i; + } + logInfo(" ~deFrame DONE"); +} + +bool deFrame::clearImpl() +{ + bool result = (impl != NULL); + impl = NULL; + return result; +} + +void deFrame::show() +{ + if (impl) + { + impl->Show(); + } +} + +void deFrame::addWidget(deWindow& window) +{ + deWindowWX& w = dynamic_cast(window); + if (impl) + { + impl->addWidget(w.getWindow()); + } +} + +void deFrame::addWidget(const std::string& _name, deWindow& window) +{ + deWindowWX& w = dynamic_cast(window); + if (impl) + { + impl->addWidget(_name, w.getWindow()); + } +} + +void deFrame::addSizer(const std::string& _name) +{ + if (impl) + { + impl->addSizer(_name); + } +} + +deWindow& deFrame::getWindow() +{ + return impl->getWindow(); +} + +void deFrame::fit() +{ + impl->fit(); +} diff -Nru delaboratory-0.7/gui_wx/frame.h delaboratory-0.8/gui_wx/frame.h --- delaboratory-0.7/gui_wx/frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/frame.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,52 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_FRAME_H +#define _DE_FRAME_H + +#include +class deWindow; +class dePanel; + +class deFrameImpl; + +class deFrame +{ + private: + deFrameImpl* impl; + + protected: + void addWidget(deWindow& window); + void addWidget(const std::string& _name, deWindow& window); + void addSizer(const std::string& _name); + + public: + deFrame(deWindow& parent, const std::string& name); + virtual ~deFrame(); + + void show(); + + deWindow& getWindow(); + + void fit(); + + bool clearImpl(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/gradient_panel.cc delaboratory-0.8/gui_wx/gradient_panel.cc --- delaboratory-0.7/gui_wx/gradient_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/gradient_panel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,552 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gradient_panel.h" +#include "conversion_processor.h" + +deColorPanelOld::deColorPanelOld(wxWindow* parent, wxSize _size, int style) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, _size, style) +{ + Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deColorPanelOld::click)); + Connect(wxEVT_MOTION, wxMouseEventHandler(deColorPanelOld::hover)); + Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(deColorPanelOld::enter)); + Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(deColorPanelOld::leave)); +} + +deColorPanelOld::~deColorPanelOld() +{ +} + +void deColorPanelOld::click(wxMouseEvent &event) +{ + +} + +void deColorPanelOld::hover(wxMouseEvent &event) +{ + +} + +void deColorPanelOld::enter(wxMouseEvent &event) +{ +// SetBackgroundColour(wxColour(255 * r, 255 * g, 255 * b)); +} + +void deColorPanelOld::leave(wxMouseEvent &event) +{ +// SetBackgroundColour(wxColour(100 * r, 100 * g, 100 * b)); +} + + +void deColorPanelOld::setRGB(deValue rr, deValue gg, deValue bb) +{ + r = rr; + g = gg; + b = bb; + + SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); +} + +void deColorPanelOld::setColor(deColorSpace colorSpace, int channel, deValue value) +{ + deValue rr = 0; + deValue gg = 0; + deValue bb = 0; + + deValue v1 = 0; + deValue v2 = 0; + deValue v3 = 0; + deValue v4 = 0; + + if (colorSpace == deColorSpaceHSV) + { + v2 = 0.8; + v3 = 1.0; + } + + if (colorSpace == deColorSpaceHSL) + { + v2 = 0.8; + v3 = 0.5; + } + + if (colorSpace == deColorSpaceLCH) + { + v1 = 0.7; + v2 = 0.9; + } + + if (colorSpace == deColorSpaceLAB) + { + v2 = 0.5; + v3 = 0.5; + } + + switch (channel) + { + case 0: + v1 = value; + break; + case 1: + v2 = value; + break; + case 2: + v3 = value; + break; + case 3: + v4 = value; + break; + } + + deConversionProcessor p; + + deValue z; + p.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); + + SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); +} + +deGradientPanel::deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, _size), + colorSpace(_colorSpace) +{ + bitmap = NULL; + Connect(wxEVT_PAINT, wxPaintEventHandler(deGradientPanel::paintEvent)); +} + +deGradientPanel::~deGradientPanel() +{ + if (bitmap) + { + delete bitmap; + } +} + +void deGradientPanel::paintEvent(wxPaintEvent & evt) +{ + wxPaintDC dc(this); + dc.DrawBitmap(*bitmap, 0, 0, false); +} + + +deGradientPanel1::deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3) +:deGradientPanel(parent, _size, _colorSpace), +channel1(_channel1), channel2(_channel2), c1(_c1), c2(_c2), c3(_c3) +{ + bitmap = NULL; + generateBitmap(); +} + +deGradientPanel1::~deGradientPanel1() +{ +} + +void deGradientPanel1::changeChannel(int _channel) +{ + channel1 = _channel; + generateBitmap(); + Update(); + Refresh(); +} + +void setValues(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, int channel1, int channel2, deValue u, deValue v, deValue c1, deValue c2, deValue c3) +{ + v1 = 0; + v2 = 0; + v3 = 0; + v4 = 0; + + if (colorSpace == deColorSpaceLAB) + { + v1 = 0.9; + v2 = 0.5; + v3 = 0.5; + } + + if (colorSpace == deColorSpaceLCH) + { + v1 = 0.8; + v2 = 0.7; + v3 = 0.0; + } + + if (colorSpace == deColorSpaceHSL) + { + v1 = 0.0; + v2 = 0.8; + v3 = 0.6; + } + + if (colorSpace == deColorSpaceHSV) + { + v1 = 0.0; + v2 = 0.8; + v3 = 0.8; + } + + if (colorSpace == deColorSpaceXYZ) + { + v1 = 0.1; + v2 = 0.1; + v3 = 0.1; + } + + switch (channel2) + { + case 0: + v1 = u; + break; + case 1: + v2 = u; + break; + case 2: + v3 = u; + break; + case 3: + v4 = u; + break; + }; + + switch (channel1) + { + case 0: + v1 = v; + if ((colorSpace == deColorSpaceLCH) && (channel2 < 0)) + { + v2 = 0; + } + break; + case 1: + v2 = v; + break; + case 2: + v3 = v; + break; + case 3: + v4 = v; + break; + }; + + if (c1 >= 0) + { + if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) + { + v1 = c1; + } + if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) + { + v3 = c1; + } + } + + if (c2 >= 0) + { + if (colorSpace == deColorSpaceLCH) + { + v3 = c2; + } + if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) + { + v1 = c2; + } + } + + if (colorSpace == deColorSpaceCMYK) + { + if (c1 >= 0) + { + v1 = c1; + } + if (c2 >= 0) + { + v2 = c2; + } + if (c3 >= 0) + { + v3 = c3; + } + } +} + +void deGradientPanel1::generateBitmap() +{ + if (bitmap) + { + delete bitmap; + } + + deConversionProcessor cp; + + int w = GetSize().GetWidth(); + int h = GetSize().GetHeight(); + wxImage* image = new wxImage(w, h); + unsigned char* data = image->GetData(); + + int x; + int y; + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + float v = 0; + float u = 0; + if (h > w) + { + v = 1.0 - (float) y / h; + u = (float) x / w; + } + else + { + v = (float) x / w; + u = 1.0 - (float) y / h; + } + + deValue v1 = v; + deValue v2 = v; + deValue v3 = v; + deValue v4 = v; + + setValues(v1, v2, v3, v4, colorSpace, channel1, channel2, u, v, c1, c2, c3); + + deValue rr = 0; + deValue gg = 0; + deValue bb = 0; + + deValue z; + cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); + + unsigned char r = 255 * rr; + unsigned char g = 255 * gg; + unsigned char b = 255 * bb; + + data[3*(y*w+x) + 0] = r; + data[3*(y*w+x) + 1] = g; + data[3*(y*w+x) + 2] = b; + + } + } + bitmap = new wxBitmap(*image); + delete image; +} + +deGradientPanel2::deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4) +:deGradientPanel(parent, _size, _colorSpace), + c1(_c1), c2(_c2), c3(_c3), c4(_c4) +{ + bitmap = NULL; + generateBitmap(); +} + +deGradientPanel2::~deGradientPanel2() +{ +} + +void setValues2(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, deValue c1, deValue c2, deValue c3, deValue c4, deValue u, deValue v) +{ + if (colorSpace == deColorSpaceCMYK) + { + v1 = c1; + v2 = c2; + v3 = c3; + v4 = c4 + v * 0.2; + } + if (colorSpace == deColorSpaceLAB) + { + deValue uu = u + 0.2; + deValue vv = v + 0.2; + deValue s = sqrt(vv * vv + uu * uu) - 0.2; + if (s < 0) + { + s = 0; + } + v1 = 1.0 - 0.2 * s; + v2 = c1; + v3 = c2; + v4 = 0; + } +} + +void deGradientPanel2::generateBitmap() +{ + if (bitmap) + { + delete bitmap; + } + + deConversionProcessor cp; + + int w = GetSize().GetWidth(); + int h = GetSize().GetHeight(); + wxImage* image = new wxImage(w, h); + unsigned char* data = image->GetData(); + + int x; + int y; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + float v = 0; + float u = 0; + + deValue d = 2; + + deValue xx = fabs(x - w / d) / (w / d); + deValue yy = fabs(y - h / d) / (h / d); + + if (h > w) + { + v = yy; + u = xx; + } + else + { + v = xx; + u = yy; + } + + deValue v1 = v; + deValue v2 = v; + deValue v3 = v; + deValue v4 = v; + + setValues2(v1, v2, v3, v4, colorSpace, c1, c2, c3, c4, u, v); + + deValue rr = 0; + deValue gg = 0; + deValue bb = 0; + + deValue z; + cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); + + unsigned char r = 255 * rr; + unsigned char g = 255 * gg; + unsigned char b = 255 * bb; + + data[3*(y*w+x) + 0] = r; + data[3*(y*w+x) + 1] = g; + data[3*(y*w+x) + 2] = b; + + } + } + bitmap = new wxBitmap(*image); + delete image; +} + + +deGradientPanel0::deGradientPanel0(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel, int _margin) +:deGradientPanel(parent, _size, _colorSpace), +channel(_channel), margin(_margin) +{ + bitmap = NULL; + generateBitmap(); +} + +deGradientPanel0::~deGradientPanel0() +{ +} + +void deGradientPanel0::changeChannel(int _channel) +{ + channel = _channel; + generateBitmap(); + Update(); + Refresh(); +} + +void deGradientPanel0::generateBitmap() +{ + if (bitmap) + { + delete bitmap; + } + + deConversionProcessor cp; + + int w = GetSize().GetWidth(); + int h = GetSize().GetHeight(); + + unsigned char gray = 128; + + int ww = w - 2 * margin; + wxImage* image = new wxImage(w, h); + unsigned char* data = image->GetData(); + + int xx; + int y; + for (xx = 0; xx < w; xx++) + { + int x = xx - margin; + if (x < 0) + { + x = -1; + } + if (x >= ww) + { + x = -1; + } + for (y = 0; y < h; y++) + { + unsigned char r = gray; + unsigned char g = gray; + unsigned char b = gray; + + if (x >= 0) + { + float v = 0; + float u = 0; + if (h > ww) + { + v = 1.0 - (float) y / h; + u = (float) x / ww; + } + else + { + v = (float) x / ww; + u = 1.0 - (float) y / h; + } + + deValue v1 = v; + deValue v2 = v; + deValue v3 = v; + deValue v4 = v; + + setValues(v1, v2, v3, v4, colorSpace, channel, -1, u, v, -1, -1, -1); + + deValue rr = 0; + deValue gg = 0; + deValue bb = 0; + + deValue z; + cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); + + r = 255 * rr; + g = 255 * gg; + b = 255 * bb; + } + + data[3*(y*w+xx) + 0] = r; + data[3*(y*w+xx) + 1] = g; + data[3*(y*w+xx) + 2] = b; + + } + } + bitmap = new wxBitmap(*image); + delete image; +} diff -Nru delaboratory-0.7/gui_wx/gradient_panel.h delaboratory-0.8/gui_wx/gradient_panel.h --- delaboratory-0.7/gui_wx/gradient_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/gradient_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,117 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GRADIENT_PANEL_H +#define _DE_GRADIENT_PANEL_H + +#include +#include "color_space.h" +#include "value.h" +class dePalette3; + +class deColorPanelOld:public wxPanel +{ +private: + deValue r; + deValue g; + deValue b; + +protected: + void click(wxMouseEvent &event); + void hover(wxMouseEvent &event); + void enter(wxMouseEvent &event); + void leave(wxMouseEvent &event); + +public: + deColorPanelOld(wxWindow* parent, wxSize _size, int style); + virtual ~deColorPanelOld(); + + void setRGB(deValue rr, deValue gg, deValue bb); + void setColor(deColorSpace colorSpace, int channel, deValue value); +}; + +class deGradientPanel:public wxPanel +{ +protected: + wxBitmap* bitmap; + deColorSpace colorSpace; + +public: + deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace); + virtual ~deGradientPanel(); + + void paintEvent(wxPaintEvent & evt); +}; + +class deGradientPanel0:public deGradientPanel +{ +private: + void generateBitmap(); + + int channel; + int margin; + +public: + deGradientPanel0(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel, int _margin); + ~deGradientPanel0(); + + void changeChannel(int _channel); + +}; + +class deGradientPanel1:public deGradientPanel +{ +private: + + void generateBitmap(); + + int channel1; + int channel2; + + deValue c1; + deValue c2; + deValue c3; + +public: + deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3); + ~deGradientPanel1(); + + void changeChannel(int _channel); + + +}; + +class deGradientPanel2:public deGradientPanel +{ +private: + + void generateBitmap(); + + deValue c1; + deValue c2; + deValue c3; + deValue c4; + +public: + deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4); + ~deGradientPanel2(); + + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/gui.cc delaboratory-0.8/gui_wx/gui.cc --- delaboratory-0.7/gui_wx/gui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/gui.cc 2012-06-28 00:55:17.000000000 +0000 @@ -0,0 +1,149 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gui.h" +#include "view_mode_panel.h" +#include "layer_grid_panel.h" +#include "layer_frame_manager.h" +#include "window_wx.h" +#include "base_layer.h" +#include "generic_layer_frame.h" +#include "histogram_mode_panel.h" +#include "image_area_panel.h" +#include "logger.h" + +deGUI::deGUI() +{ + viewModePanel = NULL; + layerGridPanel = NULL; + histogramModePanel = NULL; + imageAreaPanel = NULL; +} + +deGUI::~deGUI() +{ +} + +void deGUI::setViewModePanel(deViewModePanel* _viewModePanel) +{ + viewModePanel = _viewModePanel; +} + +void deGUI::setLayerGridPanel(deLayerGridPanel* _panel) +{ + layerGridPanel = _panel; +} + +void deGUI::setHistogramModePanel(deHistogramModePanel* _histogramModePanel) +{ + histogramModePanel = _histogramModePanel; +} + + +void deGUI::updateViewModePanelMode() +{ + if (viewModePanel) + { + viewModePanel->updateMode(); + } +} + +void deGUI::updateViewModePanelNames() +{ + if (viewModePanel) + { + viewModePanel->updateNames(); + } +} + +void deGUI::updateLayerGrid() +{ + if (layerGridPanel) + { + layerGridPanel->update(); + } +} + +void deGUI::openLayerFrame(deBaseLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& layerFrameManager, int index) +{ + if (!layerFrameManager.checkLayerFrame(index)) + { + deWindowWX window(layerGridPanel); + const std::string name = layer.getType(); + + deFrame* frame = new deGenericLayerFrame(window, name, layer, layerProcessor, layerFrameManager, index); + if (frame) + { + frame->show(); + } + } +} + +void deGUI::updateHistogramMode(int channel) +{ + if (histogramModePanel) + { + histogramModePanel->updateMode(channel); + } +} + +void deGUI::updateHistogramNames() +{ + if (histogramModePanel) + { + histogramModePanel->updateNames(); + } +} + +void deGUI::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) +{ + imageAreaPanel = _imageAreaPanel; +} + +void deGUI::updateImageAreaSize() +{ + if (imageAreaPanel) + { + imageAreaPanel->updateSize(false); + } +} + +void deGUI::lockSize() +{ + if (imageAreaPanel) + { + imageAreaPanel->lockSize(); + } + else + { + logError("can't lockSize, no imageAreaPanel"); + } +} + +void deGUI::unlockSize() +{ + if (imageAreaPanel) + { + imageAreaPanel->unlockSize(); + } + else + { + logError("can't unlockSize, no imageAreaPanel"); + } +} + diff -Nru delaboratory-0.7/gui_wx/gui.h delaboratory-0.8/gui_wx/gui.h --- delaboratory-0.7/gui_wx/gui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/gui.h 2012-06-27 18:13:03.000000000 +0000 @@ -0,0 +1,68 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GUI_H +#define _DE_GUI_H + +class deViewModePanel; +class deLayerGridPanel; +class deLayerProcessor; +class deLayerFrameManager; +class deBaseLayer; +class deHistogramModePanel; +class deImageAreaPanel; + +class deGUI +{ + private: + deGUI(const deGUI& gui); + deGUI& operator =(const deGUI& gui); + + deViewModePanel* viewModePanel; + deLayerGridPanel* layerGridPanel; + deHistogramModePanel* histogramModePanel; + deImageAreaPanel* imageAreaPanel; + + public: + deGUI(); + + virtual ~deGUI(); + + void setViewModePanel(deViewModePanel* _viewModePanel); + void updateViewModePanelMode(); + void updateViewModePanelNames(); + + void setLayerGridPanel(deLayerGridPanel* _panel); + void updateLayerGrid(); + + void openLayerFrame(deBaseLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& layerFrameManager, int index); + + void setHistogramModePanel(deHistogramModePanel* _histogramModePanel); + void updateHistogramMode(int channel); + void updateHistogramNames(); + + void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); + void updateImageAreaSize(); + + void lockSize(); + void unlockSize(); + + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame2.cc delaboratory-0.8/gui_wx/help_color_spaces_frame2.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame2.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame2.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,113 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame2.h" +#include "color_space.h" +#include "gradient_panel.h" +#include "color_space_utils.h" + +deHelpColorSpacesFrame2::deHelpColorSpacesFrame2(wxWindow *parent) +:deHelpFrame(parent, "mix of channels") +{ + wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(mainSizer); + + wxSizer* sizer1 = new wxGridSizer(2); + mainSizer->Add(sizer1); + + std::vector colorSpaces; + getSupportedColorSpaces(colorSpaces); + + int width = 140; + int barSize = 140; + + std::vector::iterator i; + + for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) + { + deColorSpace c = *i; + + int n = getColorSpaceSize(c); + + if (n == 3) + { + + wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); + sizer1->Add(sizerB); + + int j; + for (j = 0; j < n; j++) + { + int k = j + 1; + if (k >= n) + { + k = 0; + } + + std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); + wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); + sizerB->Add(sizerBC); + + deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); + sizerBC->Add(gradient, 0, wxCENTER); + } + + } + } + + wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); + mainSizer->Add(sizer2); + + for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) + { + deColorSpace c = *i; + + int n = getColorSpaceSize(c); + + if (n == 4) + { + + wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); + sizer2->Add(sizerB); + + int j; + for (j = 0; j < n; j++) + { + int k; + for (k = j + 1; k < n; k++) + { + std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); + wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); + sizerB->Add(sizerBC); + + deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); + sizerBC->Add(gradient, 0, wxCENTER); + } + } + + } + } + + Fit(); + +} + +deHelpColorSpacesFrame2::~deHelpColorSpacesFrame2() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame2.h delaboratory-0.8/gui_wx/help_color_spaces_frame2.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame2.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame2.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME2_H +#define _DE_HELP_COLOR_SPACES_FRAME2_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame2:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame2(wxWindow *parent); + virtual ~deHelpColorSpacesFrame2(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame3.cc delaboratory-0.8/gui_wx/help_color_spaces_frame3.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame3.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame3.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,87 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame3.h" +#include "color_space.h" +#include "gradient_panel.h" +#include +#include "color_space_utils.h" + +void add(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) +{ + wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); + sizer->Add(sizerB); + + int w = 160; + int h = 160; + + deValue max = 1.0; + int n = 6; + deValue min = max - n * (0.25/2.0); + deValue step = (max-min) / (n ); + + deValue light; + + for (light = min; light <= max; light+= step) + { + deValue l = light * 100; + + std::ostringstream oss; + oss << l; + wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); + sizerB->Add(sizerBC); + + int c1; + int c2; + if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) + { + c1 = 1; + c2 = 2; + } + else + { + c1 = 1; + c2 = 0; + } + + deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, light, -1, -1); + sizerBC->Add(gradient, 0, wxCENTER); + + } + +} + +deHelpColorSpacesFrame3::deHelpColorSpacesFrame3(wxWindow *parent) +:deHelpFrame(parent, "lightness / value") +{ + wxSizer* sizer = new wxGridSizer(1); + SetSizer(sizer); + + add(deColorSpaceLAB, this, sizer); + add(deColorSpaceLCH, this, sizer); + add(deColorSpaceHSL, this, sizer); + add(deColorSpaceHSV, this, sizer); + + Fit(); + +} + +deHelpColorSpacesFrame3::~deHelpColorSpacesFrame3() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame3.h delaboratory-0.8/gui_wx/help_color_spaces_frame3.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame3.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame3.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME3_H +#define _DE_HELP_COLOR_SPACES_FRAME3_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame3:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame3(wxWindow *parent); + virtual ~deHelpColorSpacesFrame3(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame4.cc delaboratory-0.8/gui_wx/help_color_spaces_frame4.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame4.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame4.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,93 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame4.h" +#include "color_space.h" +#include "gradient_panel.h" +#include +#include "color_space_utils.h" + +void add2(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) +{ + wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); + sizer->Add(sizerB); + + wxSizer* sizerG = new wxGridSizer(6); + sizerB->Add(sizerG); + + int w = 120; + int h = 50; + + int n = 18; + deValue step = 1.0 / n; + deValue l = 0; + + int i; + for (i = 0; i < n; i++) + { + std::ostringstream oss; + + int hue; + + hue = 360 * l; + + oss << hue; + wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); + sizerG->Add(sizerBC); + + int c1; + int c2; + if (colorSpace == deColorSpaceLCH) + { + c1 = 0; + c2 = 1; + } + else + { + c1 = 1; + c2 = 2; + } + + deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, -1, l, -1); + sizerBC->Add(gradient, 0, wxCENTER); + + l += step; + + } + + +} + +deHelpColorSpacesFrame4::deHelpColorSpacesFrame4(wxWindow *parent) +:deHelpFrame(parent, "hue") +{ + wxSizer* sizer = new wxGridSizer(1); + SetSizer(sizer); + + add2(deColorSpaceLCH, this, sizer); + add2(deColorSpaceHSL, this, sizer); + add2(deColorSpaceHSV, this, sizer); + + Fit(); + +} + +deHelpColorSpacesFrame4::~deHelpColorSpacesFrame4() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame4.h delaboratory-0.8/gui_wx/help_color_spaces_frame4.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame4.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame4.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME4_H +#define _DE_HELP_COLOR_SPACES_FRAME4_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame4:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame4(wxWindow *parent); + virtual ~deHelpColorSpacesFrame4(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame5.cc delaboratory-0.8/gui_wx/help_color_spaces_frame5.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame5.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame5.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,99 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame5.h" +#include "color_space.h" +#include "gradient_panel.h" +#include +#include "conversion_processor.h" +#include +#include + +#include "skin_color_chart.h" + +void generateFelixVonLuschan(wxWindow* window, wxSizer* sizer) +{ + int w = 240; + int h = 30; + + std::vector skins; + getFelixVonLuschan(skins); + + std::vector ranges; + + getSkinRanges(ranges); + + std::vector::iterator r; + for (r = ranges.begin(); r != ranges.end(); r++) + { + deSkinRange range = *r; + + std::ostringstream oss; + oss << range.description; + wxSizer* sizer_B = new wxStaticBoxSizer(wxVERTICAL, window, wxString::FromAscii(oss.str().c_str())); + sizer->Add(sizer_B); + + int i; + + deConversionProcessor cp; + + for (i = range.first - 1; i <= range.last - 1; i++) + { + deSkinRGB& skin = skins[i]; + deValue cc; + deValue mm; + deValue yy; + deValue kk; + +// rgb2cmyk(skin.r / 255.0, skin.g / 255.0, skin.b / 255.0, cc, mm, yy, kk); + cp.convert(deColorSpaceRGB, skin.r / 255.0, skin.g / 255.0, skin.b / 255.0, 0, deColorSpaceCMYK, cc, mm, yy, kk); + + int c = 100 * cc; + int m = 100 * mm; + int y = 100 * yy; + int k = 100 * kk; + + std::ostringstream oss; + oss << "C: " << c << " M: " << m << " Y: " << y << " K: " << k; + wxSizer* sizer_S = new wxStaticBoxSizer(wxHORIZONTAL, window, wxString::FromAscii(oss.str().c_str())); + sizer_B->Add(sizer_S); + + deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceCMYK, cc, mm, yy, kk); + sizer_S->Add(gradient, 0, wxCENTER); + } + + } + +} + +deHelpColorSpacesFrame5::deHelpColorSpacesFrame5(wxWindow *parent) +:deHelpFrame(parent, "skin colors in CMYK (based on Felix Von Lunshan scale)") +{ + wxSizer* sizer = new wxFlexGridSizer(3); + SetSizer(sizer); + + generateFelixVonLuschan(this, sizer); + + Fit(); + +} + +deHelpColorSpacesFrame5::~deHelpColorSpacesFrame5() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame5.h delaboratory-0.8/gui_wx/help_color_spaces_frame5.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame5.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame5.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME5_H +#define _DE_HELP_COLOR_SPACES_FRAME5_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame5:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame5(wxWindow *parent); + virtual ~deHelpColorSpacesFrame5(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame6.cc delaboratory-0.8/gui_wx/help_color_spaces_frame6.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame6.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame6.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,86 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame6.h" +#include "color_space.h" +#include "gradient_panel.h" +#include +#include +#include + +const int LAB_COLORS_COUNT=10; +const int LAB_COLORS_ELEMENTS = (2 * LAB_COLORS_COUNT + 1); + +void generateAB(wxWindow* window, wxSizer* sizer, int scale) +{ + int w = 40; + int h = 40; + + int b; + int a; + + sizer->Add(-1, 0, wxCENTER); + + for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) + { + int sa = scale * a; + std::ostringstream oss; + oss << sa; + wxStaticText* la = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); + sizer->Add(la, 1, wxCENTER); + } + + for (b = LAB_COLORS_COUNT; b >= -LAB_COLORS_COUNT; b--) + { + int sb = scale * b; + + std::ostringstream oss; + oss << sb; + wxStaticText* lb = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); + sizer->Add(lb, 0, wxCENTER); + + deValue bb = (sb + 100.0) / 200.0; + for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) + { + int sa = scale * a; + deValue aa = (sa + 100.0) / 200.0; + + deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceLAB, aa, bb, -1, -1); + sizer->Add(gradient, 0, wxCENTER); + } + } + + sizer->Layout(); +} + +deHelpColorSpacesFrame6::deHelpColorSpacesFrame6(wxWindow *parent, int scale) +:deHelpFrame(parent, "LAB") +{ + wxSizer* sizer = new wxFlexGridSizer(1 + LAB_COLORS_ELEMENTS, 0, 0); + SetSizer(sizer); + + generateAB(this, sizer, scale); + + Fit(); + +} + +deHelpColorSpacesFrame6::~deHelpColorSpacesFrame6() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame6.h delaboratory-0.8/gui_wx/help_color_spaces_frame6.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame6.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame6.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME6_H +#define _DE_HELP_COLOR_SPACES_FRAME6_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame6:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame6(wxWindow *parent, int scale); + virtual ~deHelpColorSpacesFrame6(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame.cc delaboratory-0.8/gui_wx/help_color_spaces_frame.cc --- delaboratory-0.7/gui_wx/help_color_spaces_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,63 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_color_spaces_frame.h" +#include "color_space.h" +#include "gradient_panel.h" +#include "color_space_utils.h" + +deHelpColorSpacesFrame::deHelpColorSpacesFrame(wxWindow *parent) +:deHelpFrame(parent, "channels") +{ + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + std::vector colorSpaces; + getSupportedColorSpaces(colorSpaces); + + int width = 256; + int barSize = 40; + + std::vector::iterator i; + for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) + { + deColorSpace c = *i; + + wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); + sizer->Add(sizerB); + + int n = getColorSpaceSize(c); + int j; + for (j = 0; j < n; j++) + { + wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getChannelName(c, j).c_str())); + sizerB->Add(sizerBC); + + deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, -1, -1, -1, -1); + sizerBC->Add(gradient, 0, wxCENTER); + } + } + + Fit(); + +} + +deHelpColorSpacesFrame::~deHelpColorSpacesFrame() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_color_spaces_frame.h delaboratory-0.8/gui_wx/help_color_spaces_frame.h --- delaboratory-0.7/gui_wx/help_color_spaces_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_color_spaces_frame.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_COLOR_SPACES_FRAME_H +#define _DE_HELP_COLOR_SPACES_FRAME_H + +#include "help_frame.h" + +class deHelpColorSpacesFrame:public deHelpFrame +{ + private: + public: + deHelpColorSpacesFrame(wxWindow *parent); + virtual ~deHelpColorSpacesFrame(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/help_frame.cc delaboratory-0.8/gui_wx/help_frame.cc --- delaboratory-0.7/gui_wx/help_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_frame.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,29 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "help_frame.h" + +deHelpFrame::deHelpFrame(wxWindow *parent, const std::string& name) +:wxFrame(parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT) +{ +} + +deHelpFrame::~deHelpFrame() +{ +} + diff -Nru delaboratory-0.7/gui_wx/help_frame.h delaboratory-0.8/gui_wx/help_frame.h --- delaboratory-0.7/gui_wx/help_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/help_frame.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,32 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HELP_FRAME_H +#define _DE_HELP_FRAME_H + +#include + +class deHelpFrame:public wxFrame +{ + private: + public: + deHelpFrame(wxWindow *parent, const std::string& _name); + virtual ~deHelpFrame(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/histogram_mode_panel.cc delaboratory-0.8/gui_wx/histogram_mode_panel.cc --- delaboratory-0.7/gui_wx/histogram_mode_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/histogram_mode_panel.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,115 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "histogram_mode_panel.h" +#include +#include "color_space.h" +#include "project.h" +#include +#include "histogram_panel.h" +#include "layer_processor.h" +#include "color_space_utils.h" +#include "gui.h" + +void deHistogramModePanel::select(wxCommandEvent &event) +{ + int i = event.GetId(); + + int j; + for (j = 0; j < MAX_COLOR_SPACE_SIZE; j++) + { + if (buttons[j]->GetId() == i) + { + histogramPanel->setChannel(j); + project.getLayerProcessor().generateHistogram(); + } + } + +} + +deHistogramModePanel::deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel, deGUI& gui) +:wxPanel(parent), project(_project), histogramPanel(_histogramPanel) +{ + gui.setHistogramModePanel(this); + + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(sizer); + + int i; + for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) + { + int style = 0; + if (i == 0) + { + style = wxRB_GROUP; + } + wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); + sizer->Add(b); + buttons.push_back(b); + + } + + updateNames(); + updateMode(0); + + Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deHistogramModePanel::select)); +} + +deHistogramModePanel::~deHistogramModePanel() +{ + +} + +void deHistogramModePanel::updateNames() +{ + deViewManager& viewManager = project.getViewManager(); + deColorSpace colorSpace = viewManager.getColorSpace(); + + int i; + int n = getColorSpaceSize(colorSpace); + for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) + { + wxRadioButton* b = buttons[i]; + if (i < n) + { + std::string name = getChannelName(colorSpace, i); + b->SetLabel(wxString::FromAscii(name.c_str())); + b->Show(); + } + else + { + b->Hide(); + } + } + + Layout(); + Fit(); + SetFocus(); +} + +void deHistogramModePanel::updateMode(int c) +{ + if ((c < 0) || (c >= MAX_COLOR_SPACE_SIZE)) + { + return; + } + + histogramPanel->setChannel(c); + buttons[c]->SetValue(1); +} + diff -Nru delaboratory-0.7/gui_wx/histogram_mode_panel.h delaboratory-0.8/gui_wx/histogram_mode_panel.h --- delaboratory-0.7/gui_wx/histogram_mode_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/histogram_mode_panel.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HISTOGRAM_MODE_PANEL_H +#define _DE_HISTOGRAM_MODE_PANEL_H + +#include +#include + +class deProject; +class deHistogramPanel; +class deGUI; + +class deHistogramModePanel:public wxPanel +{ + private: + std::vector buttons; + deProject& project; + deHistogramPanel* histogramPanel; + + void select(wxCommandEvent &event); + public: + deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel, deGUI& gui); + virtual ~deHistogramModePanel(); + + void updateNames(); + void updateMode(int c); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/histogram_panel.cc delaboratory-0.8/gui_wx/histogram_panel.cc --- delaboratory-0.7/gui_wx/histogram_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/histogram_panel.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,161 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "histogram_panel.h" +#include "project.h" +#include "color_space.h" +#include +#include "base_layer.h" +#include "image.h" +#include "layer_processor.h" +#include +#include "channel_manager.h" +#include "layer_stack.h" +#include "str.h" +#include "canvas_wx.h" + +BEGIN_EVENT_TABLE(deHistogramPanel, wxPanel) +EVT_PAINT(deHistogramPanel::paintEvent) +END_EVENT_TABLE() + +deHistogramPanel::deHistogramPanel(wxWindow* parent, deProject* _project, int _width, int _margin) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(_width, 200)), project(_project), histogram(_width - 2 * _margin), width(_width), margin(_margin) +{ + channel = 0; + generated = false; + renderedImage.setSize(deSize(width, width)); +} + +deHistogramPanel::~deHistogramPanel() +{ +} + +void deHistogramPanel::paintEvent(wxPaintEvent & evt) +{ + wxBufferedPaintDC dc(this); + deCanvasWX canvas(dc); + render(canvas); +} + +void deHistogramPanel::paintHistogram() +{ + wxClientDC dc(this); + wxBufferedDC bufferedDC(&dc); + deCanvasWX canvas(bufferedDC); + render(canvas); +} + +void deHistogramPanel::render(deCanvas& canvas) +{ + mutex.lock(); + + if (generated) + { + renderedImage.render(canvas); + } + else + { + canvas.clear(); + } + + mutex.unlock(); +} + +void deHistogramPanel::generateHistogram() +{ + mutex.lock(); + +#ifdef DEBUG_LOG + logInfo("generate histogram..."); +#endif + + generated = false; + + deLayerStack& layerStack = project->getLayerStack(); + deViewManager& viewManager = project->getViewManager(); + + int viewV = viewManager.getView(); + + project->getLayerProcessor().lockLayerProcessor(); + + int view = project->getLayerProcessor().getLastValidLayer(); + if (view > viewV) + { + view = viewV; + } + const deBaseLayer* layer = layerStack.startReadLayer(view); + + project->getLayerProcessor().unlockLayerProcessor(); + + if (layer) + { + const deImage& image = layer->getLayerImage(); + int n = image.getChannelSize().getN(); + + const deValue* values = image.startRead(channel); + + if ((n > 0) && (values)) + { + histogram.clear(); + histogram.calc(values, n); + } + else + { + if (!values) + { + logError("can't generate histogram - NULL channel"); + } + if (n <= 0) + { + logError("can't generate histogram - n: " + str(n)); + } + } + + image.finishRead(channel); + } + + + if (layer) + { + int sizeH = 200; + unsigned char g1 = 50; + unsigned char g2 = 120; + + generated = histogram.render(renderedImage.getCurrentImageData(), width, sizeH, g1, g2, margin); + } + + layerStack.finishReadLayer(view); + +#ifdef DEBUG_LOG + logInfo("generate histogram DONE"); +#endif + + mutex.unlock(); +} + +void deHistogramPanel::setChannel(int _channel) +{ + mutex.lock(); + channel = _channel; + mutex.unlock(); +} + +int deHistogramPanel::getChannel() const +{ + return channel; +} diff -Nru delaboratory-0.7/gui_wx/histogram_panel.h delaboratory-0.8/gui_wx/histogram_panel.h --- delaboratory-0.7/gui_wx/histogram_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/histogram_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,57 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HISTOGRAM_PANEL_H +#define _DE_HISTOGRAM_PANEL_H + +#include +#include "histogram.h" +class deProject; +#include "rendered_image.h" +#include "mutex.h" + +class deHistogramPanel:public wxPanel +{ + private: + deProject* project; + deHistogram histogram; + deRenderedImage renderedImage; + int channel; + bool generated; + int width; + int margin; + deMutex mutex; + + void paintEvent(wxPaintEvent & evt); + void render(deCanvas& canvas); + + DECLARE_EVENT_TABLE() + + public: + deHistogramPanel(wxWindow* parent, deProject* _project, int _width, int _margin); + virtual ~deHistogramPanel(); + + void generateHistogram(); + void paintHistogram(); + + void setChannel(int _channel); + + int getChannel() const; +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/image_area_panel.cc delaboratory-0.8/gui_wx/image_area_panel.cc --- delaboratory-0.7/gui_wx/image_area_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_area_panel.cc 2012-06-27 18:13:03.000000000 +0000 @@ -0,0 +1,99 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "image_area_panel.h" +#include "size.h" +#include "project.h" +#include "image_panel.h" +#include "channel_manager.h" +#include "layer_processor.h" +#include "zoom_panel.h" +#include "str.h" +#include "gui.h" + +void deImageAreaPanel::resize(wxSizeEvent& event) +{ + logInfo("SIZE event in image area panel"); + updateSize(true); + Refresh(); +} + +void deImageAreaPanel::updateSize(bool canSkip) +{ + if (sizeLocked) + { + logError("updateSize called when sizeLocked, skipped"); + return; + } + + wxSize s = GetSize(); + logInfo("image area panel update size " + str(s.GetWidth()) + "x" + str(s.GetHeight())); + + const deSize ps(s.GetWidth(), s.GetHeight()); + + deSize fit = project.onImageAreaChangeSize(ps, canSkip); + + logInfo("set image panel size " + str(fit.getW()) + "x" + str(fit.getH())); + imagePanel->SetMinSize(wxSize(fit.getW(), fit.getH())); + + Layout(); +} + +deImageAreaPanel::deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel, deGUI& gui) +:wxPanel(parent), project(_project) +{ + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + imagePanel = new deImagePanel(this, project, _samplerManager, _zoomManager, zoomPanel); + sizer->Add(imagePanel, 0, wxCENTER); + + gui.setImageAreaPanel(this); + + zoomPanel->setImageAreaPanel(this); + + sizeLocked = false; + + Connect(wxEVT_SIZE, wxSizeEventHandler(deImageAreaPanel::resize)); +} + +deImageAreaPanel::~deImageAreaPanel() +{ +} + +deImagePanel* deImageAreaPanel::getImagePanel() +{ + return imagePanel; +} + +void deImageAreaPanel::lockSize() +{ + logInfo("sizeLocked = true"); + sizeMutex.lock(); + sizeLocked = true; + sizeMutex.unlock(); +} + +void deImageAreaPanel::unlockSize() +{ + logInfo("sizeLocked = false"); + sizeMutex.lock(); + sizeLocked = false; + sizeMutex.unlock(); +} + diff -Nru delaboratory-0.7/gui_wx/image_area_panel.h delaboratory-0.8/gui_wx/image_area_panel.h --- delaboratory-0.7/gui_wx/image_area_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_area_panel.h 2012-06-27 18:13:03.000000000 +0000 @@ -0,0 +1,56 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CENTER_PANEL_H +#define _DE_CENTER_PANEL_H + +#include +class deProject; +class deImagePanel; +class deSamplerManager; +class deZoomManager; +class deZoomPanel; +class deGUI; +#include "mutex.h" + +class deImageAreaPanel:public wxPanel +{ + private: + void resize(wxSizeEvent &event); + deProject& project; + + deImagePanel* imagePanel; + + deMutex sizeMutex; + + bool sizeLocked; + + public: + deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel, deGUI& gui); + virtual ~deImageAreaPanel(); + + void updateSize(bool canSkip); + + void lockSize(); + void unlockSize(); + + deImagePanel* getImagePanel(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/image_io.cc delaboratory-0.8/gui_wx/image_io.cc --- delaboratory-0.7/gui_wx/image_io.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_io.cc 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,204 @@ +/* + + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "image_io.h" +#include +#include +#include "logger.h" +#include "static_image.h" +#include "str.h" +#include "dcraw_support.h" +#include "channel_manager.h" +#include "image.h" +#include "conversion_processor.h" +#include "tiff.h" + +void saveJPEG(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size) +{ + wxImage* image; + int w = size.getW(); + int h = size.getH(); + + image = new wxImage(w, h); + + image->SetOption(wxIMAGE_OPTION_QUALITY,98); + + int pos = 0; + int y; + for (y = 0; y < h; y++) + { + int x; + for (x = 0; x < w; x++) + { + deValue r = 255 * channelR[pos]; + deValue g = 255 * channelG[pos]; + deValue b = 255 * channelB[pos]; + image->SetRGB(x, y, r, g, b); + + pos++; + + } + } + + const char* c = fileName.c_str(); + wxString s(c, wxConvUTF8); + image->SaveFile(s); + delete image; +} + +bool loadJPEG(const std::string& fileName, deStaticImage& image) +{ + + logInfo("loadJPEG " + fileName); + + const char* c = fileName.c_str(); + wxString s(c, wxConvUTF8); + wxImage fileImage; + bool result = fileImage.LoadFile(s, wxBITMAP_TYPE_JPEG); + if (!result) + { + return false; + } + int w = fileImage.GetWidth(); + int h = fileImage.GetHeight(); + + image.lock(); + + deSize size(w, h); + image.setSize(size); + image.setColorSpace(deColorSpaceRGB); + + deValue* pixels0 = image.startWriteStatic(0); + deValue* pixels1 = image.startWriteStatic(1); + deValue* pixels2 = image.startWriteStatic(2); + + int pos = 0; + + unsigned char* data = fileImage.GetData(); + + int p = 0; + int y; + for (y =0; y < h; y++) + { + int x; + for (x = 0; x < w; x++) + { + + deValue r = data[p] / 255.0; + p++; + deValue g = data[p] / 255.0; + p++; + deValue b = data[p] / 255.0; + p++; + pixels0[pos] = r; + pixels1[pos] = g; + pixels2[pos] = b; + pos++; + } + } + + logInfo("loadJPEG " + fileName + " done"); + + image.finishWriteStatic(0); + image.finishWriteStatic(1); + image.finishWriteStatic(2); + + image.unlock(); + return true; +} + +bool saveImage(const std::string& fileName, const deImage& image, const std::string& type, deChannelManager& previewChannelManager) +{ + bool result = false; + + if (image.getColorSpace() == deColorSpaceRGB) + { + if (type == "tiff") + { + const deValue* vr = image.startRead(0); + const deValue* vg = image.startRead(1); + const deValue* vb = image.startRead(2); + result = saveTIFF(fileName, vr, vg, vb, image.getChannelSize()); + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + } + if (type == "jpg") + { + const deValue* vr = image.startRead(0); + const deValue* vg = image.startRead(1); + const deValue* vb = image.startRead(2); + saveJPEG(fileName, vr, vg, vb, image.getChannelSize()); + image.finishRead(0); + image.finishRead(1); + image.finishRead(2); + result = true; + } + } + else + { + logInfo("image is not in sRGB, conversion is needed before save..."); + deImage finalImage(deColorSpaceRGB, previewChannelManager); + finalImage.allocateChannels(); + + deConversionProcessor p; + deConversionCPU cpu(4); + p.convertImage(image, finalImage, cpu); + + if (type == "tiff") + { + const deValue* vr = finalImage.startRead(0); + const deValue* vg = finalImage.startRead(1); + const deValue* vb = finalImage.startRead(2); + result = saveTIFF(fileName, vr, vg, vb, image.getChannelSize()); + finalImage.finishRead(0); + finalImage.finishRead(1); + finalImage.finishRead(2); + } + if (type == "jpg") + { + const deValue* vr = finalImage.startRead(0); + const deValue* vg = finalImage.startRead(1); + const deValue* vb = finalImage.startRead(2); + saveJPEG(fileName, vr, vg, vb, image.getChannelSize()); + finalImage.finishRead(0); + finalImage.finishRead(1); + finalImage.finishRead(2); + result = true; + } + } + + return result; +} + +bool loadImage(const std::string& fileName, deStaticImage& image) +{ + wxLogNull noerrormessages; + + if (loadTIFF(fileName, image)) + { + return true; + } + if (loadJPEG(fileName, image)) + { + return true; + } + return false; +} + diff -Nru delaboratory-0.7/gui_wx/image_io.h delaboratory-0.8/gui_wx/image_io.h --- delaboratory-0.7/gui_wx/image_io.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_io.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,35 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_IMAGE_IO_H +#define _DE_IMAGE_IO_H + +#include +#include "size.h" +#include "color_space.h" +class deStaticImage; +class deImage; +class deChannelManager; + +bool loadImage(const std::string& fileName, deStaticImage& image); + +bool loadPPM(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace); + +bool saveImage(const std::string& fileName, const deImage& image, const std::string& type, deChannelManager& previewChannelManager); + +#endif diff -Nru delaboratory-0.7/gui_wx/image_panel.cc delaboratory-0.8/gui_wx/image_panel.cc --- delaboratory-0.7/gui_wx/image_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_panel.cc 2012-06-24 22:28:27.000000000 +0000 @@ -0,0 +1,273 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "image_panel.h" +#include +#include "project.h" +#include "base_layer.h" +#include "layer_processor.h" +#include +#include "str.h" +#include "layer_frame_manager.h" +#include "zoom_manager.h" +#include "zoom_panel.h" +#include "image_area_panel.h" +#include "canvas_wx.h" + +void deImagePanel::click(wxMouseEvent &event) +{ + int ex = event.GetX(); + int ey = event.GetY(); + int xx; + int yy; + GetSize(&xx, &yy); + float x = (float) ex / xx; + float y = (float) ey / yy; + + clicked = true; + + onClick(x,y); + +} + +void deImagePanel::release(wxMouseEvent &event) +{ + clicked = false; + + onRelease(); + + project.getLayerProcessor().onGUIUpdate(); +} + +void deImagePanel::move(wxMouseEvent &event) +{ + int ex = event.GetX(); + int ey = event.GetY(); + int xx; + int yy; + GetSize(&xx, &yy); + float x = (float) ex / xx; + float y = (float) ey / yy; + + if (clicked) + { + if (onMove(x,y)) + { + project.getLayerProcessor().onGUIUpdate(); + } + } + +} + +void deImagePanel::wheel(wxMouseEvent &event) +{ +} + + +bool deImagePanel::onClick(deValue x, deValue y) +{ + if (zoomManager.isInSelectionMode()) + { + bool result = zoomManager.onClick(x, y); + zoomPanel->updateButtons(); + return result; + } + + bool used = project.getLayerFrameManager().onImageClick(x, y); + + if (!used) + { + used = samplerManager.onClick(x, y); + if (used) + { + project.getLayerProcessor().onGUIUpdate(); + } + } + + return used; +} + +bool deImagePanel::onMove(deValue x, deValue y) +{ + if (zoomManager.isInSelectionMode()) + { + bool result = zoomManager.onMove(x, y); + zoomPanel->updateButtons(); + return result; + } + + bool used = project.getLayerFrameManager().onImageClick(x, y); + + if (!used) + { + used = samplerManager.onMove(x, y); + } + + return used; +} + +bool deImagePanel::onRelease() +{ + if (zoomManager.isInSelectionMode()) + { + bool result = zoomManager.onRelease(); + zoomPanel->updateButtons(); + area->updateSize(false); + return result; + } + + samplerManager.onRelease(); + + return false; +} + +deImagePanel::deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel) +:wxPanel(_area, wxID_ANY, wxDefaultPosition, wxDefaultSize), area(_area), project(_project), samplerManager(_samplerManager), zoomManager(_zoomManager), zoomPanel(_zoomPanel) +{ + clicked = false; + + Connect(wxEVT_PAINT, wxPaintEventHandler(deImagePanel::paintEvent)); + Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deImagePanel::click)); + Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deImagePanel::release)); + Connect(wxEVT_MOTION, wxMouseEventHandler(deImagePanel::move)); + Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(deImagePanel::wheel)); +} + +deImagePanel::~deImagePanel() +{ +} + +void deImagePanel::paintEvent(wxPaintEvent & evt) +{ + logInfo("paint event start"); + project.getLayerProcessor().lockLayerProcessor(); + int view = project.getLayerProcessor().getLastValidLayer(); + if (view >= 0) + { + wxBufferedPaintDC dc(this); + + deCanvasWX canvas(dc); + + canvas.clear(); + + render(canvas); + } + else + { + } + project.getLayerProcessor().unlockLayerProcessor(); + logInfo("paint event DONE"); +} + +void deImagePanel::repaintImagePanel() +{ + int view = project.getLayerProcessor().getLastValidLayer(); + if (view >= 0) + { + wxClientDC dc(this); + wxBufferedDC bufferedDC(&dc); + + deCanvasWX canvas(bufferedDC); + + canvas.clear(); + + render(canvas); + } + else + { + } +} + +void deImagePanel::render(deCanvas& canvas) +{ + project.getLayerProcessor().render(canvas); + + if (samplerManager.getMoving()) + { + drawSamplers(canvas); + } + if (zoomManager.isInSelectionMode()) + { + drawSelection(canvas); + } +} + + +void deImagePanel::drawSamplers(deCanvas& canvas) +{ + int w; + int h; + GetSize(&w, &h); + + int n = samplerManager.getNumberOfSamplers(); + int selected = samplerManager.getSelected(); + + int i; + + for (i = 0; i < n; i++) + { + deSampler* sampler = samplerManager.getSampler(i); + if (sampler->isEnabled()) + { + if (i == selected) + { + canvas.setPen(200, 200, 200); + } + else + { + canvas.setPen(0, 0, 0); + } + float x = sampler->getX(); + float y = sampler->getY(); + + if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) + { + canvas.drawCircle(w * x, h * y, 5); + } + } + } + +} + +void deImagePanel::drawSelection(deCanvas& canvas) +{ + int w; + int h; + GetSize(&w, &h); + + deValue x1; + deValue y1; + deValue x2; + deValue y2; + + zoomManager.getSelection(x1, y1, x2, y2); + + int xx1 = w * x1; + int yy1 = h * y1; + int xx2 = w * x2; + int yy2 = h * y2; + + canvas.setPen(220, 220, 220); + + canvas.drawLine(xx1, yy1, xx2, yy1); + canvas.drawLine(xx1, yy2, xx2, yy2); + canvas.drawLine(xx1, yy1, xx1, yy2); + canvas.drawLine(xx2, yy1, xx2, yy2); + +} + diff -Nru delaboratory-0.7/gui_wx/image_panel.h delaboratory-0.8/gui_wx/image_panel.h --- delaboratory-0.7/gui_wx/image_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/image_panel.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,65 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_IMAGE_PANEL_H +#define _DE_IMAGE_PANEL_H + +#include "wx/wx.h" +#include "renderer.h" +#include "value.h" +class deProject; +class deSamplerManager; +class deZoomManager; +class deZoomPanel; +class deImageAreaPanel; +class deCanvas; + +class deImagePanel:public wxPanel +{ +private: + deImageAreaPanel* area; + + deProject& project; + bool clicked; + deSamplerManager& samplerManager; + deZoomManager& zoomManager; + deZoomPanel* zoomPanel; + + void click(wxMouseEvent &event); + void release(wxMouseEvent &event); + void move(wxMouseEvent &event); + void wheel(wxMouseEvent &event); + + bool onClick(deValue x, deValue y); + bool onMove(deValue x, deValue y); + bool onRelease(); + + void drawSamplers(deCanvas& canvas); + void drawSelection(deCanvas& canvas); + void render(deCanvas& canvas); + +public: + deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel); + virtual ~deImagePanel(); + + void paintEvent(wxPaintEvent & evt); + void repaintImagePanel(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/layer_frame_manager.cc delaboratory-0.8/gui_wx/layer_frame_manager.cc --- delaboratory-0.7/gui_wx/layer_frame_manager.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_frame_manager.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,139 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_frame_manager.h" +#include "layer_frame.h" +#include "str.h" +#include "logger.h" + +deLayerFrameManager::deLayerFrameManager() +{ +} + +deLayerFrameManager::~deLayerFrameManager() +{ + destroyAllFrames(); +} + +void deLayerFrameManager::destroyAllFrames() +{ + while (layerFrames.size() > 0) + { + std::map::iterator i = layerFrames.begin(); + layerFrames.erase(i); + delete i->second; + } +} + + +bool deLayerFrameManager::addLayerFrame(int index, deLayerFrame* frame) +{ + std::map::iterator i = layerFrames.find(index); + if (i != layerFrames.end()) + { + return false; + } + layerFrames[index] = frame; + return true; +} + +bool deLayerFrameManager::removeLayerFrame(int index) +{ + logInfo("remove layer frame " + str(index)); + std::map::iterator i = layerFrames.find(index); + if (i == layerFrames.end()) + { + return false; + } + layerFrames.erase(i); + logInfo("remove layer frame " + str(index) + " DONE"); + return true; +} + +bool deLayerFrameManager::destroyLayerFrame(int index) +{ + logInfo("destroy layer frame " + str(index)); + std::map::iterator i = layerFrames.find(index); + if (i == layerFrames.end()) + { + return false; + } + deLayerFrame* frame = i->second; + logInfo("b destroy layer frame " + str(index)); + if (frame) + { + delete frame; + } + else + { + logError("broken layer frame detected!"); + } + logInfo("c destroy layer frame " + str(index)); + return true; +} + +void deLayerFrameManager::onDestroyLayer(int index) +{ + logInfo("c onDestroyLayer " + str(index)); + destroyLayerFrame(index); + logInfo("onDestroyLayer " + str(index) + " DONE"); +} + +bool deLayerFrameManager::onImageClick(deValue x, deValue y) +{ + { + std::map::iterator i = layerFrames.begin(); + for (i = layerFrames.begin(); i != layerFrames.end(); i++) + { + deLayerFrame* layerFrame = i->second; + if (layerFrame) + { + bool result = layerFrame->onImageClick(x, y); + if (result) + { + return result; + } + } + } + } + return false; +} + +void deLayerFrameManager::onKey(int key) +{ + std::map::iterator i = layerFrames.begin(); + for (i = layerFrames.begin(); i != layerFrames.end(); i++) + { + deLayerFrame* layerFrame = i->second; + if (layerFrame) + { + layerFrame->onKey(key); + } + } +} + +bool deLayerFrameManager::checkLayerFrame(int index) +{ + std::map::iterator i = layerFrames.find(index); + if (i != layerFrames.end()) + { + return true; + } + return false; +} + diff -Nru delaboratory-0.7/gui_wx/layer_frame_manager.h delaboratory-0.8/gui_wx/layer_frame_manager.h --- delaboratory-0.7/gui_wx/layer_frame_manager.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_frame_manager.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,55 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_FRAME_MANAGER_H +#define _DE_LAYER_FRAME_MANAGER_H + +#include + +#include "value.h" + +class deLayerFrame; +#include + +class deLayerFrameManager +{ + private: + std::map layerFrames; + deLayerFrameManager(const deLayerFrameManager& ); + deLayerFrameManager& operator =(const deLayerFrameManager& ); + + public: + deLayerFrameManager(); + virtual ~deLayerFrameManager(); + + void onDestroyLayer(int index); + + bool onImageClick(deValue x, deValue y); + void onKey(int key); + + void destroyAllFrames(); + + bool addLayerFrame(int index, deLayerFrame* frame); + bool removeLayerFrame(int index); + bool destroyLayerFrame(int index); + + bool checkLayerFrame(int index); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/layer_grid_panel.cc delaboratory-0.8/gui_wx/layer_grid_panel.cc --- delaboratory-0.7/gui_wx/layer_grid_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_grid_panel.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,179 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_grid_panel.h" + +#include "project.h" +#include +#include "base_layer_with_source.h" +#include "switchable_layer.h" + +#include + +#include "layer_factory.h" +#include "layer_processor.h" + +#include "frame.h" + +#include "str.h" + +#include "layer_stack.h" + +#include "window_wx.h" + +#include "gui.h" + +void deLayerGridPanel::buildRows() +{ + logInfo("build rows"); + + deLayerStack& layerStack = project.getLayerStack(); + int n = layerStack.getSize(); + + int idWidth = 24; + int actionWidth = 200; + + int i; + for (i = n-1; i >=0; i--) + { + const deBaseLayer* layer = layerStack.startReadLayer(i); + + layerRows.push_back(deLayerRow(i)); + deLayerRow& row = layerRows.back(); + + std::ostringstream oss; + oss << i; + + row.id = new wxStaticText(this, wxID_ANY, wxString::FromAscii(oss.str().c_str()), wxDefaultPosition, wxSize(idWidth, -1)); + gridSizer->Add(row.id, 0, wxALIGN_CENTER); + + int style = 0; + if (i == n-1) + { + style = wxRB_GROUP; + } + + row.view = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); + gridSizer->Add(row.view, 0, wxALIGN_CENTER); + + std::string action = layer->getType(); + + row.action = new wxButton(this, wxID_ANY, wxString::FromAscii(action.c_str()), wxDefaultPosition, wxSize(actionWidth,25)); + if (action.size() > 0) + { + gridSizer->Add(row.action, 0); + } + else + { + gridSizer->Add(row.action, 0); + row.action->Hide(); + } + + layerStack.finishReadLayer(i); + + } +} + +void deLayerGridPanel::clearRows() +{ + logInfo("clear rows"); + + std::vector::iterator i; + int index = 0; + for (i = layerRows.begin(); i != layerRows.end(); i++) + { + index++; + deLayerRow& row = *i; + + gridSizer->Detach(row.id); + delete row.id; + + gridSizer->Detach(row.view); + delete row.view; + + gridSizer->Detach(row.action); + delete row.action; + + } + + gridSizer->Clear(); + + layerRows.clear(); +} + +deLayerGridPanel::deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deChannelManager& _channelManager, deGUI& gui) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(250, 400)), +project(_project), layerProcessor(_processor), channelManager(_channelManager) +{ + gui.setLayerGridPanel(this); + + gridSizer = new wxFlexGridSizer(3); + gridSizer->SetFlexibleDirection(wxHORIZONTAL); + SetSizer(gridSizer); + + buildRows(); + + SetMinSize(wxSize(300, 360)); + + Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deLayerGridPanel::select)); + Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deLayerGridPanel::click)); +} + +deLayerGridPanel::~deLayerGridPanel() +{ +} + +void deLayerGridPanel::select(wxCommandEvent &event) +{ + int id = event.GetId(); + std::vector::const_iterator i; + for (i = layerRows.begin(); i != layerRows.end(); i++) + { + const deLayerRow& row = *i; + if (row.view->GetId() == id) + { + project.getViewManager().setView(row.index); + layerProcessor.onChangeViewMode(); + } + } +} + +void deLayerGridPanel::click(wxCommandEvent &event) +{ + deLayerStack& layerStack = project.getLayerStack(); + int id = event.GetId(); + std::vector::const_iterator i; + for (i = layerRows.begin(); i != layerRows.end(); i++) + { + const deLayerRow& row = *i; + if (row.action->GetId() == id) + { + project.openLayerFrame(row.index); + } + } + +} + +void deLayerGridPanel::update() +{ + clearRows(); + buildRows(); + Layout(); + layerProcessor.onGUIUpdate(); +} + diff -Nru delaboratory-0.7/gui_wx/layer_grid_panel.h delaboratory-0.8/gui_wx/layer_grid_panel.h --- delaboratory-0.7/gui_wx/layer_grid_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_grid_panel.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,74 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_GRID_PANEL_H +#define _DE_LAYER_GRID_PANEL_H + +#include +#include +#include + +class deProject; +class deLayerProcessor; +class deChannelManager; +class deGUI; + +class deLayerGridPanel:public wxPanel +{ + class deLayerRow + { + public: + deLayerRow(int _index) + :index(_index) + { + }; + + int index; + wxStaticText* id; + wxRadioButton* view; + wxButton* action; + }; + + private: + std::vector layerRows; + + deProject& project; + deLayerProcessor& layerProcessor; + + wxSizer* mainSizer; + + wxFlexGridSizer* gridSizer; + deChannelManager& channelManager; + + int maxRows; + + void select(wxCommandEvent &event); + void click(wxCommandEvent &event); + + public: + deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deChannelManager& _channelManager, deGUI& gui); + ~deLayerGridPanel(); + + void buildRows(); + void clearRows(); + + void update(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/layer_processor_threads.cc delaboratory-0.8/gui_wx/layer_processor_threads.cc --- delaboratory-0.7/gui_wx/layer_processor_threads.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_processor_threads.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,258 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "layer_processor_threads.h" +#include "layer_processor.h" +#include "main_window.h" +#include "main_frame.h" +#include "layer_frame_manager.h" +#include "layer_stack.h" +#include "view_manager.h" +#include +#include "base_layer.h" +#include "channel_manager.h" +#include "str.h" +#include +#include +#include "logger.h" +#include "renderer.h" +#include "image_io.h" + +class deLayerProcessorWorkerThread:public wxThread +{ + private: + void performTasks() + { + while (true) + { + if (processor.isClosing()) + { + return; + } + +#ifdef DEBUG_LOG + logInfo("worker thread wait..."); +#endif + semaphore.wait(); + Sleep(10); + + if (TestDestroy()) + { + return; + } + + processor.tickWork(); + + if (TestDestroy()) + { + return; + } + } + } + + virtual void *Entry() + { + performTasks(); + logInfo("worker thread finished"); + return NULL; + } + deLayerProcessor& processor; + deSemaphore& semaphore; + + public: + deLayerProcessorWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) + :processor(_processor), + semaphore(_semaphore) + { + logInfo("worker thread created"); + } + virtual ~deLayerProcessorWorkerThread() + { + } +}; + +class deRenderWorkerThread:public wxThread +{ + private: + void performTasks() + { + while (true) + { + if (processor.isClosing()) + { + return; + } + +#ifdef DEBUG_LOG + logInfo("render thread wait..."); +#endif + semaphore.wait(); + Sleep(10); + + if (TestDestroy()) + { + return; + } + + if (processor.prepareImage()) + { + processor.sendRepaintEvent(); + } + + if (TestDestroy()) + { + return; + } + } + } + + virtual void *Entry() + { + performTasks(); + logInfo("render thread finished"); + return NULL; + } + + deLayerProcessor& processor; + deSemaphore& semaphore; + + public: + deRenderWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) + :processor(_processor), + semaphore(_semaphore) + { + logInfo("render thread created"); + } + virtual ~deRenderWorkerThread() + { + } +}; + +class deHistogramWorkerThread:public wxThread +{ + private: + void performTasks() + { + while (true) + { + if (processor.isClosing()) + { + return; + } + +#ifdef DEBUG_LOG + logInfo("histogram thread wait..."); +#endif + semaphore.wait(); + Sleep(10); + + if (TestDestroy()) + { + return; + } + + processor.onGenerateHistogram(); + processor.sendHistogramEvent(); + + if (TestDestroy()) + { + return; + } + } + } + + virtual void *Entry() + { + performTasks(); + logInfo("histogram thread finished"); + return NULL; + } + + deLayerProcessor& processor; + deSemaphore& semaphore; + + public: + deHistogramWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) + :processor(_processor), + semaphore(_semaphore) + { + logInfo("histogram thread created"); + } + virtual ~deHistogramWorkerThread() + { + } +}; + + + +void deLayerProcessorThreads::stopWorkerThread() +{ + logInfo("stop worker, render and histogram threads"); + + workerSemaphore.post(); + workerThread->Delete(); + + renderWorkerSemaphore.post(); + renderWorkerThread->Delete(); + + histogramWorkerSemaphore.post(); + histogramWorkerThread->Delete(); + + wxThread::Sleep(200); + + logInfo("stopped worker, render and histogram threads"); + +} + +void deLayerProcessorThreads::startWorkerThread() +{ + logInfo("start worker, render and histogram threads"); + + workerThread = new deLayerProcessorWorkerThread(layerProcessor, workerSemaphore); + + if ( workerThread->Create() != wxTHREAD_NO_ERROR ) + { + } + + if ( workerThread->Run() != wxTHREAD_NO_ERROR ) + { + } + + renderWorkerThread = new deRenderWorkerThread(layerProcessor, renderWorkerSemaphore); + + if ( renderWorkerThread->Create() != wxTHREAD_NO_ERROR ) + { + } + + if ( renderWorkerThread->Run() != wxTHREAD_NO_ERROR ) + { + } + + histogramWorkerThread = new deHistogramWorkerThread(layerProcessor, histogramWorkerSemaphore); + + if ( histogramWorkerThread->Create() != wxTHREAD_NO_ERROR ) + { + } + + if ( histogramWorkerThread->Run() != wxTHREAD_NO_ERROR ) + { + } + + logInfo("started worker, render and histogram threads"); +} + diff -Nru delaboratory-0.7/gui_wx/layer_processor_threads.h delaboratory-0.8/gui_wx/layer_processor_threads.h --- delaboratory-0.7/gui_wx/layer_processor_threads.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/layer_processor_threads.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,81 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LAYER_PROCESSOR_THREADS_H +#define _DE_LAYER_PROCESSOR_THREADS_H + +class deMainWindow; +class deLayerStack; +class deViewManager; +class deChannelManager; +class wxProgressDialog; +class deLayer; +class deLogger; +class deLayerFrameManager; +class wxThread; +#include +#include "size.h" +#include "renderer.h" +#include "semaphore.h" +#include "base_layer.h" + + +class deLayerProcessorThreads +{ + private: + deLayerProcessor& layerProcessor; + wxThread* workerThread; + wxThread* renderWorkerThread; + wxThread* histogramWorkerThread; + deSemaphore workerSemaphore; + deSemaphore renderWorkerSemaphore; + deSemaphore histogramWorkerSemaphore; + public: + deLayerProcessorThreads(deLayerProcessor& _layerProcessor) + :layerProcessor(_layerProcessor), + workerSemaphore(1,1), + renderWorkerSemaphore(1, 1), + histogramWorkerSemaphore(1, 1) + { + histogramWorkerThread = NULL; + workerThread = NULL; + renderWorkerThread = NULL; + + }; + virtual ~deLayerProcessorThreads() + { + }; + void startWorkerThread(); + void stopWorkerThread(); + void renderPost() + { + renderWorkerSemaphore.post(); + } + void histogramPost() + { + histogramWorkerSemaphore.post(); + } + void workerPost() + { + workerSemaphore.post(); + } + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/logger.cc delaboratory-0.8/gui_wx/logger.cc --- delaboratory-0.7/gui_wx/logger.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/logger.cc 2012-06-27 18:13:03.000000000 +0000 @@ -0,0 +1,170 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "logger.h" +#include "str.h" +#include +#include + +#define LOCK_THRESHOLD 100 +#define LOGGING 1 + +static bool loggerActive = false; + +class deLoggerHelp +{ + private: + public: + wxThreadIdType main_id; + wxStopWatch sw; + deLoggerHelp() + { + } + virtual ~deLoggerHelp() + { + } + +}; + +deLogger& deLogger::getLogger() +{ + static deLogger logger; + return logger; +} + +deLogger::deLogger() +{ + help = new deLoggerHelp(); + f = NULL; + started = false; + loggerActive = true; +} + +deLogger::~deLogger() +{ + logInfo("closing logger..."); + loggerActive = false; + + mutex.lock(); + + if (f) + { + f->close(); + delete f; + } + + delete help; + + mutex.unlock(); +} + +void deLogger::setFile(const std::string& fileName) +{ +#ifdef LOGGING + mutex.lock(); + + if (f) + { + f->close(); + delete f; + } + + f = new std::ofstream(fileName.c_str()); + if (!f) + { + logError("can't create logfile: " + fileName); + } + + mutex.unlock(); +#endif +} + +std::string deLogger::getThreadName() +{ + if (!started) + { + help->main_id = wxThread::GetCurrentId(); + started = true; + } + + wxThreadIdType c_id = wxThread::GetCurrentId(); + + std::string thr = "main"; + + if (help->main_id != c_id) + { + std::ostringstream oss; + oss.str(""); + oss << c_id; + thr = oss.str(); + } + + return thr; +} + +void deLogger::log(const std::string& message) +{ + mutex.lock(); + + if (f) + { + int t = help->sw.Time(); + + (*f) << t << ": [" << getThreadName() << "] " << message << std::endl; + } + + mutex.unlock(); +} + +void deLogger::logInfo(const std::string& message) +{ + log("INFO " + message); +} + +int deLogger::getTime() const +{ + int t = help->sw.Time(); + return t; +} + +void logInfo(const std::string& message) +{ +#ifdef LOGGING + if (loggerActive) + { + deLogger::getLogger().logInfo(message); + } +#endif +} + +static deMutex logErrorMutex; + +void logError(const std::string& message) +{ + const std::string m = "ERROR " + message; + logErrorMutex.lock(); + std::cout << m << std::endl; + logErrorMutex.unlock(); +#ifdef LOGGING + if (loggerActive) + { + deLogger::getLogger().log(m); + } +#endif +} + diff -Nru delaboratory-0.7/gui_wx/logger.h delaboratory-0.8/gui_wx/logger.h --- delaboratory-0.7/gui_wx/logger.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/logger.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,55 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LOGGER_H +#define _DE_LOGGER_H + +#include +#include +#include "mutex.h" + +class deLoggerHelp; + +class deLogger +{ + private: + deLoggerHelp* help; + std::ofstream* f; + deMutex mutex; + bool started; + + std::string getThreadName(); + + deLogger(); + + public: + static deLogger& getLogger(); + virtual ~deLogger(); + + void setFile(const std::string& fileName); + + void log(const std::string& message); + void logInfo(const std::string& message); + + int getTime() const; +}; + +void logInfo(const std::string& message); +void logError(const std::string& message); + +#endif diff -Nru delaboratory-0.7/gui_wx/main_frame.cc delaboratory-0.8/gui_wx/main_frame.cc --- delaboratory-0.7/gui_wx/main_frame.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/main_frame.cc 2012-07-29 04:13:49.000000000 +0000 @@ -0,0 +1,582 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "main_frame.h" +#include "layer_grid_panel.h" +#include "control_panel.h" +#include "image_area_panel.h" +#include "histogram_panel.h" +#include "view_mode_panel.h" +#include "histogram_mode_panel.h" +#include "help_color_spaces_frame.h" +#include "help_color_spaces_frame2.h" +#include "help_color_spaces_frame3.h" +#include "help_color_spaces_frame4.h" +#include "help_color_spaces_frame5.h" +#include "help_color_spaces_frame6.h" +#include "color_matrix_frame.h" +#include "project.h" +#include "str.h" +#include "str_wx.h" +#include "file_dialogs.h" +#include "delaboratory.h" +#include "samplers_panel.h" +#include "layer_processor.h" +#include "zoom_panel.h" +#include "threads_panel.h" +#include "warning_panel.h" +#include "layer_stack.h" + +#include "image_panel.h" + +#include "wx/thread.h" +#include "wx/notebook.h" +#include "progress_dialog.h" + +BEGIN_EVENT_TABLE(deMainFrame, wxFrame) +#ifdef __WXOSX_MAC__ + EVT_MENU(wxID_EXIT, deMainFrame::onQuit) +#else + EVT_MENU(ID_Quit, deMainFrame::onQuit) +#endif + +EVT_MENU(ID_NewProject, deMainFrame::onNewProject) +EVT_MENU(ID_TestImageSmall, deMainFrame::onTestImageSmall) +EVT_MENU(ID_TestImageBig, deMainFrame::onTestImageBig) +EVT_MENU(ID_OpenImage, deMainFrame::onOpenImage) +EVT_MENU(ID_OpenRawImageProPhoto, deMainFrame::onOpenRawImageProPhoto) +EVT_MENU(ID_OpenRawImageRGB, deMainFrame::onOpenRawImageRGB) +EVT_MENU(ID_OpenRawImageProPhotoAB, deMainFrame::onOpenRawImageProPhotoAB) +EVT_MENU(ID_OpenRawImageRGBAB, deMainFrame::onOpenRawImageRGBAB) +EVT_MENU(ID_HelpColorSpaces, deMainFrame::onHelpColorSpaces) +EVT_MENU(ID_HelpColorSpaces2, deMainFrame::onHelpColorSpaces2) +EVT_MENU(ID_HelpColorSpaces3, deMainFrame::onHelpColorSpaces3) +EVT_MENU(ID_HelpColorSpaces4, deMainFrame::onHelpColorSpaces4) +EVT_MENU(ID_HelpColorSpaces5, deMainFrame::onHelpColorSpaces5) +EVT_MENU(ID_LABColors1, deMainFrame::onLABColors1) +EVT_MENU(ID_LABColors2, deMainFrame::onLABColors2) +EVT_MENU(ID_LABColors5, deMainFrame::onLABColors5) +EVT_MENU(ID_ColorMatrix1, deMainFrame::onColorMatrix1) +EVT_MENU(ID_ColorMatrix2, deMainFrame::onColorMatrix2) +EVT_MENU(ID_ColorMatrix3, deMainFrame::onColorMatrix3) +EVT_MENU(ID_ColorMatrix4, deMainFrame::onColorMatrix4) +EVT_MENU(ID_ColorMatrix5, deMainFrame::onColorMatrix5) +EVT_MENU(DE_REPAINT_EVENT, deMainFrame::onRepaintEvent) +EVT_MENU(DE_IMAGE_LOAD_EVENT, deMainFrame::onImageLoadEvent) +EVT_MENU(DE_HISTOGRAM_EVENT, deMainFrame::onHistogramEvent) +EVT_MENU(DE_INFO_EVENT, deMainFrame::onInfoEvent) +EVT_MENU(DE_WARNING_EVENT, deMainFrame::onWarningEvent) +EVT_MENU(ID_ExportGIMP, deMainFrame::onExportGIMP) +EVT_MENU(ID_ExportTIFF, deMainFrame::onExportTIFF) +EVT_MENU(ID_ExportJPG, deMainFrame::onExportJPG) +EVT_MENU(ID_ExportAll, deMainFrame::onExportAll) +END_EVENT_TABLE() + +deMainFrame::deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcraw_version, deOperationProcessor& _operationProcessor, deChannelManager& channelManager, deGUI& _gui) +: wxFrame() , project(_project), layerProcessor(_layerProcessor), imageSize(0,0), gui(_gui) +{ + logInfo("main frame constructor"); + + imageName = ""; + +#ifdef __WXOSX_MAC__ + Create((wxFrame *)NULL, wxID_ANY, _T("main frame")); +#else + Create((wxFrame *)NULL, wxID_ANY, _T("main frame"), wxDefaultPosition, size, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE); +#endif + +#ifdef _WIN32 + SetIcon(wxICON(id)); +#endif + + updateTitle(); + + mainSizer = new wxBoxSizer(wxHORIZONTAL); + + wxSizer* leftSizer = new wxBoxSizer(wxVERTICAL); + mainSizer->Add(leftSizer, 1, wxEXPAND); + + topPanel = new wxPanel(this); + leftSizer->Add(topPanel, 0, wxEXPAND); + + wxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL); + topPanel->SetSizer(topSizer); + + wxPanel* viewModePanel = new deViewModePanel(topPanel, project, gui); + topSizer->Add(viewModePanel); + + threadsPanel = new deThreadsPanel(topPanel); + topSizer->Add(threadsPanel, 0, wxEXPAND); + + deZoomPanel* zoomPanel = new deZoomPanel(topPanel, _zoomManager); + topSizer->Add(zoomPanel); + + warningPanel = new deWarningPanel(topPanel); + topSizer->Add(warningPanel, 0, wxEXPAND); + + wxSizer* sizerI = new wxStaticBoxSizer(wxVERTICAL, this, _T("image")); + leftSizer->Add(sizerI, 1, wxEXPAND); + + imageAreaPanel = new deImageAreaPanel(this, project, _samplerManager, _zoomManager, zoomPanel, gui); + sizerI->Add(imageAreaPanel, 1, wxEXPAND); + + wxSizer* rightSizer = new wxBoxSizer(wxVERTICAL); + hPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(280, 250)); + wxSizer* sizerH = new wxStaticBoxSizer(wxVERTICAL, hPanel, _T("histogram")); + hPanel->SetSizer(sizerH); + + histogramPanel = new deHistogramPanel(hPanel, &project, 260, 2); + sizerH->Add(histogramPanel, 0, wxCENTER); + + deHistogramModePanel* histogramModePanel = new deHistogramModePanel(hPanel, project, histogramPanel, gui); + sizerH->Add(histogramModePanel, 0, wxLEFT); + + rightSizer->Add(hPanel, 0, wxEXPAND); + + wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); + rightSizer->Add(notebook, 1, wxEXPAND); + + layerGridPanel = new deLayerGridPanel(notebook, project, _layerProcessor, channelManager, gui); + + notebook->AddPage(layerGridPanel, _T("layers")); + samplersPanel = new deSamplersPanel(notebook, project, _samplerManager); + notebook->AddPage(samplersPanel, _T("samplers")); + + controlPanel = new deControlPanel(this, project, _layerProcessor, _operationProcessor, channelManager); + rightSizer->Add(controlPanel, 0, wxEXPAND); + + mainSizer->Add(rightSizer, 0, wxEXPAND); + + SetSizer(mainSizer); + + full = false; + + wxMenu *menuFile = new wxMenu; + menuFile->Append( ID_NewProject, _("New project") ); + menuFile->AppendSeparator(); + menuFile->Append( ID_OpenRawImageProPhoto, _("Open RAW image as ProPhoto RGB (default)") ); + menuFile->Append( ID_OpenRawImageRGB, _("Open RAW image as sRGB") ); + menuFile->Append( ID_OpenRawImageProPhotoAB, _("Open RAW image as ProPhoto RGB - auto brighten") ); + menuFile->Append( ID_OpenRawImageRGBAB, _("Open RAW image as sRGB - auto brighten") ); + menuFile->Append( ID_OpenImage, _("Open TIFF/JPG image") ); + menuFile->AppendSeparator(); + menuFile->Append( ID_TestImageSmall, _("Generate test image (small)") ); + menuFile->Append( ID_TestImageBig, _("Generate test image (big, slow)") ); + menuFile->AppendSeparator(); +#ifdef __WXOSX_MAC__ + menuFile->Append( wxID_EXIT, _("E&xit") ); +#else + menuFile->Append( ID_Quit, _("E&xit") ); +#endif + + + wxMenu *menuExport = new wxMenu; + menuExport->Append( ID_ExportGIMP, _("Send to External Editor") ); + menuExport->Append( ID_ExportTIFF, _("Export 16-bit TIFF") ); + menuExport->Append( ID_ExportAll, _("Export all layers to 16-bit TIFFs") ); + menuExport->Append( ID_ExportJPG, _("Export JPG") ); + + wxMenu *menuHelp = new wxMenu; + menuHelp->Append( ID_HelpColorSpaces, _("channels") ); + menuHelp->Append( ID_HelpColorSpaces2, _("mix of channels") ); + menuHelp->Append( ID_HelpColorSpaces3, _("lightness/value in LAB/LCH/HSL/HSV") ); + menuHelp->Append( ID_HelpColorSpaces4, _("hue in LCH/HSL/HSV") ); + menuHelp->Append( ID_HelpColorSpaces5, _("CMYK skin colors") ); + menuHelp->Append( ID_LABColors1, _("LAB colors 1") ); + menuHelp->Append( ID_LABColors2, _("LAB colors 2") ); + menuHelp->Append( ID_LABColors5, _("LAB colors 5") ); + + wxMenu *menuPalette = new wxMenu; + menuPalette->Append( ID_ColorMatrix1, _("LAB color matrix 40x40") ); + menuPalette->Append( ID_ColorMatrix2, _("LAB color matrix 20x20") ); + menuPalette->Append( ID_ColorMatrix3, _("color tiles 20") ); + menuPalette->Append( ID_ColorMatrix4, _("color tiles 40") ); + menuPalette->Append( ID_ColorMatrix5, _("color tiles 80") ); + + wxMenuBar *menuBar = new wxMenuBar; + menuBar->Append( menuFile, _("&File") ); + menuBar->Append( menuExport, _("&Export") ); + menuBar->Append( menuPalette, _("&Palette") ); + menuBar->Append( menuHelp, _("&Channels") ); + + SetMenuBar( menuBar ); + + Layout(); + + imageAreaPanel->SetFocus(); + Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deMainFrame::check)); + + Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(deMainFrame::onCloseEvent)); + + Connect(wxEVT_TIMER, wxTimerEventHandler(deMainFrame::onTimerEvent)); + + threadsPanel->setInfoColor(DE_DCRAW_END); +} + +#define TILE1 20 +#define TILE2 40 +#define TILE3 60 +#define TILER1 30 +#define TILER2 50 +#define TILER3 80 +#define PALRW 60 +#define PALRH 40 +#define PAL1 16 +#define PAL2 12 +#define PAL3 10 +#define MAR1 0.03 +#define MAR2 0.06 + + +deMainFrame::~deMainFrame() +{ + logInfo("main frame destructor"); + layerProcessor.stopWorkerThread(); + layerProcessor.lockLayerProcessor(); + layerProcessor.unlockLayerProcessor(); +} + +void deMainFrame::rebuild() +{ + topPanel->Layout(); + topPanel->Update(); + topPanel->Refresh(); +} + +void deMainFrame::onKey(int key) +{ +} + +void deMainFrame::onQuit(wxCommandEvent& WXUNUSED(event)) +{ + logInfo("main frame onQuit"); + Close(TRUE); +} + +void deMainFrame::onNewProject(wxCommandEvent& WXUNUSED(event)) +{ + project.newProject(); +} + +void deMainFrame::onTestImageSmall(wxCommandEvent& WXUNUSED(event)) +{ + project.setTestImage(900); +} + +void deMainFrame::onTestImageBig(wxCommandEvent& WXUNUSED(event)) +{ + project.setTestImage(1800); +} + +void deMainFrame::onOpenImage(wxCommandEvent& WXUNUSED(event)) +{ + std::string f = getOpenFile(this, "load source image", "image", openDirectory); + if (!f.empty()) + { + openDirectory = getPath(f); + project.openImage(f, false, false, false); + } +} + +void deMainFrame::onOpenRawImageProPhoto(wxCommandEvent& WXUNUSED(event)) +{ + std::string f = getOpenFile(this, "load source image", "raw", openDirectory); + if (!f.empty()) + { + openDirectory = getPath(f); + project.openImage(f, true, false, false); + } +} + +void deMainFrame::onOpenRawImageRGB(wxCommandEvent& WXUNUSED(event)) +{ + std::string f = getOpenFile(this, "load source image", "raw", openDirectory); + if (!f.empty()) + { + openDirectory = getPath(f); + project.openImage(f, true, true, false); + } +} + +void deMainFrame::onOpenRawImageProPhotoAB(wxCommandEvent& WXUNUSED(event)) +{ + std::string f = getOpenFile(this, "load source image", "raw", openDirectory); + if (!f.empty()) + { + openDirectory = getPath(f); + project.openImage(f, true, false, true); + } +} + +void deMainFrame::onOpenRawImageRGBAB(wxCommandEvent& WXUNUSED(event)) +{ + std::string f = getOpenFile(this, "load source image", "raw", openDirectory); + if (!f.empty()) + { + openDirectory = getPath(f); + project.openImage(f, true, true, true); + } +} + +void deMainFrame::onHelpColorSpaces(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame(this); + help->Show(); +} + +void deMainFrame::onHelpColorSpaces2(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame2(this); + help->Show(); +} + +void deMainFrame::onHelpColorSpaces3(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame3(this); + help->Show(); +} + +void deMainFrame::onHelpColorSpaces4(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame4(this); + help->Show(); +} + +void deMainFrame::onHelpColorSpaces5(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame5(this); + help->Show(); +} + +void deMainFrame::onLABColors1(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame6(this, 1); + help->Show(); +} + +void deMainFrame::onLABColors2(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame6(this, 2); + help->Show(); +} + +void deMainFrame::onLABColors5(wxCommandEvent& event) +{ + wxFrame* help = new deHelpColorSpacesFrame6(this, 5); + help->Show(); +} + +void deMainFrame::onColorMatrix1(wxCommandEvent& event) +{ + dePalette3* palette = NULL; + wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 32, 32, palette); + help->Show(); +} + +void deMainFrame::onColorMatrix2(wxCommandEvent& event) +{ + dePalette3* palette = NULL; + wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 16, 16, palette); + help->Show(); +} + +void deMainFrame::onColorMatrix3(wxCommandEvent& event) +{ + wxFrame* help = new deColorMatrixFrame(this, project, 20, 20, 20, 20, 40, 40, 12, 0.1); + help->Show(); +} + +void deMainFrame::onColorMatrix4(wxCommandEvent& event) +{ + wxFrame* help = new deColorMatrixFrame(this, project, 40, 40, 40, 40, 40, 40, 12, 0.1); + help->Show(); +} + +void deMainFrame::onColorMatrix5(wxCommandEvent& event) +{ + wxFrame* help = new deColorMatrixFrame(this, project, 80, 80, 80, 80, 40, 40, 12, 0.1); + help->Show(); +} + +void deMainFrame::onRepaintEvent(wxCommandEvent& event) +{ + repaintMainFrame(true); +} + +void deMainFrame::onImageLoadEvent(wxCommandEvent& event) +{ + layerProcessor.onImageLoad(); +} + +void deMainFrame::onInfoEvent(wxCommandEvent& event) +{ + int i = event.GetInt(); + threadsPanel->setInfoColor(i); +} + +void deMainFrame::onWarningEvent(wxCommandEvent& event) +{ + int view = project.getViewManager().getView(); + deLayerStack& stack = project.getLayerStack(); + const deBaseLayer* layer = stack.startReadLayer(view); + if (layer) + { + std::string warning = layer->getWarning(); + warningPanel->setWarning(warning); + } + stack.finishReadLayer(view); +} + +void deMainFrame::repaintMainFrame(bool calcHistogram) +{ +#ifdef DEBUG_LOG + logInfo("repaint main frame"); +#endif + if (!project.isSourceValid()) + { + return; + } + + imageAreaPanel->getImagePanel()->repaintImagePanel(); + samplersPanel->update(); + +} + +void deMainFrame::check(wxCommandEvent &event) +{ +} + +void deMainFrame::onCloseEvent(wxCloseEvent& event) +{ + logInfo("deMainFrame::onCloseEvent"); + this->Destroy(); +} + +void deMainFrame::generateHistogram() +{ + if (project.getSourceImageSize().getW() == 0) + { + return; + } + if (histogramPanel) + { + histogramPanel->generateHistogram(); + } +} + +void deMainFrame::onHistogramEvent(wxCommandEvent& event) +{ + if (histogramPanel) + { + histogramPanel->paintHistogram(); + } +} + +void deMainFrame::updateTitle() +{ + std::string s = imageName + " " + str(imageSize.getW()) + "x" + str(imageSize.getH()) + " - " + getApplicationName() + " " + getVersion() + " " + getCopyright(); + + SetTitle(str2wx(s)); +} + +void deMainFrame::setImageName(const std::string& _imageName, const deSize& _size) +{ + imageName = _imageName; + imageSize = _size; + updateTitle(); +} + +void deMainFrame::onTimerEvent(wxTimerEvent& event) +{ + project.onTimerUpdate(); +} + +void deMainFrame::updateWarning() +{ +} + +void deMainFrame::forceUpdateSize() +{ + imageAreaPanel->updateSize(false); +} + +void deMainFrame::onExportGIMP(wxCommandEvent& event) +{ +#ifdef __WXOSX_MAC__ + generateFinalImage("/Applications/Gimp.app/Contents/MacOS/Gimp", "tiff", "", false, ""); +#else + generateFinalImage("gimp", "tiff", "", false, ""); +#endif +} + +void deMainFrame::onExportAll(wxCommandEvent& event) +{ + std::string f = getDir(this, "export all images"); + + if (!f.empty()) + { + logInfo("export all images to " + f); + generateFinalImage("", "tiff", "", true, f); + } +} + +void deMainFrame::onExportTIFF(wxCommandEvent& event) +{ + std::string f = getSaveFile(this, "export TIFF", "tiff", saveDirectory); + + if (!f.empty()) + { + saveDirectory = getPath(f); + + if (f.rfind(".tiff") != f.size() - 5) + { + f += ".tiff"; + } + + generateFinalImage("", "tiff", f, false, ""); + } +} + +void deMainFrame::onExportJPG(wxCommandEvent& event) +{ + std::string f = getSaveFile(this, "export JPG", "jpg", saveDirectory); + + if (!f.empty()) + { + saveDirectory = getPath(f); + + if (f.rfind(".jpg") != f.size() - 4) + { + f += ".jpg"; + } + + generateFinalImage("", "jpg", f, false, ""); + } +} + + +bool deMainFrame::generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir) +{ + logInfo("generateFinalImage..."); + + deProgressDialog dialog; + + bool result = project.exportFinalImage(app, type, name, dialog, saveAll, dir); + + return result; +} diff -Nru delaboratory-0.7/gui_wx/main_frame_events.h delaboratory-0.8/gui_wx/main_frame_events.h --- delaboratory-0.7/gui_wx/main_frame_events.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/main_frame_events.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,57 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MAIN_FRAME_EVENTS_H +#define _DE_MAIN_FRAME_EVENTS_H + +enum +{ + ID_Quit = 1, + ID_NewProject, + ID_TestImageSmall, + ID_TestImageBig, + ID_OpenImage, + ID_OpenRawImageProPhoto, + ID_OpenRawImageRGB, + ID_OpenRawImageProPhotoAB, + ID_OpenRawImageRGBAB, + ID_HelpColorSpaces, + ID_HelpColorSpaces2, + ID_HelpColorSpaces3, + ID_HelpColorSpaces4, + ID_HelpColorSpaces5, + ID_LABColors1, + ID_LABColors2, + ID_LABColors5, + ID_ColorMatrix1, + ID_ColorMatrix2, + ID_ColorMatrix3, + ID_ColorMatrix4, + ID_ColorMatrix5, + ID_ExportGIMP, + ID_ExportTIFF, + ID_ExportJPG, + ID_ExportAll, + DE_REPAINT_EVENT, + DE_IMAGE_LOAD_EVENT, + DE_HISTOGRAM_EVENT, + DE_WARNING_EVENT, + DE_INFO_EVENT +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/main_frame.h delaboratory-0.8/gui_wx/main_frame.h --- delaboratory-0.7/gui_wx/main_frame.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/main_frame.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,131 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MAIN_FRAME_H +#define _DE_MAIN_FRAME_H + +#include "wx/wx.h" +class deProject; +class deImageAreaPanel; +class deLayerGridPanel; +class deControlPanel; +class deHistogramPanel; +class deLayerProcessor; +class deSamplersPanel; +class deSamplerManager; +class deZoomManager; +class deThreadsPanel; +class deOperationProcessor; +class deChannelManager; +class deWarningPanel; +#include "size.h" +#include "main_frame_events.h" +#include "gui.h" + +class deMainFrame: public wxFrame +{ +private: + deProject& project; + wxPanel* hPanel; + wxPanel* topPanel; + deLayerGridPanel* layerGridPanel; + deSamplersPanel* samplersPanel; + deControlPanel* controlPanel; + wxSizer* mainSizer; + deImageAreaPanel* imageAreaPanel; + deHistogramPanel* histogramPanel; + deThreadsPanel* threadsPanel; + deWarningPanel* warningPanel; + deGUI& gui; + + std::string imageName; + + deLayerProcessor& layerProcessor; + + deSize imageSize; + + std::string openDirectory; + std::string saveDirectory; + + bool full; + + void onTestImageSmall(wxCommandEvent& event); + void onTestImageBig(wxCommandEvent& event); + void onOpenImage(wxCommandEvent& event); + void onOpenRawImageProPhoto(wxCommandEvent& event); + void onOpenRawImageRGB(wxCommandEvent& event); + void onOpenRawImageProPhotoAB(wxCommandEvent& event); + void onOpenRawImageRGBAB(wxCommandEvent& event); + void onQuit(wxCommandEvent& event); + void onNewProject(wxCommandEvent& event); + void onHelpColorSpaces(wxCommandEvent& event); + void onHelpColorSpaces2(wxCommandEvent& event); + void onHelpColorSpaces3(wxCommandEvent& event); + void onHelpColorSpaces4(wxCommandEvent& event); + void onHelpColorSpaces5(wxCommandEvent& event); + void onLABColors1(wxCommandEvent& event); + void onLABColors2(wxCommandEvent& event); + void onLABColors5(wxCommandEvent& event); + void onColorMatrix1(wxCommandEvent& event); + void onColorMatrix2(wxCommandEvent& event); + void onColorMatrix3(wxCommandEvent& event); + void onColorMatrix4(wxCommandEvent& event); + void onColorMatrix5(wxCommandEvent& event); + void onRepaintEvent(wxCommandEvent& event); + void onImageLoadEvent(wxCommandEvent& event); + void onInfoEvent(wxCommandEvent& event); + void onWarningEvent(wxCommandEvent& event); + void onHistogramEvent(wxCommandEvent& event); + void onTimerEvent(wxTimerEvent& event); + void onExportGIMP(wxCommandEvent& event); + void onExportTIFF(wxCommandEvent& event); + void onExportJPG(wxCommandEvent& event); + void onExportAll(wxCommandEvent& event); + + void onCloseEvent(wxCloseEvent& event); + + void repaintMainFrame(bool calcHistogram); + + void check(wxCommandEvent &event); + + void updateTitle(); + + void paintHistogram(); + + bool generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir); + +public: + deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcrawVersion, deOperationProcessor& _operationProcessor, deChannelManager& channelManager, deGUI& _gui); + ~deMainFrame(); + + void rebuild(); + + void onKey(int key); + + void generateHistogram(); + void updateWarning(); + + void setImageName(const std::string& _imageName, const deSize& _size); + void forceUpdateSize(); + + DECLARE_EVENT_TABLE() + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/main_window.cc delaboratory-0.8/gui_wx/main_window.cc --- delaboratory-0.7/gui_wx/main_window.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/main_window.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,201 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "main_window.h" +#include "main_frame.h" +#include + +class deMainWindowImpl +{ + private: + deMainFrame* frame; + wxTimer* rawTimer; + + public: + deMainWindowImpl() + { + frame = NULL; + } + + ~deMainWindowImpl() + { + } + + void init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui) + { + frame = new deMainFrame( wxSize(width,height), project, layerProcessor, samplerManager, zoomManager, dcrawVersion, operationProcessor, channelManager, gui); + + rawTimer = new wxTimer(frame, wxID_ANY); + } + + void show() + { + if (frame) + { + frame->Show(TRUE); + } + } + + void setTopWindow() + { + if (frame) + { + //SetTopWindow(frame); + } + } + + void postEvent(int e, int arg) + { + if (frame) + { + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, e ); + event.SetInt(arg); + wxPostEvent( frame, event ); + } + } + + void generateHistogram() + { + if (frame) + { + frame->generateHistogram(); + } + } + + void onKey(int key) + { + if (frame) + { + frame->onKey(key); + } + } + + void rebuild() + { + if (frame) + { + frame->rebuild(); + } + } + + void setImageName(const std::string& _imageName, const deSize& _size) + { + if (frame) + { + frame->setImageName(_imageName, _size); + } + } + + void startRawTimer() + { + rawTimer->Start(500); + } + + void stopRawTimer() + { + rawTimer->Stop(); + } + + void updateWarning() + { + if (frame) + { + frame->updateWarning(); + } + } + + void forceUpdateSize() + { + if (frame) + { + frame->forceUpdateSize(); + } + } + + +}; + +deMainWindow::deMainWindow() +{ + impl = new deMainWindowImpl(); +} + +deMainWindow::~deMainWindow() +{ + delete impl; +} + +void deMainWindow::init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui) +{ + impl->init( width, height, project, layerProcessor, samplerManager, zoomManager, dcrawVersion, operationProcessor, channelManager, gui); +} + +void deMainWindow::show() +{ + impl->show(); +} + +void deMainWindow::setTopWindow() +{ + impl->setTopWindow(); +} + +void deMainWindow::postEvent(int event, int arg) +{ + impl->postEvent(event, arg); +} + +void deMainWindow::generateHistogram() +{ + impl->generateHistogram(); +} + +void deMainWindow::onKey(int key) +{ + impl->onKey(key); +} + +void deMainWindow::rebuild() +{ + impl->rebuild(); +} + +void deMainWindow::setImageName(const std::string& _imageName, const deSize& _size) +{ + impl->setImageName(_imageName, _size); +} + +void deMainWindow::startRawTimer() +{ + impl->startRawTimer(); +} + +void deMainWindow::stopRawTimer() +{ + impl->stopRawTimer(); +} + +void deMainWindow::updateWarning() +{ + impl->updateWarning(); +} + +void deMainWindow::forceUpdateSize() +{ + impl->forceUpdateSize(); +} diff -Nru delaboratory-0.7/gui_wx/main_window.h delaboratory-0.8/gui_wx/main_window.h --- delaboratory-0.7/gui_wx/main_window.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/main_window.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,57 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MAIN_WINDOW_H +#define _DE_MAIN_WINDOW_H + +class deMainWindowImpl; +class deProject; +class deLayerProcessor; +class deSamplerManager; +class deZoomManager; +class deOperationProcessor; +class deSize; +class deChannelManager; +class deGUI; +#include + +class deMainWindow +{ + private: + deMainWindowImpl* impl; + + public: + deMainWindow(); + virtual ~deMainWindow(); + + void init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui); + void show(); + void setTopWindow(); + void postEvent(int event, int arg); + void generateHistogram(); + void onKey(int key); + void rebuild(); + void setImageName(const std::string& _imageName, const deSize& _size); + void startRawTimer(); + void stopRawTimer(); + void updateWarning(); + void forceUpdateSize(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/message_box.cc delaboratory-0.8/gui_wx/message_box.cc --- delaboratory-0.7/gui_wx/message_box.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/message_box.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,30 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include "str_wx.h" + +void showMessageBox(const std::string& s) +{ + wxMessageBox(str2wx(s)); +} + +void sleep(int ms) +{ + wxThread::Sleep(200); +} diff -Nru delaboratory-0.7/gui_wx/message_box.h delaboratory-0.8/gui_wx/message_box.h --- delaboratory-0.7/gui_wx/message_box.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/message_box.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,27 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MESSAGE_BOX_H +#define _DE_MESSAGE_BOX_H + +#include + +void showMessageBox(const std::string& s); +void sleep(int ms); + +#endif diff -Nru delaboratory-0.7/gui_wx/mutex.cc delaboratory-0.8/gui_wx/mutex.cc --- delaboratory-0.7/gui_wx/mutex.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/mutex.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,85 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "mutex.h" +#include +#include "logger.h" + +class deMutexImpl +{ + private: + wxMutex mutex; + public: + deMutexImpl(wxMutexType flags) + :mutex(flags) + { + } + + ~deMutexImpl() + { + } + + void lock() + { + mutex.Lock(); + } + + void unlock() + { + mutex.Unlock(); + } + +}; + +deMutex::deMutex(bool recursive) +{ + wxMutexType flags = wxMUTEX_DEFAULT; + if (recursive) + { +#ifdef DEBUG_LOG + logInfo("create recursive mutex"); +#endif + flags = wxMUTEX_RECURSIVE; + } + else + { +#ifdef DEBUG_LOG + logInfo("create normal mutex"); +#endif + } + + impl = new deMutexImpl(flags); +} + +deMutex::~deMutex() +{ +#ifdef DEBUG_LOG + logInfo("destroy mutex"); +#endif + delete impl; +} + +void deMutex::lock() +{ + impl->lock(); +} + +void deMutex::unlock() +{ + impl->unlock(); +} diff -Nru delaboratory-0.7/gui_wx/mutex.h delaboratory-0.8/gui_wx/mutex.h --- delaboratory-0.7/gui_wx/mutex.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/mutex.h 2012-06-16 21:34:03.000000000 +0000 @@ -0,0 +1,39 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MUTEX_H +#define _DE_MUTEX_H + +class deMutexImpl; + +class deMutex +{ + private: + deMutexImpl* impl; + deMutex(const deMutex& m); + deMutex& operator = (const deMutex& m); + public: + deMutex(bool recursive = true); + ~deMutex(); + + void lock(); + void unlock(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/mutex_read_write.cc delaboratory-0.8/gui_wx/mutex_read_write.cc --- delaboratory-0.7/gui_wx/mutex_read_write.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/mutex_read_write.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,60 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "mutex_read_write.h" +#include "logger.h" + +deMutexReadWrite::deMutexReadWrite(int _maxReaders) +:maxReaders(_maxReaders), +readSemaphore(_maxReaders, _maxReaders) +{ +} + +deMutexReadWrite::~deMutexReadWrite() +{ +} + +void deMutexReadWrite::lockRead() +{ + readSemaphore.wait(); +} + +void deMutexReadWrite::unlockRead() +{ + readSemaphore.post(); +} + +void deMutexReadWrite::lockWrite() +{ + int i; + for (i = 0; i < maxReaders; i++) + { + readSemaphore.wait(); + } + writeMutex.lock(); +} + +void deMutexReadWrite::unlockWrite() +{ + writeMutex.unlock(); + int i; + for (i = 0; i < maxReaders; i++) + { + readSemaphore.post(); + } +} diff -Nru delaboratory-0.7/gui_wx/mutex_read_write.h delaboratory-0.8/gui_wx/mutex_read_write.h --- delaboratory-0.7/gui_wx/mutex_read_write.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/mutex_read_write.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,47 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MUTEX_READ_WRITE_H +#define _DE_MUTEX_READ_WRITE_H + +#include "mutex.h" +#include "semaphore.h" + +class deMutexReadWrite +{ + private: + int maxReaders; + deSemaphore readSemaphore; + deMutex writeMutex; + + deMutexReadWrite(const deMutexReadWrite& m); + deMutexReadWrite& operator = (const deMutexReadWrite& m); + + public: + deMutexReadWrite(int _maxReaders); + ~deMutexReadWrite(); + + void lockRead(); + void unlockRead(); + void lockWrite(); + void unlockWrite(); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/panel_wx.cc delaboratory-0.8/gui_wx/panel_wx.cc --- delaboratory-0.7/gui_wx/panel_wx.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/panel_wx.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,46 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "panel_wx.h" +#include "window_wx.h" + +dePanelWX::dePanelWX() +:wxPanel(), window(this) +{ +} + + +dePanelWX::dePanelWX(deWindow& _parent) +:wxPanel(dynamic_cast(_parent).getWindow()), window(this) +{ +} + +dePanelWX::dePanelWX(deWindow& _parent, int w, int h) +:wxPanel(dynamic_cast(_parent).getWindow(), wxID_ANY, wxDefaultPosition, wxSize(w, h)), window(this) +{ +} + +dePanelWX::~dePanelWX() +{ +} + +deWindow& dePanelWX::getWindow() +{ + return window; +} + diff -Nru delaboratory-0.7/gui_wx/panel_wx.h delaboratory-0.8/gui_wx/panel_wx.h --- delaboratory-0.7/gui_wx/panel_wx.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/panel_wx.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,42 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PANEL_WX_H +#define _DE_PANEL_WX_H + +#include +#include "window_wx.h" + +class dePanelWX:public wxPanel +{ + private: + deWindowWX window; + + dePanelWX(); + protected: + dePanelWX(deWindow& _parent); + dePanelWX(deWindow& _parent, int w, int h); + public: + virtual ~dePanelWX(); + + deWindow& getWindow(); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/progress_dialog.cc delaboratory-0.8/gui_wx/progress_dialog.cc --- delaboratory-0.7/gui_wx/progress_dialog.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/progress_dialog.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,35 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "progress_dialog.h" +#include + +deProgressDialog::deProgressDialog() +{ + progressDialog = new wxProgressDialog(_T("generate final image"), _T("generate final image"), 100, NULL, wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME); +} + +deProgressDialog::~deProgressDialog() +{ + delete progressDialog; +} + +void deProgressDialog::update(int progress, const std::string& s) +{ + progressDialog->Update(progress, wxString::FromAscii(s.c_str())); +} diff -Nru delaboratory-0.7/gui_wx/progress_dialog.h delaboratory-0.8/gui_wx/progress_dialog.h --- delaboratory-0.7/gui_wx/progress_dialog.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/progress_dialog.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,36 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROGRESS_DIALOG_H +#define _DE_PROGRESS_DIALOG_H + +class wxProgressDialog; +#include + +class deProgressDialog +{ + private: + wxProgressDialog* progressDialog; + public: + deProgressDialog(); + virtual ~deProgressDialog(); + + void update(int progress, const std::string& s); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/property_boolean_ui.cc delaboratory-0.8/gui_wx/property_boolean_ui.cc --- delaboratory-0.7/gui_wx/property_boolean_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_boolean_ui.cc 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_boolean_ui.h" +#include "property_boolean.h" +#include "base_layer.h" +#include "layer_processor.h" + +dePropertyBooleanUI::dePropertyBooleanUI(deWindow& window, dePropertyBoolean& _property, deLayerProcessor& _layerProcessor, int _layerIndex) +:deCheckBox(window, _property.getLabel()), +property(_property), +layerProcessor(_layerProcessor), +layerIndex(_layerIndex) +{ + setFromProperty(); +} + +dePropertyBooleanUI::~dePropertyBooleanUI() +{ +} + +void dePropertyBooleanUI::onCheck(bool c) +{ + property.set(c); + + if (property.updateBlendOnly()) + { + layerProcessor.markUpdateBlendAllChannels(layerIndex); + } + else + { + layerProcessor.markUpdateAllChannels(layerIndex); + } +} + +void dePropertyBooleanUI::setFromProperty() +{ + set(property.get()); +} diff -Nru delaboratory-0.7/gui_wx/property_boolean_ui.h delaboratory-0.8/gui_wx/property_boolean_ui.h --- delaboratory-0.7/gui_wx/property_boolean_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_boolean_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_BOOLEAN_UI_H +#define _DE_PROPERTY_BOOLEAN_UI_H + +#include "check_box.h" +class dePropertyBoolean; +class deLayerProcessor; + +class dePropertyBooleanUI:public deCheckBox +{ + private: + dePropertyBoolean& property; + deLayerProcessor& layerProcessor; + int layerIndex; + + public: + dePropertyBooleanUI(deWindow& window, dePropertyBoolean& _property, deLayerProcessor& _layerProcessor, int _layerIndex); + virtual ~dePropertyBooleanUI(); + + virtual void onCheck(bool c); + + void setFromProperty(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/property_choice_ui.cc delaboratory-0.8/gui_wx/property_choice_ui.cc --- delaboratory-0.7/gui_wx/property_choice_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_choice_ui.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,67 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_choice_ui.h" +#include "property_choice.h" +#include "base_layer.h" +#include "layer_processor.h" +#include "layer_frame.h" + +dePropertyChoiceUI::dePropertyChoiceUI(deWindow& window, dePropertyChoice& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _parent) +:deChoice(window, _property.getName(), _property.getChoices()), +property(_property), +layerProcessor(_layerProcessor), +layerIndex(_layerIndex), +parent(_parent) +{ + setFromProperty(); +} + +dePropertyChoiceUI::~dePropertyChoiceUI() +{ +} + +void dePropertyChoiceUI::onChoose(int index) +{ + property.setIndex(index); + + if (property.affectOthers()) + { + parent.setUIFromLayer(); + } + + if (property.affectSize()) + { + layerProcessor.forceUpdateSize(); + } + + if (property.updateBlendOnly()) + { + layerProcessor.markUpdateBlendAllChannels(layerIndex); + } + else + { + layerProcessor.markUpdateAllChannels(layerIndex); + } +} + +void dePropertyChoiceUI::setFromProperty() +{ + int index = property.getIndex(); + set(index); +} diff -Nru delaboratory-0.7/gui_wx/property_choice_ui.h delaboratory-0.8/gui_wx/property_choice_ui.h --- delaboratory-0.7/gui_wx/property_choice_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_choice_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,48 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_CHOICE_UI_H +#define _DE_PROPERTY_CHOICE_UI_H + +#include "choice.h" +class dePropertyChoice; +class deLayerProcessor; +class deLayerFrame; + +class dePropertyChoiceUI:public deChoice +{ + private: + dePropertyChoice& property; + deLayerProcessor& layerProcessor; + + int layerIndex; + + deLayerFrame& parent; + + public: + dePropertyChoiceUI(deWindow& window, dePropertyChoice& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _parent); + virtual ~dePropertyChoiceUI(); + + virtual void onChoose(int index); + + void setFromProperty(); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/property_curves_ui.cc delaboratory-0.8/gui_wx/property_curves_ui.cc --- delaboratory-0.7/gui_wx/property_curves_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_curves_ui.cc 2012-07-15 07:47:57.000000000 +0000 @@ -0,0 +1,281 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_curves_ui.h" +#include "property_curves.h" +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" +#include +#include "canvas_wx.h" +#include "gradient_panel.h" +#include "channel_selector.h" +#include "curves_panel.h" +#include "base_layer_with_source.h" +#include "logger.h" +#include "color_space_utils.h" + +class deCurvesChannelSelector:public deChannelSelector +{ + private: + dePropertyCurvesUIImpl& ui; + public: + deCurvesChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyCurvesUIImpl& _ui) + :deChannelSelector(window, colorSpace), ui(_ui) + { + } + virtual ~deCurvesChannelSelector() + { + } + virtual void onValueChange(int channel); +}; + + +class dePropertyCurvesUIImpl:public dePanelWX +{ + private: + deBaseLayerWithSource& layer; + dePropertyCurvesUI& parent; + dePropertyCurves& property; + + deCurvesChannelSelector *channelSelector; + deCurvesPanel* curvesPanel; + deGradientPanel1* leftBar; + deGradientPanel1* bottomBar; + + wxStaticText* infoEntry; + + int channel; + + public: + dePropertyCurvesUIImpl(dePropertyCurvesUI& _parent, deWindow& _parentWindow, dePropertyCurves& _property, deBaseLayerWithSource& _layer, deLayerProcessor& layerProcessor, int layerIndex, int width) + :dePanelWX(_parentWindow), layer(_layer), parent(_parent), property(_property) + { + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + channel = -1; + + deColorSpace colorSpace = layer.getColorSpace(); + + wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(sizer2); + + { + channelSelector = new deCurvesChannelSelector(getWindow(), colorSpace, *this); + deWindowWX& w = dynamic_cast(channelSelector->getWindow()); + sizer2->Add(w.getWindow(), 0); + } + + sizer2->AddSpacer(20); + infoEntry = new wxStaticText(this, wxID_ANY, _T("info")); + sizer2->Add(infoEntry, 0, wxRIGHT); + + curvesPanel = new deCurvesPanel(this, layerProcessor, layerIndex, property, colorSpace, infoEntry); + + int barSize = 16; + + leftBar = new deGradientPanel1(this, wxSize(barSize, CURVES_PANEL_SIZE_Y), colorSpace, 0, -1, -1, -1, -1); + bottomBar = new deGradientPanel1(this, wxSize(CURVES_PANEL_SIZE_X, barSize), colorSpace, 0, -1, -1, -1, -1); + + wxSizer* sizerC = new wxFlexGridSizer(2, 8, 8); + sizer->Add(sizerC); + + sizerC->Add(leftBar, 0, wxCENTER); + sizerC->Add(curvesPanel, 0, wxCENTER); + sizerC->Add(-1, 0, wxCENTER); + sizerC->Add(bottomBar, 0, wxCENTER); + + setChannel(0); + + Fit(); + } + + virtual ~dePropertyCurvesUIImpl() + { + } + + void generate() + { + const deImage& sourceImage = layer.getSourceImage(); + + int chan = channel; + int hc = property.getHorizontalChannel(); + if (hc >=0 ) + { + chan = hc; + } + + const deValue* c = sourceImage.startRead(chan); + + int n = sourceImage.getChannelSize().getN(); + + curvesPanel->generateBackground(c, n); + + sourceImage.finishRead(chan); + } + + void setMarker() + { + const deImage& sourceImage = layer.getSourceImage(); + + const deValue* c = sourceImage.startRead(channel); + int n = sourceImage.getChannelSize().getN(); + + curvesPanel->setMarker(c, n); + + sourceImage.finishRead(channel); + } + + void setFromProperty() + { + generate(); + updateBars(); + curvesPanel->paint(); + } + + void setChannel(int _channel) + { + channel = _channel; + generate(); + curvesPanel->changeChannel(channel); + setMarker(); + updateBars(); + } + + void updateBars() + { + leftBar->changeChannel(channel); + int hc = property.getHorizontalChannel(); + if (hc < 0) + { + bottomBar->changeChannel(channel); + } + else + { + bottomBar->changeChannel(hc); + } + } + + bool onImageClick(deValue x, deValue y) + { + const deImage& sourceImage = layer.getSourceImage(); + + const deValue* c = sourceImage.startRead(channel); + + curvesPanel->onImageClick(x, y, c, sourceImage.getChannelSize()); + + sourceImage.finishRead(channel); + + return true; + } + + bool onKey(int key) + { + if (key == 'X') + { + return curvesPanel->removeSelectedPoint(); + } + + int p = curvesPanel->getClickPosition(); + if (p >= 0) + { + const deImage& sourceImage = layer.getSourceImage(); + if (p >= sourceImage.getChannelSize().getN()) + { + logError("click position outside channel"); + return false; + } + deColorSpace colorSpace = layer.getColorSpace(); + int n = getColorSpaceSize(colorSpace); + int i; + for (i = 0; i < n; i++) + { + const deValue* c = sourceImage.startRead(i); + if (c) + { + deValue v = c[p]; + property.onKey(key, i, v); + } + sourceImage.finishRead(i); + } + return true; + } + return false; + } + + +}; + +dePropertyCurvesUI::dePropertyCurvesUI(deWindow& window, dePropertyCurves& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) +:property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) +{ + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new dePropertyCurvesUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); + } + else + { + impl = NULL; + } +} + +dePropertyCurvesUI::~dePropertyCurvesUI() +{ + if (impl) + { + delete impl; + } +} + +deWindow& dePropertyCurvesUI::getWindow() +{ + return impl->getWindow(); +} + +void dePropertyCurvesUI::setFromProperty() +{ + if (impl) + { + impl->setFromProperty(); + } +} + +bool dePropertyCurvesUI::onImageClick(deValue x, deValue y) +{ + if (impl) + { + return impl->onImageClick(x,y); + } + return false; +} + +bool dePropertyCurvesUI::onKey(int key) +{ + if (impl) + { + return impl->onKey(key); + } + return false; +} + +void deCurvesChannelSelector::onValueChange(int channel) +{ + ui.setChannel(channel); +} diff -Nru delaboratory-0.7/gui_wx/property_curves_ui.h delaboratory-0.8/gui_wx/property_curves_ui.h --- delaboratory-0.7/gui_wx/property_curves_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_curves_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,53 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_CURVES_UI_H +#define _DE_PROPERTY_CURVES_UI_H + +class dePropertyCurves; +class deLayerProcessor; +class deWindow; +class dePropertyCurvesUIImpl; +class deBaseLayerWithSource; +#include "value.h" + +class dePropertyCurvesUI +{ + private: + dePropertyCurves& property; + deLayerProcessor& layerProcessor; + + int layerIndex; + + deBaseLayerWithSource& layer; + + dePropertyCurvesUIImpl* impl; + + public: + dePropertyCurvesUI(deWindow& window, dePropertyCurves& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); + virtual ~dePropertyCurvesUI(); + + deWindow& getWindow(); + + void setFromProperty(); + + bool onImageClick(deValue x, deValue y); + bool onKey(int key); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/property_levels_ui.cc delaboratory-0.8/gui_wx/property_levels_ui.cc --- delaboratory-0.7/gui_wx/property_levels_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_levels_ui.cc 2012-07-29 13:17:33.000000000 +0000 @@ -0,0 +1,421 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_levels_ui.h" +#include "property_levels.h" +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" +#include "histogram.h" +#include +#include "canvas_wx.h" +#include "gradient_panel.h" +#include "channel_selector.h" +#include "base_layer_with_source.h" + +class deLevelsChannelSelector:public deChannelSelector +{ + private: + dePropertyLevelsUIImpl& ui; + public: + deLevelsChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyLevelsUIImpl& _ui) + :deChannelSelector(window, colorSpace), ui(_ui) + { + } + virtual ~deLevelsChannelSelector() + { + } + virtual void onValueChange(int channel); +}; + + +class deLevelsControl:public dePanelWX +{ + private: + wxBitmap bitmap; + dePropertyLevels& property; + int width; + int height; + int margin; + + deLayerProcessor& layerProcessor; + int layerIndex; + + int channel; + + enum + { + deModeNothing, + deModeMin, + deModeMiddle, + deModeMax + } mode; + + void click(wxMouseEvent &event) + { + deValue v = getValue(event.GetX()); + + const deLevels& levels = property.getLevels(channel); + + deValue min = levels.getMin(); + deValue middle = levels.getMiddle(); + deValue max = levels.getMax(); + + deValue dmin = fabs(v - min); + deValue dmiddle = fabs(v - middle); + deValue dmax = fabs(v - max); + + deValue d = 0.01; + + if (dmin < d) + { + mode = deModeMin; + } else + if (dmax < d) + { + mode = deModeMax; + } else + if (dmiddle < d) + { + mode = deModeMiddle; + } + } + + void release(wxMouseEvent &event) + { + mode = deModeNothing; + } + + void move(wxMouseEvent &event) + { + deValue v = getValue(event.GetX()); + + if ((v < 0) || (v > 1.0)) + { + return; + } + + deLevels& levels = property.getLevels(channel); + + switch (mode) + { + case deModeMin: + { + levels.setMin(v); + break; + } + case deModeMiddle: + { + levels.setMiddle(v); + break; + } + case deModeMax: + { + levels.setMax(v); + break; + } + default: + { + return; + break; + } + } + + paint(); + + layerProcessor.markUpdateSingleChannel(layerIndex, channel); + } + + void drawArrow(deCanvas& canvas, deValue v) + { + int p = margin + v * (width - 2 * margin); + int m = 3; + int p1 = p - m; + if (p1 < 0) + { + p1 = 0; + } + int p2 = p + m; + if (p2 >= width) + { + p2 = width - 1; + } + + int g = 50; + canvas.setBrush(g, g, g); + canvas.drawTriangle(p, 0, p1, height, p2, height); + } + + deValue getValue(int p) + { + deValue a = p - margin; + deValue b = width - 2 * margin; + return a / b; + } + + + public: + deLevelsControl(deWindow& _parentWindow, dePropertyLevels& _property, int _width, int _height, int _margin, deLayerProcessor& _layerProcessor, int _layerIndex) + :dePanelWX(_parentWindow, _width, _height), property(_property), width(_width), height(_height), margin(_margin), layerProcessor(_layerProcessor), layerIndex(_layerIndex) + { + SetMinSize(wxSize(width, height)); + + channel = -1; + + mode = deModeNothing; + + bitmap.Create(_width, _height); + + Connect(wxEVT_PAINT, wxPaintEventHandler(deLevelsControl::paintEvent)); + Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deLevelsControl::click)); + Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deLevelsControl::release)); + Connect(wxEVT_MOTION, wxMouseEventHandler(deLevelsControl::move)); + + } + + ~deLevelsControl() + { + } + + void setChannel(int _channel) + { + channel = _channel; + paint(); + } + + void paint() + { + wxClientDC dc(this); + + render(dc); + } + + void paintEvent(wxPaintEvent & evt) + { + wxPaintDC dc(this); + + render(dc); + } + + void render(wxDC& dc_orig) + { + wxBufferedDC dc(&dc_orig, bitmap, wxBUFFER_CLIENT_AREA); + + deCanvasWX canvas(dc); + + int h = height / 5; + + canvas.clear(); + canvas.drawLine(0, h, width, h); + + const deLevels& levels = property.getLevels(channel); + deValue min = levels.getMin(); + deValue middle = levels.getMiddle(); + deValue max = levels.getMax(); + + unsigned char g = 50; + canvas.setPen(g, g, g); + drawArrow(canvas, min); + drawArrow(canvas, middle); + drawArrow(canvas, max); + } +}; + +class deChannelHistogramPanel:public dePanelWX +{ + private: + wxBitmap* backgroundBitmap; + int width; + int height; + int margin; + + public: + deChannelHistogramPanel(deWindow& _parentWindow, const deValue* c, int n, int _width, int _height, int _margin) + :dePanelWX(_parentWindow, _width, _height), width(_width), height(_height), margin(_margin) + { + backgroundBitmap = NULL; + + generate(c, n); + + Connect(wxEVT_PAINT, wxPaintEventHandler(deChannelHistogramPanel::paintEvent)); + } + + virtual ~deChannelHistogramPanel() + { + } + + void paintEvent(wxPaintEvent & evt) + { + wxPaintDC dc(this); + dc.DrawBitmap(*backgroundBitmap, 0, 0, false); + } + + void paint() + { + wxClientDC dc(this); + dc.DrawBitmap(*backgroundBitmap, 0, 0, false); + } + + void generate(const deValue* c, int n) + { + if (backgroundBitmap) + { + delete backgroundBitmap; + backgroundBitmap = NULL; + } + + deHistogram histogram(width - 2 * margin); + + histogram.clear(); + histogram.calc(c, n); + + wxImage* image = new wxImage(width, height); + unsigned char* data = image->GetData(); + + unsigned char g1 = 255; + unsigned char g2 = 200; + + histogram.render(data, width, height, g1, g2, margin); + + backgroundBitmap = new wxBitmap(*image); + delete image; + + paint(); + } +}; + + +class dePropertyLevelsUIImpl:public dePanelWX +{ + private: + deBaseLayerWithSource& layer; + dePropertyLevelsUI& parent; + dePropertyLevels& property; + + deLevelsChannelSelector *channelSelector; + deChannelHistogramPanel* histogramPanel; + deLevelsControl* levelsControl; + deGradientPanel0* gradient; + + int channel; + + public: + dePropertyLevelsUIImpl(dePropertyLevelsUI& _parent, deWindow& _parentWindow, dePropertyLevels& _property, deBaseLayerWithSource& _layer, deLayerProcessor& layerProcessor, int layerIndex, int width) + :dePanelWX(_parentWindow), layer(_layer), parent(_parent), property(_property) + { + int margin = 10; + + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + channel = -1; + + deColorSpace colorSpace = layer.getColorSpace(); + + { + channelSelector = new deLevelsChannelSelector(getWindow(), colorSpace, *this); + deWindowWX& w = dynamic_cast(channelSelector->getWindow()); + sizer->Add(w.getWindow()); + } + + int h = 80; + histogramPanel = new deChannelHistogramPanel(getWindow(), NULL, 0, width, h, margin); + sizer->Add(histogramPanel); + + gradient = new deGradientPanel0(this, wxSize(width, 8), layer.getColorSpace(), 0, margin); + sizer->Add(gradient); + + levelsControl = new deLevelsControl(getWindow(), property, width, 10, margin, layerProcessor, layerIndex); + sizer->Add(levelsControl); + + setChannel(0); + + Fit(); + } + + virtual ~dePropertyLevelsUIImpl() + { + } + + void generate() + { + const deImage& sourceImage = layer.getSourceImage(); + + const deValue* c = sourceImage.startRead(channel); + int n = sourceImage.getChannelSize().getN(); + + histogramPanel->generate(c, n); + + sourceImage.finishRead(channel); + } + + void setFromProperty() + { + levelsControl->paint(); + } + + void setChannel(int _channel) + { + channel = _channel; + levelsControl->setChannel(channel); + gradient->changeChannel(channel); + generate(); + } + + +}; + +dePropertyLevelsUI::dePropertyLevelsUI(deWindow& window, dePropertyLevels& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) +:property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) +{ + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new dePropertyLevelsUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); + } + else + { + impl = NULL; + } +} + +dePropertyLevelsUI::~dePropertyLevelsUI() +{ + if (impl) + { + delete impl; + } +} + +deWindow& dePropertyLevelsUI::getWindow() +{ + return impl->getWindow(); +} + +void dePropertyLevelsUI::setFromProperty() +{ + if (impl) + { + impl->setFromProperty(); + } +} + +void deLevelsChannelSelector::onValueChange(int channel) +{ + ui.setChannel(channel); +} diff -Nru delaboratory-0.7/gui_wx/property_levels_ui.h delaboratory-0.8/gui_wx/property_levels_ui.h --- delaboratory-0.7/gui_wx/property_levels_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_levels_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_LEVELS_UI_H +#define _DE_PROPERTY_LEVELS_UI_H + +class dePropertyLevels; +class deLayerProcessor; +class deWindow; +class dePropertyLevelsUIImpl; +class deBaseLayerWithSource; + +class dePropertyLevelsUI +{ + private: + dePropertyLevels& property; + deLayerProcessor& layerProcessor; + + int layerIndex; + + deBaseLayerWithSource& layer; + + dePropertyLevelsUIImpl* impl; + + public: + dePropertyLevelsUI(deWindow& window, dePropertyLevels& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); + virtual ~dePropertyLevelsUI(); + + deWindow& getWindow(); + + void setFromProperty(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/property_mixer_ui.cc delaboratory-0.8/gui_wx/property_mixer_ui.cc --- delaboratory-0.7/gui_wx/property_mixer_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_mixer_ui.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,209 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_mixer_ui.h" +#include "property_mixer.h" +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" +#include "histogram.h" +#include +#include "canvas_wx.h" +#include "gradient_panel.h" +#include "color_space_utils.h" +#include "slider.h" +#include "logger.h" +#include "channel_selector.h" +#include "base_layer_with_source.h" + +class deMixerChannelSelector:public deChannelSelector +{ + private: + dePropertyMixerUIImpl& ui; + public: + deMixerChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyMixerUIImpl& _ui) + :deChannelSelector(window, colorSpace), ui(_ui) + { + } + virtual ~deMixerChannelSelector() + { + } + virtual void onValueChange(int channel); +}; + +class deMixerSlider:public deSlider +{ + private: + dePropertyMixerUIImpl& ui; + int index; + public: + deMixerSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl, dePropertyMixerUIImpl& _ui, int _index) + :deSlider(window, _name, _min, _max, _width, widthn, widthl), + ui(_ui), index(_index) + { + logInfo("deMixerSlider constructor"); + } + + virtual ~deMixerSlider() + { + logInfo("deMixerSlider destructor"); + } + + virtual void onValueChange(deValue value, bool finished); +}; + +class dePropertyMixerUIImpl:public dePanelWX +{ + private: + dePropertyMixerUI& parent; + dePropertyMixer& property; + deMixerChannelSelector *channelSelector; + std::vector sliders; + int channel; + deLayerProcessor& layerProcessor; + deGradientPanel0* gradient; + int layerIndex; + + public: + dePropertyMixerUIImpl(dePropertyMixerUI& _parent, deWindow& _parentWindow, dePropertyMixer& _property, deBaseLayerWithSource& layer, deLayerProcessor& _layerProcessor, int _layerIndex, int width) + :dePanelWX(_parentWindow), parent(_parent), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex) + { + int margin = 10; + + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + deColorSpace colorSpace = layer.getColorSpace(); + + { + channelSelector = new deMixerChannelSelector(getWindow(), colorSpace, *this); + deWindowWX& w = dynamic_cast(channelSelector->getWindow()); + sizer->Add(w.getWindow()); + } + + channel = 0; + + int n = getColorSpaceSize(layer.getColorSpace()); + + deValue min = -3; + deValue max = 3; + int w = 400; + int wn = 80; + int wl = 40; + int i; + for (i = 0; i < n; i++) + { + std::string c = getChannelName(layer.getColorSpace(), i); + deMixerSlider* s = new deMixerSlider(getWindow(), c, min, max, w, wn, wl, *this, i); + sliders.push_back(s); + deWindowWX& w = dynamic_cast(s->getWindow()); + sizer->Add(w.getWindow()); + } + + gradient = new deGradientPanel0(this, wxSize(width, 8), layer.getColorSpace(), channel, margin); + sizer->Add(gradient); + + setFromProperty(); + + Fit(); + } + + virtual ~dePropertyMixerUIImpl() + { + delete channelSelector; + } + + void setFromProperty() + { + deMixer* mixer = property.getMixer(channel); + + int n = sliders.size(); + int i; + for (i = 0; i < n; i++) + { + deValue w = mixer->getWeight(i); + deMixerSlider* s = sliders[i]; + s->setValue(w); + } + } + + void setFromSlider(int index, deValue v) + { + deMixer* mixer = property.getMixer(channel); + mixer->setWeight(index, v); + + layerProcessor.markUpdateSingleChannel(layerIndex, channel); + } + + void setChannel(int _channel) + { + channel = _channel; + gradient->changeChannel(channel); + setFromProperty(); + layerProcessor.setHistogramChannel(channel); + + } + + +}; + +dePropertyMixerUI::dePropertyMixerUI(deWindow& window, dePropertyMixer& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) +:property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) +{ + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new dePropertyMixerUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); + } + else + { + impl = NULL; + } +} + +dePropertyMixerUI::~dePropertyMixerUI() +{ + if (impl) + { + delete impl; + } +} + +deWindow& dePropertyMixerUI::getWindow() +{ + return impl->getWindow(); +} + +void dePropertyMixerUI::setFromProperty() +{ + if (impl) + { + impl->setFromProperty(); + } +} + +void deMixerSlider::onValueChange(deValue value, bool finished) +{ + ui.setFromSlider(index, value); +} + + +void deMixerChannelSelector::onValueChange(int channel) +{ + ui.setChannel(channel); +} diff -Nru delaboratory-0.7/gui_wx/property_mixer_ui.h delaboratory-0.8/gui_wx/property_mixer_ui.h --- delaboratory-0.7/gui_wx/property_mixer_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_mixer_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_MIXER_UI_H +#define _DE_PROPERTY_MIXER_UI_H + +class dePropertyMixer; +class deLayerProcessor; +class deWindow; +class dePropertyMixerUIImpl; +class deBaseLayerWithSource; + +class dePropertyMixerUI +{ + private: + dePropertyMixer& property; + deLayerProcessor& layerProcessor; + + int layerIndex; + + deBaseLayerWithSource& layer; + + dePropertyMixerUIImpl* impl; + + public: + dePropertyMixerUI(deWindow& window, dePropertyMixer& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); + virtual ~dePropertyMixerUI(); + + deWindow& getWindow(); + + void setFromProperty(); +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/property_numeric_ui.cc delaboratory-0.8/gui_wx/property_numeric_ui.cc --- delaboratory-0.7/gui_wx/property_numeric_ui.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_numeric_ui.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,51 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_numeric_ui.h" +#include "property_numeric.h" +#include "layer_processor.h" + +dePropertyNumericUI::dePropertyNumericUI(deWindow& window, dePropertyNumeric& _property, deLayerProcessor& _layerProcessor, int _layerIndex, int _width, int widthn, int widthl) +:deSlider(window, _property.getName(), _property.getMin(), _property.getMax(), _width, widthn, widthl), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex) +{ + setFromProperty(); +} + +dePropertyNumericUI::~dePropertyNumericUI() +{ +} + +void dePropertyNumericUI::onValueChange(deValue value, bool finished) +{ + property.set(value); + + if (property.updateBlendOnly()) + { + layerProcessor.markUpdateBlendAllChannels(layerIndex); + } + else + { + layerProcessor.markUpdateAllChannels(layerIndex); + } +} + +void dePropertyNumericUI::setFromProperty() +{ + setValue(property.get()); +} + diff -Nru delaboratory-0.7/gui_wx/property_numeric_ui.h delaboratory-0.8/gui_wx/property_numeric_ui.h --- delaboratory-0.7/gui_wx/property_numeric_ui.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/property_numeric_ui.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,45 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_VALUE_SLIDER_H +#define _DE_PROPERTY_VALUE_SLIDER_H + +class dePropertyNumeric; +class deLayerProcessor; +class deWindow; +#include "slider.h" + +class dePropertyNumericUI:public deSlider +{ + private: + dePropertyNumeric& property; + deLayerProcessor& layerProcessor; + + int layerIndex; + + public: + dePropertyNumericUI(deWindow& window, dePropertyNumeric& _property, deLayerProcessor& _layerProcessor, int _layerIndex, int _width, int width, int widthl); + virtual ~dePropertyNumericUI(); + + virtual void onValueChange(deValue value, bool finished); + + void setFromProperty(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/raw_module.cc delaboratory-0.8/gui_wx/raw_module.cc --- delaboratory-0.7/gui_wx/raw_module.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/raw_module.cc 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,97 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "raw_module.h" +#include "dcraw_support.h" +#include "image_io.h" +#include "str.h" +#include "logger.h" + +deRawModule::deRawModule() +{ + dcraw_version = ""; + loader = NULL; +} + +deRawModule::~deRawModule() +{ +} + +void deRawModule::onInit() +{ + dcraw_version = getDcrawVersion(); +} + +std::string deRawModule::getVersion() const +{ + return dcraw_version; +} + +bool deRawModule::loadRAW(const std::string& fileName, deStaticImage& image, bool half, bool srgb, bool brighten) +{ + if (loader) + { + logError("can't load RAW - loader already active"); + return false; + } + + bool status = false; + + mutex.lock(); + + loader = new deRawLoader(fileName, image, half, srgb, brighten); + + status = loader->getStatus(); + + mutex.unlock(); + + return status; +} + +bool deRawModule::updateRawLoading(bool& failure) +{ + if (!loader) + { + return false; + } + + if (failure) + { + logError("failure detected before load ?!"); + } + + bool result = loader->load(failure); + + if (failure) + { + logError("failure detected in deRawModule"); + } + + if ((result) || (failure)) + { + delete loader; + loader = NULL; + } + + return result; +} + +bool deRawModule::isActive() const +{ + return (loader); +} diff -Nru delaboratory-0.7/gui_wx/raw_module.h delaboratory-0.8/gui_wx/raw_module.h --- delaboratory-0.7/gui_wx/raw_module.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/raw_module.h 2012-07-26 21:58:31.000000000 +0000 @@ -0,0 +1,56 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RAW_MODULE_H +#define _DE_RAW_MODULE_H + +#include +class deStaticImage; +#include "color_space.h" +#include "dcraw_support.h" +#include "mutex.h" + +class deRawModule +{ + private: + mutable deMutex mutex; + + deRawLoader* loader; + + deRawModule(const deRawModule&); + deRawModule& operator =(const deRawModule&); + + std::string dcraw_version; + + public: + deRawModule(); + virtual ~deRawModule(); + + void onInit(); + + std::string getVersion() const; + bool loadRAW(const std::string& fileName, deStaticImage& image, bool half, bool srgb, bool brighten); + + bool updateRawLoading(bool& failure); + + bool isActive() const; + + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/rendered_image.cc delaboratory-0.8/gui_wx/rendered_image.cc --- delaboratory-0.7/gui_wx/rendered_image.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/rendered_image.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,135 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "rendered_image.h" +#include "logger.h" +#include "str.h" +#include +#include +#include "bitmap_wx.h" +#include "canvas_wx.h" + +void deRenderedImage::setSize(const deSize& _size) +{ + requestedSize = _size; +} + +unsigned char* deRenderedImage::getCurrentImageData() +{ + if (requestedSize != size) + { + if (internalData) + { + delete [] internalData; + } + size = requestedSize; + int w = size.getW(); + int h = size.getH(); + internalData = new unsigned char [ 3 * w * h ]; + } + + return internalData; +} + + +deRenderedImage::deRenderedImage() +:size(0,0), +requestedSize(0,0), +bitmapSize(0,0) +{ + renderedBitmap = new deBitmapWX(); + internalData = NULL; + error = false; +} + +deRenderedImage::~deRenderedImage() +{ + if (renderedBitmap) + { + delete renderedBitmap; + } + if (internalData) + { + delete [] internalData; + } +} + +bool deRenderedImage::render(deCanvas& canvas) +{ + if (error) + { + logError("can't render"); + return false; + } + + if (!internalData) + { + logInfo("can't render - no internal data"); + return false; + } + + int w = size.getW(); + int h = size.getH(); + + if (bitmapSize != size) + { + renderedBitmap->resize(w, h); + bitmapSize = size; + } + + deBitmapWX* bitmapWX = dynamic_cast(renderedBitmap); + + wxNativePixelData bitmapData(*(bitmapWX->getBitmap())); + if (!bitmapData) + { + logError("can't render - wxNativePixelData doesn't work"); + return false; + } + + wxNativePixelData::Iterator p(bitmapData); + + p.Offset(bitmapData, 0, 0); + + int x; + int y; + int pos = 0; + for (y = 0; y < h; y++) + { + wxNativePixelData::Iterator rowStart = p; + + for (x = 0; x < w; x++) + { + unsigned char r = internalData[pos]; + p.Red() = r; + pos++; + unsigned char g = internalData[pos]; + p.Green() = g; + pos++; + unsigned char b = internalData[pos]; + p.Blue() = b; + pos++; + p++; + } + + p = rowStart; + p.OffsetY(bitmapData, 1); + } + + canvas.drawBitmap(*renderedBitmap); + return true; +} diff -Nru delaboratory-0.7/gui_wx/rendered_image.h delaboratory-0.8/gui_wx/rendered_image.h --- delaboratory-0.7/gui_wx/rendered_image.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/rendered_image.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,56 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RENDERED_IMAGE_H +#define _DE_RENDERED_IMAGE_H + +#include "size.h" +class deBitmap; +class deCanvas; + +class deRenderedImage +{ + private: + deBitmap* renderedBitmap; + unsigned char* internalData; + + deRenderedImage(const deRenderedImage& i); + deRenderedImage& operator = (const deRenderedImage& i); + + deSize size; + deSize requestedSize; + deSize bitmapSize; + + bool error; + + public: + deRenderedImage(); + + virtual ~deRenderedImage(); + + void setSize(const deSize& _size); + unsigned char* getCurrentImageData(); + unsigned char* getCurrentBitmapData(); + bool render(deCanvas& canvas); + + void setError() {error = true;}; + void clearError() {error = false;}; + bool getError() const {return error;}; +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/sampler_panel.cc delaboratory-0.8/gui_wx/sampler_panel.cc --- delaboratory-0.7/gui_wx/sampler_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/sampler_panel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,250 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sampler_panel.h" +#include "sampler.h" +#include "project.h" +#include "base_layer.h" +#include "conversion_processor.h" +#include "image.h" +#include +#include "channel_manager.h" +#include "layer_stack.h" +#include "color_space_utils.h" + +deSamplerPanel::deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project) +:wxPanel(parent, wxID_ANY, wxDefaultPosition), sampler(_sampler), project(_project) +{ + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + int valueWidth = 70; + + getSupportedColorSpaces(colorSpaces); + + wxSizer* sizerT = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(sizerT); + + wxString* colorSpaceStrings = new wxString [colorSpaces.size()]; + unsigned int i; + for (i = 0; i < colorSpaces.size(); i++) + { + colorSpaceStrings[i] = wxString::FromAscii(getColorSpaceName(colorSpaces[i]).c_str()); + } + + colorSpaceChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, colorSpaces.size(), colorSpaceStrings); + sizerT->Add(colorSpaceChoice); + + colorPanel = new deColorPanelOld(this, wxSize(60, 25), 0); + sizerT->Add(colorPanel, 0, wxALIGN_CENTER); + + sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); + sizer->Add(sizerS); + + v1 = new wxStaticText(this, wxID_ANY, _T("v1"), wxDefaultPosition, wxSize(valueWidth, -1)); + sizerS->Add(v1); + v2 = new wxStaticText(this, wxID_ANY, _T("v2"), wxDefaultPosition, wxSize(valueWidth, -1)); + sizerS->Add(v2); + v3 = new wxStaticText(this, wxID_ANY, _T("v3"), wxDefaultPosition, wxSize(valueWidth, -1)); + sizerS->Add(v3); + v4 = new wxStaticText(this, wxID_ANY, _T("v4"), wxDefaultPosition, wxSize(valueWidth, -1)); + sizerS->Add(v4); + + delete [] colorSpaceStrings; + + setChoice(); + + Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deSamplerPanel::choose)); + +} + +deSamplerPanel::~deSamplerPanel() +{ +} + +void deSamplerPanel::setChoice() +{ + deColorSpace colorSpace = sampler.getColorSpace(); + unsigned int i; + for (i = 0; i != colorSpaces.size(); i++) + { + if (colorSpaces[i] == colorSpace) + { + colorSpaceChoice->SetSelection(i); + } + } +} + +void deSamplerPanel::update() +{ + if (sampler.isEnabled()) + { + colorSpaceChoice->Enable(); + v1->Enable(); + v2->Enable(); + v3->Enable(); + v4->Enable(); + } + else + { + v1->Disable(); + v2->Disable(); + v3->Disable(); + v4->Disable(); + colorSpaceChoice->Disable(); + } + + int g = 240; + + if (sampler.isSelected()) + { + g = 200; + } + + sizerS->GetStaticBox()->SetBackgroundColour(wxColour(g, g, g)); + + const deViewManager& viewManager = project.getViewManager(); + int view = viewManager.getView(); + + deLayerStack& layerStack = project.getLayerStack(); + + const deBaseLayer* layer = layerStack.startReadLayer(view); + + if (layer) + { + const deImage& image = layer->getLayerImage(); + + update(image); + } + + layerStack.finishReadLayer(view); +} + +void deSamplerPanel::update(const deImage& image) +{ + deSize channelSize = image.getChannelSize(); + + deValue x = sampler.getX(); + deValue y = sampler.getY(); + + if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) + { + int xx = channelSize.getW() * x; + int yy = channelSize.getH() * y; + int p = channelSize.getW() * yy + xx; + + deColorSpace colorSpace = sampler.getColorSpace(); + int n = getColorSpaceSize(colorSpace); + + switch (n) + { + case 1: + { + v1->Show(); + v2->Hide(); + v3->Hide(); + v4->Hide(); + break; + } + case 3: + { + v1->Show(); + v2->Show(); + v3->Show(); + v4->Hide(); + break; + } + case 4: + { + v1->Show(); + v2->Show(); + v3->Show(); + v4->Show(); + break; + } + } + + deValue orig[4]; + + deColorSpace oc = image.getColorSpace(); + int on = getColorSpaceSize(oc); + + logInfo("reading values for sampler"); + int i; + for (i = 0; i < on; i++) + { + const deValue* values = image.startRead(i); + if (values) + { + orig[i] = values[p]; + } + image.finishRead(i); + } + + deValue vv1; + deValue vv2; + deValue vv3; + deValue vv4; + + deValue rr; + deValue gg; + deValue bb; + + deConversionProcessor cp; + + cp.convert(oc, orig[0], orig[1], orig[2], orig[3], deColorSpaceRGB, rr, gg, bb, vv4); + cp.convert(oc, orig[0], orig[1], orig[2], orig[3], colorSpace, vv1, vv2, vv3, vv4); + + colorPanel->setRGB(rr, gg, bb); + + std::ostringstream oss; + oss.setf(std::ios_base::fixed); + oss.precision(3); + + { + oss.str(""); + oss << getPresentationValue(colorSpace, 0, vv1); + v1->SetLabel(wxString::FromAscii(oss.str().c_str())); + } + { + oss.str(""); + oss << getPresentationValue(colorSpace, 1, vv2); + v2->SetLabel(wxString::FromAscii(oss.str().c_str())); + } + { + oss.str(""); + oss << getPresentationValue(colorSpace, 2, vv3); + v3->SetLabel(wxString::FromAscii(oss.str().c_str())); + } + { + oss.str(""); + oss << getPresentationValue(colorSpace, 3, vv4); + v4->SetLabel(wxString::FromAscii(oss.str().c_str())); + } + } + +} + +void deSamplerPanel::choose(wxCommandEvent &event) +{ + int c = colorSpaceChoice->GetSelection(); + deColorSpace colorSpace = colorSpaces[c]; + sampler.setColorSpace(colorSpace); + update(); +} + diff -Nru delaboratory-0.7/gui_wx/sampler_panel.h delaboratory-0.8/gui_wx/sampler_panel.h --- delaboratory-0.7/gui_wx/sampler_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/sampler_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,60 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SAMPLER_PANEL_H +#define _DE_SAMPLER_PANEL_H + +#include "wx/wx.h" +#include +#include "color_space.h" +#include "gradient_panel.h" +class deSampler; +class deProject; +class deImage; + +class deSamplerPanel:public wxPanel +{ +private: + deSampler& sampler; + deProject& project; + + wxChoice* colorSpaceChoice; + deColorPanelOld* colorPanel; + wxStaticText* v1; + wxStaticText* v2; + wxStaticText* v3; + wxStaticText* v4; + + wxStaticBoxSizer* sizerS; + + std::vector colorSpaces; + + void choose(wxCommandEvent &event); + + void update(const deImage& image); + +public: + deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project); + virtual ~deSamplerPanel(); + + void update(); + void setChoice(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/samplers_panel.cc delaboratory-0.8/gui_wx/samplers_panel.cc --- delaboratory-0.7/gui_wx/samplers_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/samplers_panel.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,84 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "samplers_panel.h" +#include "sampler_panel.h" +#include "project.h" +#include "layer_processor.h" + +deSamplersPanel::deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager) +:wxPanel(parent, wxID_ANY, wxDefaultPosition), project(_project), samplerManager(_samplerManager) +{ + unsigned int n = samplerManager.getNumberOfSamplers(); + + unsigned int i; + + wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + SetSizer(sizer); + + wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(sizer2); + + show = new wxCheckBox(this, wxID_ANY, _T("show samplers")); + show->SetValue(0); + sizer2->Add(show); + + clearButton = new wxButton(this, wxID_ANY, _T("clear"), wxDefaultPosition, wxSize(60,25)); + sizer2->Add(clearButton); + + for (i = 0; i < n; i++) + { + deSampler* sampler = samplerManager.getSampler(i); + + if (sampler) + { + deSamplerPanel* panel = new deSamplerPanel(this, *sampler, project); + sizer->Add(panel); + panels.push_back(panel); + } + } + + Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deSamplersPanel::check)); + Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deSamplersPanel::click)); +} + +deSamplersPanel::~deSamplersPanel() +{ +} + +void deSamplersPanel::update() +{ + std::list::iterator i; + for (i = panels.begin(); i != panels.end(); i++) + { + (*i)->update(); + } +} + +void deSamplersPanel::check(wxCommandEvent &event) +{ + bool checked = show->IsChecked(); + samplerManager.setMoving(checked); + project.getLayerProcessor().onGUIUpdate(); +} + +void deSamplersPanel::click(wxCommandEvent &event) +{ + samplerManager.clear(); + project.getLayerProcessor().onGUIUpdate(); +} diff -Nru delaboratory-0.7/gui_wx/samplers_panel.h delaboratory-0.8/gui_wx/samplers_panel.h --- delaboratory-0.7/gui_wx/samplers_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/samplers_panel.h 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,48 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SAMPLERS_PANEL_H +#define _DE_SAMPLERS_PANEL_H + +#include "wx/wx.h" +class deProject; +class deSamplerPanel; +class deSamplerManager; +#include + +class deSamplersPanel:public wxPanel +{ +private: + deProject& project; + std::list panels; + wxCheckBox* show; + wxButton* clearButton; + deSamplerManager& samplerManager; + + void check(wxCommandEvent &event); + void click(wxCommandEvent &event); + +public: + deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager); + virtual ~deSamplersPanel(); + + void update(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/semaphore.cc delaboratory-0.8/gui_wx/semaphore.cc --- delaboratory-0.7/gui_wx/semaphore.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/semaphore.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,66 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "semaphore.h" +#include + +class deSemaphoreImpl +{ + private: + wxSemaphore semaphore; + public: + deSemaphoreImpl(int a, int b) + :semaphore(a, b) + { + } + + ~deSemaphoreImpl() + { + } + + void wait() + { + semaphore.Wait(); + } + + void post() + { + semaphore.Post(); + } + +}; + +deSemaphore::deSemaphore(int a, int b) +{ + impl = new deSemaphoreImpl(a, b); +} + +deSemaphore::~deSemaphore() +{ + delete impl; +} + +void deSemaphore::wait() +{ + impl->wait(); +} + +void deSemaphore::post() +{ + impl->post(); +} diff -Nru delaboratory-0.7/gui_wx/semaphore.h delaboratory-0.8/gui_wx/semaphore.h --- delaboratory-0.7/gui_wx/semaphore.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/semaphore.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,41 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SEMAPHORE_H +#define _DE_SEMAPHORE_H + +class deSemaphoreImpl; + +class deSemaphore +{ + private: + deSemaphoreImpl* impl; + deSemaphore(const deSemaphore& s); + deSemaphore& operator =(const deSemaphore& s); + + public: + deSemaphore(int a, int b); + ~deSemaphore(); + + void wait(); + void post(); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/slider.cc delaboratory-0.8/gui_wx/slider.cc --- delaboratory-0.7/gui_wx/slider.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/slider.cc 2012-07-21 16:02:12.000000000 +0000 @@ -0,0 +1,162 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "slider.h" +#include +#include "layer_processor.h" +#include "panel_wx.h" +#include "window_wx.h" +#include "logger.h" +#include "str.h" + +class deSliderImpl:public dePanelWX +{ + private: + deSlider& parent; + wxSlider* slider; + wxStaticText* labelValue; + deValue min; + deValue max; + deValue width; + public: + deSliderImpl(deSlider& _parent, deWindow& _parentWindow, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl) + :dePanelWX(_parentWindow), parent(_parent), min(_min), max(_max), width(_width) + { + if (width == 0) + { + logError("slider with width 0 created"); + } + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(sizer); + + if (_name.size() > 0) + { + wxStaticText* label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(_name.c_str()), wxDefaultPosition, wxSize(widthn, 30)); + sizer->Add(label, 0, wxCENTER); + } + + slider = new wxSlider(this, wxID_ANY, _width, 0, _width, wxDefaultPosition, wxSize(_width, -1), wxSL_HORIZONTAL); + sizer->Add(slider, 0); + + labelValue = new wxStaticText(this, wxID_ANY, _T("inv"), wxDefaultPosition, wxSize(widthl, 30)); + sizer->Add(labelValue, 0, wxCENTER); + + Connect(wxEVT_SCROLL_THUMBTRACK, wxCommandEventHandler(deSliderImpl::moveSlider)); + Connect(wxEVT_SCROLL_CHANGED, wxCommandEventHandler(deSliderImpl::finishMoveSlider)); + } + + virtual ~deSliderImpl() + { +#ifdef DEBUG_LOG + logInfo("~deSliderImpl"); +#endif + } + + void moveSlider(wxCommandEvent &event) + { + updateValueFromSlider(false); + } + + void finishMoveSlider(wxCommandEvent &event) + { + updateValueFromSlider(true); + } + + void updateValueFromSlider(bool finished) + { + deValue v = min + slider->GetValue() * ((max - min) / width); + setLabelValue(v); + parent.onValueChange(v, finished); + } + + void setLabelValue(deValue v) + { + std::ostringstream oss; + oss.str(); + oss << v; + if (labelValue) + { + std::string s = oss.str(); + labelValue->SetLabel(wxString::FromAscii(oss.str().c_str())); + } + } + + void setValue(deValue v) + { + setLabelValue(v); + setSlider(v); + } + + void setSlider(deValue v) + { + if (width == 0) + { + return; + } + + if (max == min) + { + return; + } + + deValue sl = (v - min) / ((max-min) / width); + + slider->SetValue(sl); + } + +}; + +deSlider::deSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl) +{ +#ifdef DEBUG_LOG + logInfo("deSlider constructor"); +#endif + deWindowWX* w = dynamic_cast(&window); + if (w) + { + impl = new deSliderImpl(*this, window, _name, _min, _max, _width, widthn, widthl); + } + else + { + impl = NULL; + } +} + +deSlider::~deSlider() +{ +#ifdef DEBUG_LOG + logInfo("deSlider destructor"); +#endif + if (impl) + { + delete impl; + } +} + +void deSlider::setValue(deValue v) +{ + if (impl) + { + impl->setValue(v); + } +} + +deWindow& deSlider::getWindow() +{ + return impl->getWindow(); +} diff -Nru delaboratory-0.7/gui_wx/slider.h delaboratory-0.8/gui_wx/slider.h --- delaboratory-0.7/gui_wx/slider.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/slider.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,45 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SLIDER_H +#define _DE_SLIDER_H + +#include "value.h" +#include +class dePanel; +class deWindow; +class deLayerProcessor; + +class deSliderImpl; + +class deSlider +{ + private: + deSliderImpl* impl; + public: + deSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl); + virtual ~deSlider(); + + void setValue(deValue v); + virtual void onValueChange(deValue value, bool finished) = 0; + + deWindow& getWindow(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/str_wx.cc delaboratory-0.8/gui_wx/str_wx.cc --- delaboratory-0.7/gui_wx/str_wx.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/str_wx.cc 2012-07-28 22:06:31.000000000 +0000 @@ -0,0 +1,56 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "str_wx.h" +#include + +std::string str(const wxString& ws) +{ + char cstring[1024]; + strncpy(cstring, (const char*)ws.mb_str(wxConvUTF8), 1023); + + return cstring; +} + +wxString str2wx(const std::string& s) +{ + const char* c = s.c_str(); + wxString result(c, wxConvUTF8); + + return result; +} + +std::string getUserDataDir() +{ + wxStandardPathsBase& paths = wxStandardPaths::Get(); + + wxString ucd = paths.GetUserDataDir(); + std::string userDataDir = str(ucd); +#ifdef _WIN32 + userDataDir += "\\delaboratory"; +#else +#ifdef __WXOSX_MAC__ + userDataDir += "/delaboratory"; +#else + userDataDir += "/.delaboratory"; +#endif +#endif + + return userDataDir; +} + diff -Nru delaboratory-0.7/gui_wx/str_wx.h delaboratory-0.8/gui_wx/str_wx.h --- delaboratory-0.7/gui_wx/str_wx.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/str_wx.h 2012-07-28 22:06:31.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_STR_WX_H +#define _DE_STR_WX_H + +#include +#include "value.h" +#include + +wxString str2wx(const std::string& s); +std::string str(const wxString& ws); + +std::string getUserDataDir(); + +#endif diff -Nru delaboratory-0.7/gui_wx/threads_panel.cc delaboratory-0.8/gui_wx/threads_panel.cc --- delaboratory-0.7/gui_wx/threads_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/threads_panel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,100 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "threads_panel.h" +#include "layer_processor.h" + +deThreadsPanel::deThreadsPanel(wxWindow* parent) +:wxPanel(parent) +{ + //wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("thread activity")); + wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("threads")); + SetSizer(sizerP); + + //processingInfo = new wxStaticText(this, wxID_ANY, _T("[processing]"), wxDefaultPosition); + processingInfo = new wxStaticText(this, wxID_ANY, _T("[p]"), wxDefaultPosition); + sizerP->Add(processingInfo, 0, wxEXPAND); + + //renderingInfo = new wxStaticText(this, wxID_ANY, _T("[rendering]"), wxDefaultPosition); + renderingInfo = new wxStaticText(this, wxID_ANY, _T("[r]"), wxDefaultPosition); + sizerP->Add(renderingInfo, 0, wxEXPAND); + + //histogramInfo = new wxStaticText(this, wxID_ANY, _T("[histogram]"), wxDefaultPosition); + histogramInfo = new wxStaticText(this, wxID_ANY, _T("[h]"), wxDefaultPosition); + sizerP->Add(histogramInfo, 0, wxEXPAND); + + //dcrawInfo = new wxStaticText(this, wxID_ANY, _T("[dcraw]"), wxDefaultPosition); + dcrawInfo = new wxStaticText(this, wxID_ANY, _T("[d]"), wxDefaultPosition); + sizerP->Add(dcrawInfo, 0, wxEXPAND); +} + +deThreadsPanel::~deThreadsPanel() +{ + +} + +void deThreadsPanel::setInfoColor(int i) +{ + int e = 100; + int e2 = 50; + int d = 150; + switch (i) + { + case DE_PROCESSING_START: + { + processingInfo->SetForegroundColour(wxColour(e, e, e)); + break; + } + case DE_PROCESSING_END: + { + processingInfo->SetForegroundColour(wxColour(d, d, d)); + break; + } + case DE_RENDERING_START: + { + renderingInfo->SetForegroundColour(wxColour(e, e, e)); + break; + } + case DE_RENDERING_END: + { + renderingInfo->SetForegroundColour(wxColour(d, d, d)); + break; + } + case DE_HISTOGRAM_START: + { + histogramInfo->SetForegroundColour(wxColour(e, e, e)); + break; + } + case DE_HISTOGRAM_END: + { + histogramInfo->SetForegroundColour(wxColour(d, d, d)); + break; + } + case DE_DCRAW_START: + { + dcrawInfo->SetForegroundColour(wxColour(e2, e2, e2)); + break; + } + case DE_DCRAW_END: + { + dcrawInfo->SetForegroundColour(wxColour(d, d, d)); + break; + } + } +} + diff -Nru delaboratory-0.7/gui_wx/threads_panel.h delaboratory-0.8/gui_wx/threads_panel.h --- delaboratory-0.7/gui_wx/threads_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/threads_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,41 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_THREADS_PANEL_H +#define _DE_THREADS_PANEL_H + +#include + +class deThreadsPanel:public wxPanel +{ + private: + wxStaticText* processingInfo; + wxStaticText* renderingInfo; + wxStaticText* histogramInfo; + //wxStaticText* debugInfo; + wxStaticText* dcrawInfo; + public: + deThreadsPanel(wxWindow* parent); + virtual ~deThreadsPanel(); + + void setInfoColor(int i); + + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/tiff.cc delaboratory-0.8/gui_wx/tiff.cc --- delaboratory-0.7/gui_wx/tiff.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/tiff.cc 2012-07-15 08:17:38.000000000 +0000 @@ -0,0 +1,241 @@ +/* + + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "tiff.h" +#include +#include "static_image.h" +#include +#include "logger.h" + +TIFF* openTIFF(const std::string fileName, bool write) +{ + std::string mode = ""; + if (write) + { + logInfo("opening TIFF " + fileName + " in write mode"); + mode = "w"; + } + else + { + logInfo("opening TIFF " + fileName + " in read mode"); + mode = "r"; + } + + TIFF* tif = NULL; + + const char* c = fileName.c_str(); + +#ifdef _WIN32 + wxString ws(c, wxConvUTF8); + const wchar_t* wc = ws.wc_str(wxConvUTF8); + tif = TIFFOpenW(wc, mode.c_str()); +#else + tif = TIFFOpen(c, mode.c_str()); +#endif + logInfo("DONE opening TIFF"); + + return tif; +} + + +bool loadTIFF(const std::string& fileName, deStaticImage& image) +{ + TIFF* tif = openTIFF(fileName, false); + if (!tif) + { + return false; + } + tdata_t buf; + + image.lock(); + + int w; + int h; + uint16 bps; + uint16 spp; + uint16 photometric; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp); + TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); + + deSize size(w, h); + image.setSize(size); + + image.setColorSpace(deColorSpaceRGB); + if (photometric != PHOTOMETRIC_RGB) + { + logInfo("loading not RGB image, let's use LAB"); + image.setColorSpace(deColorSpaceLAB); + } + + deValue* pixelsR = image.startWriteStatic(0); + deValue* pixelsG = image.startWriteStatic(1); + deValue* pixelsB = image.startWriteStatic(2); + + int pos = 0; + int y; + + int ssize = TIFFScanlineSize(tif); + buf = _TIFFmalloc(ssize); + + deValue d = -1; + if (bps == 16) + { + logInfo("bps 16"); + d = (256 * 256) - 1; + } + else + { + logInfo("bps not 16"); + d = 256 - 1; + } + + for (y = 0; y < h; y++) + { + TIFFReadScanline(tif, buf, y); + int x; + for (x = 0; x < w; x++) + { + deValue r; + deValue g; + deValue b; + if (bps == 16) + { + uint16* bb = (uint16*)(buf); + uint16 u1 = bb[spp*x+0]; + uint16 u2 = bb[spp*x+1]; + uint16 u3 = bb[spp*x+2]; + r = u1 / d; + g = u2 / d; + b = u3 / d; + } + else + { + uint8* bb = (uint8*)(buf); + uint8 u1 = bb[spp*x+0]; + uint8 u2 = bb[spp*x+1]; + uint8 u3 = bb[spp*x+2]; + r = u1 / d; + g = u2 / d; + b = u3 / d; + } + + if (photometric == PHOTOMETRIC_RGB) + { + pixelsR[pos] = r; + pixelsG[pos] = g; + pixelsB[pos] = b; + } + else + { + // LAB + pixelsR[pos] = r; + g += 0.5; + if (g > 1) + { + g -= 1.0; + } + b += 0.5; + if (b > 1) + { + b -= 1.0; + } + pixelsG[pos] = g; + pixelsB[pos] = b; + + } + + pos++; + } + } + + image.finishWriteStatic(0); + image.finishWriteStatic(1); + image.finishWriteStatic(2); + image.unlock(); + + _TIFFfree(buf); + TIFFClose(tif); + + return true; +} + +bool saveTIFF(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size) +{ + int w = size.getW(); + int h = size.getH(); + + if ((!channelR) || (!channelG) || (!channelB)) + { + return false; + } + + TIFF* tif = openTIFF(fileName, true); + + if (!tif) + { + return false; + } + + TIFFSetField (tif, TIFFTAG_SOFTWARE, "delaboratory"); + TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, w); + TIFFSetField (tif, TIFFTAG_IMAGELENGTH, h); + TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 16); + TIFFSetField (tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, h); + TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + + tdata_t buf; + int ssize = TIFFScanlineSize(tif); + buf = _TIFFmalloc(ssize); + uint16* bb = (uint16*)(buf); + + int pos = 0; + int y; + for (y = 0; y < h; y++) + { + int x; + for (x = 0; x < w; x++) + { + deValue d = 256 * 256 - 1 ; + deValue r = d * channelR[pos]; + deValue g = d * channelG[pos]; + deValue b = d * channelB[pos]; + bb[3*x+0] = r; + bb[3*x+1] = g; + bb[3*x+2] = b;; + + pos++; + + } + TIFFWriteScanline (tif, buf, y, 0); + } + + TIFFClose(tif); + + return true; + +} + diff -Nru delaboratory-0.7/gui_wx/tiff.h delaboratory-0.8/gui_wx/tiff.h --- delaboratory-0.7/gui_wx/tiff.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/tiff.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,30 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LOAD_TIFF_H +#define _DE_LOAD_TIFF_H + +class deStaticImage; +#include +#include "value.h" +#include "size.h" + +bool loadTIFF(const std::string& fileName, deStaticImage& image); +bool saveTIFF(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size); + +#endif diff -Nru delaboratory-0.7/gui_wx/tmp.cc delaboratory-0.8/gui_wx/tmp.cc --- delaboratory-0.7/gui_wx/tmp.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/tmp.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,36 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "tmp.h" +#include +#include "str_wx.h" + +std::string getTmp() +{ + wxString temp; + if (wxGetEnv(_T("TEMP"), &temp)) + { + // on Windows $TEMP should be set + return str(temp); + } + else + { + return "/tmp"; + } +} + diff -Nru delaboratory-0.7/gui_wx/tmp.h delaboratory-0.8/gui_wx/tmp.h --- delaboratory-0.7/gui_wx/tmp.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/tmp.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_TMP_H +#define _DE_TMP_H + +#include + +std::string getTmp(); + +#endif diff -Nru delaboratory-0.7/gui_wx/update_blend.cc delaboratory-0.8/gui_wx/update_blend.cc --- delaboratory-0.7/gui_wx/update_blend.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/update_blend.cc 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,74 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "update_blend.h" +#include +#include "color_space_utils.h" +#include "layer_with_blending.h" +#include "semaphore.h" + +class deUpdateBlendThread:public wxThread +{ + private: + virtual void *Entry() + { + layer.updateBlend(channel); + semaphore.post(); + return NULL; + } + deLayerWithBlending& layer; + int channel; + deSemaphore& semaphore; + public: + deUpdateBlendThread(deLayerWithBlending& _layer, int _channel, deSemaphore& _semaphore) + :layer(_layer), + channel(_channel), + semaphore(_semaphore) + { + } + virtual ~deUpdateBlendThread() + { + } +}; + +void updateBlendOnThread(deLayerWithBlending& layer) +{ + int n = getColorSpaceSize(layer.getColorSpace()); + int i; + + deSemaphore semaphore(0, n); + + for (i = 0; i < n; i++) + { + deUpdateBlendThread* thread = new deUpdateBlendThread(layer, i, semaphore); + + if ( thread->Create() != wxTHREAD_NO_ERROR ) + { + } + + if ( thread->Run() != wxTHREAD_NO_ERROR ) + { + } + } + + for (i = 0; i < n; i++) + { + semaphore.wait(); + } +} + diff -Nru delaboratory-0.7/gui_wx/update_blend.h delaboratory-0.8/gui_wx/update_blend.h --- delaboratory-0.7/gui_wx/update_blend.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/update_blend.h 2012-06-12 00:31:57.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_UPDATE_BLEND_H +#define _DE_UPDATE_BLEND_H + +class deLayerWithBlending; + +void updateBlendOnThread(deLayerWithBlending& layer); + +#endif diff -Nru delaboratory-0.7/gui_wx/update_main_layer_image.cc delaboratory-0.8/gui_wx/update_main_layer_image.cc --- delaboratory-0.7/gui_wx/update_main_layer_image.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/update_main_layer_image.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,94 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "update_main_layer_image.h" +#include +#include "base_layer.h" +#include "semaphore.h" +#include "logger.h" +#include "color_space_utils.h" +#include "str.h" + +class deUpdateActionThread:public wxThread +{ + private: + virtual void *Entry() + { + bool result = layer.processMainImageSingleChannel(channel); + if (!result) + { + logInfo("update action failed"); + } + semaphore.post(); + return NULL; + } + deBaseLayer& layer; + int channel; + deSemaphore& semaphore; + public: + deUpdateActionThread(deBaseLayer& _layer, int _channel, deSemaphore& _semaphore) + :layer(_layer), + channel(_channel), + semaphore(_semaphore) + { + } + virtual ~deUpdateActionThread() + { + } +}; + +void updateMainImageAllChannels(deBaseLayer& layer) +{ +#ifdef DEBUG_LOG + logInfo("update action all channels start"); +#endif + + int n = getColorSpaceSize(layer.getColorSpace()); + int i; + + deSemaphore semaphore(0, n); + + for (i = 0; i < n; i++) + { +#ifdef DEBUG_LOG + logInfo("creating update action thread for channel " + str(i)); +#endif + deUpdateActionThread* thread = new deUpdateActionThread(layer, i, semaphore); + + if ( thread->Create() != wxTHREAD_NO_ERROR ) + { + } + + if ( thread->Run() != wxTHREAD_NO_ERROR ) + { + } + } + + for (i = 0; i < n; i++) + { +#ifdef DEBUG_LOG + logInfo("waiting for update action thread for channel " + str(i)); +#endif + semaphore.wait(); + } + +#ifdef DEBUG_LOG + logInfo("update action all channels DONE"); +#endif +} + diff -Nru delaboratory-0.7/gui_wx/update_main_layer_image.h delaboratory-0.8/gui_wx/update_main_layer_image.h --- delaboratory-0.7/gui_wx/update_main_layer_image.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/update_main_layer_image.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,26 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_UPDATE_MAIN_LAYER_IMAGE_H +#define _DE_UPDATE_MAIN_LAYER_IMAGE_H + +class deBaseLayer; + +void updateMainImageAllChannels(deBaseLayer& layer); + +#endif diff -Nru delaboratory-0.7/gui_wx/view_mode_panel.cc delaboratory-0.8/gui_wx/view_mode_panel.cc --- delaboratory-0.7/gui_wx/view_mode_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/view_mode_panel.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,139 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "view_mode_panel.h" +#include +#include "color_space.h" +#include "project.h" +#include +#include "logger.h" +#include "color_space_utils.h" +#include "gui.h" + +void deViewModePanel::select(wxCommandEvent &event) +{ + int i = event.GetId(); + deViewManager& viewManager = project.getViewManager(); + + if (buttons[0]->GetId() == i) + { + viewManager.setNormal(); + return; + } + + int j; + for (j = 0; j < MAX_COLOR_SPACE_SIZE; j++) + { + if (buttons[j+1]->GetId() == i) + { + viewManager.setSingleChannel(j); + } + } + +} + +deViewModePanel::deViewModePanel(wxWindow* parent, deProject& _project, deGUI& gui) +:wxPanel(parent), project(_project) +{ + gui.setViewModePanel(this); + + wxSizer* sizerS = new wxStaticBoxSizer(wxVERTICAL, this, _T("view")); + SetSizer(sizerS); + + wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + sizerS->Add(sizer); + + int i; + for (i = 0; i < (MAX_COLOR_SPACE_SIZE + 1); i++) + { + int style = 0; + if (i == 0) + { + style = wxRB_GROUP; + } + wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); + sizer->Add(b); + buttons.push_back(b); + + } + + updateNames(); + updateMode(); + + Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deViewModePanel::select)); + +} + +deViewModePanel::~deViewModePanel() +{ + +} + +void deViewModePanel::updateNames() +{ + deViewManager& viewManager = project.getViewManager(); + + deColorSpace colorSpace = viewManager.getColorSpace(); + + int i; + int n = getColorSpaceSize(colorSpace); + for (i = 0; i < ( MAX_COLOR_SPACE_SIZE + 1) ; i++) + { + wxRadioButton* b = buttons[i]; + if (i == 0) + { + b->SetLabel(wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); + b->Show(); + } + else + { + int c = i - 1; + if (c < n) + { + std::string name = getChannelName(colorSpace, c); + b->SetLabel(wxString::FromAscii(name.c_str())); + b->Show(); + } + else + { + b->Hide(); + } + } + + } + + Layout(); + Fit(); + SetFocus(); +} + +void deViewModePanel::updateMode() +{ + deViewManager& viewManager = project.getViewManager(); + + if (viewManager.isSingleChannel()) + { + int c = viewManager.getChannel(); + buttons[c+1]->SetValue(1); + } + else + { + buttons[0]->SetValue(1); + } +} + diff -Nru delaboratory-0.7/gui_wx/view_mode_panel.h delaboratory-0.8/gui_wx/view_mode_panel.h --- delaboratory-0.7/gui_wx/view_mode_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/view_mode_panel.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,45 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_VIEW_MODE_PANEL_H +#define _DE_VIEW_MODE_PANEL_H + +#include +#include +#include +#include "color_space.h" +class deProject; +class deGUI; + +class deViewModePanel:public wxPanel +{ + private: + std::vector buttons; + deProject& project; + + void select(wxCommandEvent &event); + public: + deViewModePanel(wxWindow* parent, deProject& _project, deGUI& gui); + virtual ~deViewModePanel(); + + void updateNames(); + void updateMode(); + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/warning_panel.cc delaboratory-0.8/gui_wx/warning_panel.cc --- delaboratory-0.7/gui_wx/warning_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/warning_panel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,53 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "warning_panel.h" + +deWarningPanel::deWarningPanel(wxWindow* parent) +:wxPanel(parent) +{ + SetMinSize(wxSize(220,10)); + + wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("status")); + SetSizer(sizerP); + + warning = new wxStaticText(this, wxID_ANY, _T(""), wxDefaultPosition); + sizerP->Add(warning, 0, wxEXPAND); + +} + +deWarningPanel::~deWarningPanel() +{ + +} + +void deWarningPanel::setWarning(const std::string& w) +{ + warning->SetLabel(wxString::FromAscii(w.c_str())); + + if (w == "OK") + { + unsigned char g = 128; + warning->SetForegroundColour(wxColour(g, g, g)); + } + else + { + warning->SetForegroundColour(wxColour(255, 0, 0)); + } +} + diff -Nru delaboratory-0.7/gui_wx/warning_panel.h delaboratory-0.8/gui_wx/warning_panel.h --- delaboratory-0.7/gui_wx/warning_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/warning_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,37 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_WARNING_PANEL_H +#define _DE_WARNING_PANEL_H + +#include + +class deWarningPanel:public wxPanel +{ + private: + wxStaticText* warning; + public: + deWarningPanel(wxWindow* parent); + virtual ~deWarningPanel(); + + void setWarning(const std::string& w); + + +}; + +#endif diff -Nru delaboratory-0.7/gui_wx/window.cc delaboratory-0.8/gui_wx/window.cc --- delaboratory-0.7/gui_wx/window.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/window.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "window.h" + +deWindow::deWindow() +{ +} + +deWindow::~deWindow() +{ +} + diff -Nru delaboratory-0.7/gui_wx/window.h delaboratory-0.8/gui_wx/window.h --- delaboratory-0.7/gui_wx/window.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/window.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,31 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_WINDOW_H +#define _DE_WINDOW_H + +class deWindow +{ + private: + public: + deWindow(); + virtual ~deWindow(); +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/window_wx.cc delaboratory-0.8/gui_wx/window_wx.cc --- delaboratory-0.7/gui_wx/window_wx.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/window_wx.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,33 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "window_wx.h" + +deWindowWX::deWindowWX(wxWindow* _window) +:window(_window) +{ +} + +deWindowWX::~deWindowWX() +{ +} + +wxWindow* deWindowWX::getWindow() +{ + return window; +} diff -Nru delaboratory-0.7/gui_wx/window_wx.h delaboratory-0.8/gui_wx/window_wx.h --- delaboratory-0.7/gui_wx/window_wx.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/window_wx.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_WINDOW_WX_H +#define _DE_WINDOW_WX_H + +#include "window.h" +#include + +class deWindowWX:public deWindow +{ + private: + wxWindow* window; + public: + deWindowWX(wxWindow* _window); + virtual ~deWindowWX(); + + wxWindow* getWindow(); + +}; + + +#endif diff -Nru delaboratory-0.7/gui_wx/xml.cc delaboratory-0.8/gui_wx/xml.cc --- delaboratory-0.7/gui_wx/xml.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/xml.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,36 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "xml.h" + +void saveChild(xmlNodePtr node, std::string name, std::string value) +{ + xmlChar* _name = BAD_CAST(name.c_str()); + xmlChar* _value = BAD_CAST(value.c_str()); + + xmlNodePtr child = xmlNewChild(node, NULL, _name, NULL); + xmlNodeSetContent(child, _value); +} + +std::string getContent(xmlNodePtr node) +{ + xmlChar* xs = xmlNodeGetContent(node); + std::string s = (char*)(xs); + xmlFree(xs); + return s; +} diff -Nru delaboratory-0.7/gui_wx/xml.h delaboratory-0.8/gui_wx/xml.h --- delaboratory-0.7/gui_wx/xml.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/xml.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,28 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_XML_H +#define _DE_XML_H + +#include +#include + +void saveChild(xmlNodePtr node, std::string name, std::string value); +std::string getContent(xmlNodePtr node); + +#endif diff -Nru delaboratory-0.7/gui_wx/zoom_panel.cc delaboratory-0.8/gui_wx/zoom_panel.cc --- delaboratory-0.7/gui_wx/zoom_panel.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/zoom_panel.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,94 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "zoom_panel.h" +#include "zoom_manager.h" +#include "image_area_panel.h" + +deZoomPanel::deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager) +:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), zoomManager(_zoomManager) +{ + imageAreaPanel = NULL; + + wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("zoom")); + SetSizer(sizerS); + + zoomIn = new wxButton(this, wxID_ANY, _T("select"), wxDefaultPosition, wxSize(60,25)); + sizerS->Add(zoomIn); + + zoomOut = new wxButton(this, wxID_ANY, _T("full"), wxDefaultPosition, wxSize(60,25)); + sizerS->Add(zoomOut); + + Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deZoomPanel::click)); + + updateButtons(); + +} + +void deZoomPanel::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) +{ + imageAreaPanel = _imageAreaPanel; +} + +deZoomPanel::~deZoomPanel() +{ +} + +void deZoomPanel::click(wxCommandEvent &event) +{ + int id = event.GetId(); + + if (zoomIn->GetId() == id) + { + zoomManager.enableSelectionMode(); + } + + if (zoomOut->GetId() == id) + { + zoomManager.fullZoomOut(); + if (imageAreaPanel) + { + imageAreaPanel->updateSize(false); + } + } + + updateButtons(); + +} + +void deZoomPanel::updateButtons() +{ + if (zoomManager.isInSelectionMode()) + { + zoomIn->Disable(); + zoomOut->Disable(); + return; + } + + if (zoomManager.isZoomed()) + { + zoomIn->Enable(); + zoomOut->Enable(); + } + else + { + zoomIn->Enable(); + zoomOut->Disable(); + } + +} diff -Nru delaboratory-0.7/gui_wx/zoom_panel.h delaboratory-0.8/gui_wx/zoom_panel.h --- delaboratory-0.7/gui_wx/zoom_panel.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/gui_wx/zoom_panel.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,47 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_ZOOM_PANEL_H +#define _DE_ZOOM_PANEL_H + +#include +class deZoomManager; +class deImageAreaPanel; + +class deZoomPanel:public wxPanel +{ + private: + deZoomManager& zoomManager; + deImageAreaPanel* imageAreaPanel; + + wxButton* zoomIn; + wxButton* zoomOut; + + void click(wxCommandEvent &event); + + + public: + deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager); + virtual ~deZoomPanel(); + + void updateButtons(); + + void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); +}; + +#endif diff -Nru delaboratory-0.7/layers/auto_burn_layer.cc delaboratory-0.8/layers/auto_burn_layer.cc --- delaboratory-0.7/layers/auto_burn_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/auto_burn_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,77 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "auto_burn_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" +#include "logger.h" + +deAutoBurnLayer::deAutoBurnLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius 1", 10, 100); + reset->addNumericValue("radius 1", 20); + createPropertyNumeric("radius 2", 5, 50); + reset->addNumericValue("radius 2", 10); + createPropertyNumeric("threshold", 0.0, 1.0); + reset->addNumericValue("threshold", 0.5); + applyPreset("reset"); + setOpacity(0.5); + disableNotForSharpen(); +} + +deAutoBurnLayer::~deAutoBurnLayer() +{ +} + +bool deAutoBurnLayer::updateMainImageSingleChannel(int channel) +{ +/* + if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + return true; + } + */ + + deValue r1 = getNumericValue("radius 1") * viewManager.getRealScale();; + deValue r2 = getNumericValue("radius 2") * viewManager.getRealScale();; + deValue t = getNumericValue("threshold"); + + deSize size = mainLayerImage.getChannelSize(); + +// mainLayerImage.enableChannel(channel); + const deValue* source = getSourceImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(channel); + + bool result = false; + + if ((source) && (destination)) + { + result = autoDodgeBurn(source, destination, size, r1, r2, t, true); + } + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return result; +} + diff -Nru delaboratory-0.7/layers/auto_burn_layer.h delaboratory-0.8/layers/auto_burn_layer.h --- delaboratory-0.7/layers/auto_burn_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/auto_burn_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_AUTO_BURN_LAYER_H +#define _DE_AUTO_BURN_LAYER_H + +#include "layer_with_blending.h" + +class deAutoBurnLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "auto_burn";}; + deViewManager& viewManager; + + public: + deAutoBurnLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deAutoBurnLayer(); + + virtual bool updateMainImageSingleChannel(int channel); + +}; + +#endif diff -Nru delaboratory-0.7/layers/auto_dodge_layer.cc delaboratory-0.8/layers/auto_dodge_layer.cc --- delaboratory-0.7/layers/auto_dodge_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/auto_dodge_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,77 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "auto_dodge_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" +#include "logger.h" + +deAutoDodgeLayer::deAutoDodgeLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius 1", 10, 100); + reset->addNumericValue("radius 1", 20); + createPropertyNumeric("radius 2", 5, 50); + reset->addNumericValue("radius 2", 10); + createPropertyNumeric("threshold", 0.0, 1.0); + reset->addNumericValue("threshold", 0.5); + applyPreset("reset"); + setOpacity(0.5); + disableNotForSharpen(); +} + +deAutoDodgeLayer::~deAutoDodgeLayer() +{ +} + +bool deAutoDodgeLayer::updateMainImageSingleChannel(int channel) +{ +/* + if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + return true; + } + */ + + deValue r1 = getNumericValue("radius 1") * viewManager.getRealScale();; + deValue r2 = getNumericValue("radius 2") * viewManager.getRealScale();; + deValue t = getNumericValue("threshold"); + + deSize size = mainLayerImage.getChannelSize(); + +// mainLayerImage.enableChannel(channel); + const deValue* source = getSourceImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(channel); + + bool result = false; + + if ((source) && (destination)) + { + result = autoDodgeBurn(source, destination, size, r1, r2, t, false); + } + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return result; +} + diff -Nru delaboratory-0.7/layers/auto_dodge_layer.h delaboratory-0.8/layers/auto_dodge_layer.h --- delaboratory-0.7/layers/auto_dodge_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/auto_dodge_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_AUTO_DODGE_LAYER_H +#define _DE_AUTO_DODGE_LAYER_H + +#include "layer_with_blending.h" + +class deAutoDodgeLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "auto_dodge";}; + deViewManager& viewManager; + + public: + deAutoDodgeLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deAutoDodgeLayer(); + + virtual bool updateMainImageSingleChannel(int channel); + +}; + +#endif diff -Nru delaboratory-0.7/layers/c2g_layer.cc delaboratory-0.8/layers/c2g_layer.cc --- delaboratory-0.7/layers/c2g_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/c2g_layer.cc 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,127 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "c2g_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "fill_channel.h" +#include "color_space_utils.h" +#include "blend_channel.h" +#include "logger.h" +#include "c2g.h" +#include "str.h" + +deC2GLayer::deC2GLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("radius", 1, 1000); + reset->addNumericValue("radius", 300); + + createPropertyNumeric("samples", 1, 500); + reset->addNumericValue("samples", 10); + + applyPreset("reset"); + +} + +deC2GLayer::~deC2GLayer() +{ +} + +bool deC2GLayer::updateMainImageNotThreadedWay() +{ + deValue samples = getNumericValue("samples"); + + logInfo("c2g_layer START samples: " + str(samples)); + + deSize size = mainLayerImage.getChannelSize(); + int n = size.getN(); + + deValue* mask = NULL; + try + { + mask = new deValue [n]; + } + catch (std::bad_alloc) + { + logError("allocating memory in c2g"); + if (mask) + { + delete [] mask; + } + return false; + } + + + // clear destination + fillChannel(mask, n, 0.0); + + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + + const deValue* source0 = getOriginalImage().startRead(0); + const deValue* source1 = getOriginalImage().startRead(1); + const deValue* source2 = getOriginalImage().startRead(2); + + logInfo("c2g_layer before c2g"); + c2g(source0, source1, source2, mask, size, r, samples); + logInfo("c2g_layer after c2g"); + + getOriginalImage().finishRead(0); + getOriginalImage().finishRead(1); + getOriginalImage().finishRead(2); + + int nc = getColorSpaceSize(colorSpace); + int channel; + for (channel = 0; channel < nc; channel++) + { + /* + if (!isChannelEnabled(channel)) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + } + else + */ + { + //mainLayerImage.enableChannel(channel); + deValue* destination = mainLayerImage.startWrite(channel); + int i; + for (i = 0; i < n; i++) + { + destination[i] = mask[i]; + } + mainLayerImage.finishWrite(channel); + } + } + + delete [] mask; + + logInfo("c2g_layer DONE"); + + return true; +} + +void deC2GLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); + + getOriginalImage().updateChannelUsage(channelUsage, layerIndex); +} + diff -Nru delaboratory-0.7/layers/c2g_layer.h delaboratory-0.8/layers/c2g_layer.h --- delaboratory-0.7/layers/c2g_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/c2g_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,40 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_C2G_LAYER_H +#define _DE_C2G_LAYER_H + +#include "layer_with_blending.h" + +class deC2GLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "c2g";}; + deViewManager& viewManager; + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + public: + deC2GLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deC2GLayer(); + + virtual bool updateMainImageNotThreadedWay(); + +}; + +#endif diff -Nru delaboratory-0.7/layers/conversion_layer.cc delaboratory-0.8/layers/conversion_layer.cc --- delaboratory-0.7/layers/conversion_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/conversion_layer.cc 2012-07-26 01:09:54.000000000 +0000 @@ -0,0 +1,136 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "conversion_layer.h" +#include "layer_stack.h" +#include "conversion_processor.h" +#include "str.h" +#include "preset.h" +#include "logger.h" + +deConversionLayer::deConversionLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deBaseLayerWithSource( _colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + + deColorSpace scs = getSourceColorSpace(); + + if ((scs == deColorSpaceProPhoto) || (scs == deColorSpaceLAB) || (scs == deColorSpaceLCH)) + { + deValue c = 1.0; + createPropertyNumeric("contrast", 0, 1.0); + reset->addNumericValue("contrast", c); + } + + if ((scs == deColorSpaceLAB) || (scs == deColorSpaceLCH)) + { + createPropertyNumeric("saturation", 0, 1); + reset->addNumericValue("saturation", 1); + } + + if (colorSpace == deColorSpaceCMYK) + { + createPropertyNumeric("GCR substract", 0, 1); + reset->addNumericValue("GCR substract", 0.25); + createPropertyNumeric("GCR Key max", 0, 1); + reset->addNumericValue("GCR Key max", 1.0); + createPropertyNumeric("GCR CMY min", 0, 3); + reset->addNumericValue("GCR CMY min", 0.0); + } + + if (colorSpace == deColorSpaceBW) + { + createPropertyNumeric("mixer red", -3, 3); + reset->addNumericValue("mixer red", 0.3); + createPropertyNumeric("mixer green", -3, 3); + reset->addNumericValue("mixer green", 0.6); + createPropertyNumeric("mixer blue", -3, 3); + reset->addNumericValue("mixer blue", 0.1); + + } + + if (scs == deColorSpaceBW) + { + createPropertyNumeric("pseudogrey", 0, 1.0); + reset->addNumericValue("pseudogrey", 0); + } + + applyPreset("reset"); + +} + +deConversionLayer::~deConversionLayer() +{ +} + +bool deConversionLayer::updateMainImageNotThreadedWay() +{ +#ifdef DEBUG_LOG + logInfo("conversion layer start"); +#endif + + deConversionProcessor p; + + deConversionCPU cpu(4); + + cpu.registers[CPU_REGISTER_OVERFLOW] = 0; + cpu.registers[CPU_REGISTER_CMYK_KEY_SUB] = getNumericValue("GCR substract"); + cpu.registers[CPU_REGISTER_CMYK_KEY_MAX] = getNumericValue("GCR Key max"); + cpu.registers[CPU_REGISTER_CMYK_MIN_SUM] = getNumericValue("GCR CMY min"); + cpu.registers[CPU_REGISTER_BW_MIXER_R] = getNumericValue("mixer red"); + cpu.registers[CPU_REGISTER_BW_MIXER_G] = getNumericValue("mixer green"); + cpu.registers[CPU_REGISTER_BW_MIXER_B] = getNumericValue("mixer blue"); + cpu.registers[CPU_REGISTER_CONTRAST] = getNumericValue("contrast"); + cpu.registers[CPU_REGISTER_SATURATION] = getNumericValue("saturation"); + cpu.registers[CPU_REGISTER_PSEUDOGREY] = getNumericValue("pseudogrey"); + +#ifdef DEBUG_LOG + logInfo("conversion layer contrast: " + str(cpu.registers[CPU_REGISTER_CONTRAST])); + logInfo("conversion layer saturation: " + str(cpu.registers[CPU_REGISTER_SATURATION])); +#endif + + p.convertImage(getSourceImage(), mainLayerImage, cpu); + + deValue overflow = cpu.registers[CPU_REGISTER_OVERFLOW]; + int n = getSourceImage().getChannelSize().getN(); + int percentage = overflow * 10000 / n; + + if (percentage == 0) + { + warning = "OK"; + } + else + { + deValue p = percentage / 100.0; + warning = "conversion OVERFLOW " + str(p) + "%"; + } + +#ifdef DEBUG_LOG + logInfo("conversion layer DONE"); +#endif + + return true; +} + +void deConversionLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + getSourceImage().updateChannelUsage(channelUsage, layerIndex); + + deBaseLayer::updateChannelUsage(channelUsage, layerIndex); +} + diff -Nru delaboratory-0.7/layers/conversion_layer.h delaboratory-0.8/layers/conversion_layer.h --- delaboratory-0.7/layers/conversion_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/conversion_layer.h 2012-07-26 01:09:54.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CONVERSION_LAYER_H +#define _DE_CONVERSION_LAYER_H + +#include "base_layer_with_source.h" +#include "image.h" +class deLayerStack; +class deChannelManager; + +class deConversionLayer:public deBaseLayerWithSource +{ + private: + virtual std::string getType() const {return "conversion";}; + + std::string warning; + + public: + deConversionLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deConversionLayer(); + + virtual bool updateMainImageNotThreadedWay(); + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + virtual std::string getActionName() {return "conversion setup";}; + + virtual std::string getWarning() const {return warning;}; + + +}; + +#endif diff -Nru delaboratory-0.7/layers/copy_layer.cc delaboratory-0.8/layers/copy_layer.cc --- delaboratory-0.7/layers/copy_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/copy_layer.cc 2012-07-10 23:38:22.000000000 +0000 @@ -0,0 +1,64 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "copy_layer.h" +#include "layer_stack.h" +#include "conversion_processor.h" +#include "str.h" +#include "preset.h" +#include "logger.h" + +deCopyLayer::deCopyLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending( _colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + int size = getLayerStackSize(); + std::vector numbers = createNumbers(size); + + createPropertyChoice("layer", numbers); +} + +deCopyLayer::~deCopyLayer() +{ +} + +bool deCopyLayer::updateMainImageNotThreadedWay() +{ + logInfo("conversion layer start"); + + deConversionProcessor p; + + deConversionCPU cpu(4); + + int l = getPropertyChoice("layer")->getIndex(); + const deImage& image = getOtherLayerImage(l); + p.convertImage(image, mainLayerImage, cpu); + + logInfo("conversion layer DONE"); + + return true; +} + +void deCopyLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + int l = getPropertyChoice("layer")->getIndex(); + const deImage& image = getOtherLayerImage(l); + image.updateChannelUsage(channelUsage, layerIndex); + + deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); +} + diff -Nru delaboratory-0.7/layers/copy_layer.h delaboratory-0.8/layers/copy_layer.h --- delaboratory-0.7/layers/copy_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/copy_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_COPY_LAYER_H +#define _DE_COPY_LAYER_H + +#include "layer_with_blending.h" +#include "image.h" +class deLayerStack; +class deChannelManager; + +class deCopyLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "copy";}; + + public: + deCopyLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deCopyLayer(); + + virtual bool updateMainImageNotThreadedWay(); + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + +}; + +#endif diff -Nru delaboratory-0.7/layers/curves_layer.cc delaboratory-0.8/layers/curves_layer.cc --- delaboratory-0.7/layers/curves_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/curves_layer.cc 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,110 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curves_layer.h" +#include +#include + +#include "str.h" + +#include "color_space_utils.h" +#include "channel_manager.h" + +#include "property_curves.h" + +#include "preset.h" + +deCurvesLayer::deCurvesLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + reset->addOperation("reset"); + + int n = getColorSpaceSize(colorSpace); + properties.push_back(new dePropertyCurves("curves", n)); + + applyPreset("reset"); +} + +deCurvesLayer::~deCurvesLayer() +{ +} + +bool deCurvesLayer::updateMainImageSingleChannel(int i) +{ + dePropertyCurves* p = getPropertyCurves(); + if (!p) + { + return false; + } + + bool result = false; + + // render new image + const deBaseCurve* curve = p->getCurve(i); + const deValue* source = getSourceImage().startRead(i); + deValue* destination = mainLayerImage.startWrite(i); + if ((source) && (destination)) + { + curve->process(source, destination, mainLayerImage.getChannelSize().getN()); + result = true; + } + + getSourceImage().finishRead(i); + mainLayerImage.finishWrite(i); + + return result; + +} + +bool deCurvesLayer::isChannelNeutral(int index) +{ + dePropertyCurves* p = getPropertyCurves(); + if (!p) + { + return false; + } + deBaseCurve* curve = p->getCurve(index); + return curve->isNeutral(); +} + +dePropertyCurves* deCurvesLayer::getPropertyCurves() +{ + deProperty* p = getProperty("curves"); + return dynamic_cast(p); +} + +void deCurvesLayer::executeOperation(const std::string& operation) +{ + int n = getColorSpaceSize(colorSpace); + dePropertyCurves* p = getPropertyCurves(); + + int i; + for (i = 0; i < n; i++) + { + deBaseCurve* curve = p->getCurve(i); + + curve->clearPoints(); + + curve->addPoint(0, 0); + curve->addPoint(1, 1); + + curve->build(); + + } +} diff -Nru delaboratory-0.7/layers/curves_layer.h delaboratory-0.8/layers/curves_layer.h --- delaboratory-0.7/layers/curves_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/curves_layer.h 2012-06-16 01:48:25.000000000 +0000 @@ -0,0 +1,50 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVES_LAYER_H +#define _DE_CURVES_LAYER_H + +#include "layer_with_blending.h" +#include "curve.h" + +class dePropertyCurves; + +class deCurvesLayer:public deLayerWithBlending +{ + private: + dePropertyCurves* getPropertyCurves(); + + protected: + virtual std::string getType() const {return "curves";}; + + public: + deCurvesLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager); + virtual ~deCurvesLayer(); + + virtual bool isChannelNeutral(int index); + + virtual bool updateMainImageSingleChannel(int i); + + virtual std::string getActionName() {return "curves";}; + + virtual void executeOperation(const std::string& operation); + + +}; + +#endif diff -Nru delaboratory-0.7/layers/equalizer_layer.cc delaboratory-0.8/layers/equalizer_layer.cc --- delaboratory-0.7/layers/equalizer_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/equalizer_layer.cc 2012-07-09 19:24:11.000000000 +0000 @@ -0,0 +1,164 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "equalizer_layer.h" +#include +#include + +#include "str.h" + +#include "color_space_utils.h" +#include "channel_manager.h" + +#include "property_curves.h" + +#include "preset.h" + +deEqualizerLayer::deEqualizerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + reset->addOperation("reset"); + + createPropertyChoice("channel", getChannelNames(colorSpace)); + getPropertyChoice("channel")->setOthers(); + + if (colorSpace == deColorSpaceLCH) + { + getPropertyChoice("channel")->setIndex(2); + } + + int n = getColorSpaceSize(colorSpace); + properties.push_back(new dePropertyCurves("curves", n)); + + setBlendMode(deBlendOverlay); + + applyPreset("reset"); + + setHorizontalChannel(); +} + +deEqualizerLayer::~deEqualizerLayer() +{ +} + +bool deEqualizerLayer::updateMainImageSingleChannel(int i) +{ + dePropertyCurves* p = getPropertyCurves(); + if (!p) + { + return false; + } + const deBaseCurve* curve = p->getCurve(i); + + int channel = getPropertyChoice("channel")->getIndex(); + + const deValue* sourceEq = NULL; + const deValue* source = getSourceImage().startRead(i); + if (i == channel) + { + sourceEq = source; + } + else + { + sourceEq = getSourceImage().startRead(channel); + } + deValue* destination = mainLayerImage.startWrite(i); + + int n = mainLayerImage.getChannelSize().getN(); + + int j; + for (j = 0; j < n; j++) + { + deValue eq = sourceEq[j]; + deValue v = source[j]; + deValue c = curve->calcValue(eq); + v = c; + if (v < 0) + { + destination[j] = 0; + } + else if (v > 1) + { + destination[j] = 1; + } + else + { + destination[j] = v; + } + + } + + getSourceImage().finishRead(i); + mainLayerImage.finishWrite(i); + if (i != channel) + { + getSourceImage().finishRead(channel); + } + + return true; + +} + +bool deEqualizerLayer::isChannelNeutral(int index) +{ + dePropertyCurves* p = getPropertyCurves(); + if (!p) + { + return false; + } + deBaseCurve* curve = p->getCurve(index); + return curve->isNeutral(); +} + +dePropertyCurves* deEqualizerLayer::getPropertyCurves() +{ + deProperty* p = getProperty("curves"); + return dynamic_cast(p); +} + +void deEqualizerLayer::executeOperation(const std::string& operation) +{ + int n = getColorSpaceSize(colorSpace); + dePropertyCurves* p = getPropertyCurves(); + + int i; + for (i = 0; i < n; i++) + { + deBaseCurve* curve = p->getCurve(i); + + curve->clearPoints(); + + curve->addPoint(0, 0.5); + curve->addPoint(1, 0.5); + + curve->build(); + + } +} + +void deEqualizerLayer::setHorizontalChannel() +{ + int channel = getPropertyChoice("channel")->getIndex(); + getPropertyCurves()->setHorizontalChannel(channel); +} + +void deEqualizerLayer::beforeSetUIFromLayer() +{ + setHorizontalChannel(); +} diff -Nru delaboratory-0.7/layers/equalizer_layer.h delaboratory-0.8/layers/equalizer_layer.h --- delaboratory-0.7/layers/equalizer_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/equalizer_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_EQUALIZER_LAYER_H +#define _DE_EQUALIZER_LAYER_H + +#include "layer_with_blending.h" +#include "curve.h" + +class dePropertyCurves; + +class deEqualizerLayer:public deLayerWithBlending +{ + private: + dePropertyCurves* getPropertyCurves(); + void setHorizontalChannel(); + + protected: + virtual std::string getType() const {return "curves";}; + + public: + deEqualizerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager); + virtual ~deEqualizerLayer(); + + virtual bool isChannelNeutral(int index); + + virtual bool updateMainImageSingleChannel(int i); + + virtual std::string getActionName() {return "curves";}; + + virtual void executeOperation(const std::string& operation); + + virtual void beforeSetUIFromLayer(); + + + +}; + +#endif diff -Nru delaboratory-0.7/layers/exposure_layer.cc delaboratory-0.8/layers/exposure_layer.cc --- delaboratory-0.7/layers/exposure_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/exposure_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,137 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "exposure_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" +#include "str.h" +#include "curve.h" + +deExposureLayer::deExposureLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("exposure", -1, 1); + reset->addNumericValue("exposure", 0.0); + + createPropertyNumeric("brightness", -1, 1); + reset->addNumericValue("brightness", 0.0); + + createPropertyNumeric("shadows", -1, 1); + reset->addNumericValue("shadows", 0.0); + + createPropertyNumeric("lights", -1, 1); + reset->addNumericValue("lights", 0.0); + + createPropertyNumeric("black", 0, 1); + reset->addNumericValue("black", 0.0); + + createPropertyNumeric("highlights", 0, 1); + reset->addNumericValue("highlights", 1.0); + + applyPreset("reset"); + disableNotLuminance(); +} + +deExposureLayer::~deExposureLayer() +{ +} + +bool deExposureLayer::updateMainImageSingleChannel(int channel) +{ +/* + if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + return true; + } + */ + + deValue exposure = getNumericValue("exposure"); + deValue black = getNumericValue("black"); + deValue shadows = getNumericValue("shadows"); + deValue brightness = getNumericValue("brightness"); + deValue lights = getNumericValue("lights"); + deValue highlights = getNumericValue("highlights"); + + deValue x0 = black; + deValue x4 = highlights; + deValue x2 = (x0 + x4) / 2.0; + deValue x1 = (x0 + x2) / 2.0; + deValue x3 = (x2 + x4) / 2.0; + + deValue y0 = exposure + 0.0; + deValue y1 = exposure + 0.25 + shadows/4.0 + brightness; + deValue y2 = exposure + 0.5 + brightness; + deValue y3 = exposure + 0.75 + lights/4.0 + brightness; + deValue y4 = exposure + 1.0; + + const deValue* source = getSourceImage().startRead(channel); + //mainLayerImage.enableChannel(channel); + deValue* target = mainLayerImage.startWrite(channel); + int n = mainLayerImage.getChannelSize().getN(); + + deBaseCurve curve; + + if (colorSpace == deColorSpaceCMYK) + { + if (x4 < 1) + { + curve.addPoint(0, 1 - y4); + } + curve.addPoint(1 - x4, 1 - y4); + curve.addPoint(1 - x3, 1 - y3); + curve.addPoint(1 - x2, 1 - y2); + curve.addPoint(1 - x1, 1 - y1); + curve.addPoint(1 - x0, 1 - y0); + if (x0 > 0) + { + curve.addPoint(1, 1 - y0); + } + } + else + { + if (x0 > 0) + { + curve.addPoint(0, y0); + } + curve.addPoint(x0, y0); + curve.addPoint(x1, y1); + curve.addPoint(x2, y2); + curve.addPoint(x3, y3); + curve.addPoint(x4, y4); + if (x4 < 1) + { + curve.addPoint(1, y4); + } + } + + curve.build(); + + curve.process(source, target, n); + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return true; +} diff -Nru delaboratory-0.7/layers/exposure_layer.h delaboratory-0.8/layers/exposure_layer.h --- delaboratory-0.7/layers/exposure_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/exposure_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_EXPOSURE_LAYER_H +#define _DE_EXPOSURE_LAYER_H + +#include "layer_with_blending.h" + +class deExposureLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "exposure";}; + + public: + deExposureLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deExposureLayer(); + + virtual bool updateMainImageSingleChannel(int i); + + +}; + +#endif diff -Nru delaboratory-0.7/layers/fill_layer.cc delaboratory-0.8/layers/fill_layer.cc --- delaboratory-0.7/layers/fill_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/fill_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,70 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "fill_layer.h" +#include "fill_channel.h" +#include "preset.h" +#include "color_space_utils.h" + +deFillLayer::deFillLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + int n = getColorSpaceSize(colorSpace); + + int i; + for (i = 0; i < n; i++) + { + std::string n = "fill " + getChannelName(colorSpace, i); + createPropertyNumeric(n, 0, 1); + reset->addNumericValue(n, 0.5); + } + + applyPreset("reset"); + setOpacity(0.5); +} + +deFillLayer::~deFillLayer() +{ +} + +bool deFillLayer::updateMainImageSingleChannel(int channel) +{ +/* + if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + return true; + } +*/ +// mainLayerImage.enableChannel(channel); + + std::string p = "fill " + getChannelName(colorSpace, channel); + + deValue value = getNumericValue(p); + deValue* destination = mainLayerImage.startWrite(channel); + int n = mainLayerImage.getChannelSize().getN(); + + fillChannel(destination, n, value); + + mainLayerImage.finishWrite(channel); + + return true; +} + diff -Nru delaboratory-0.7/layers/fill_layer.h delaboratory-0.8/layers/fill_layer.h --- delaboratory-0.7/layers/fill_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/fill_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,40 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_FILL_LAYER_H +#define _DE_FILL_LAYER_H + +#include "layer_with_blending.h" +class deViewManager; + +class deFillLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "fill";}; + + public: + deFillLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deFillLayer(); + + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "fill";}; + +}; + +#endif diff -Nru delaboratory-0.7/layers/gaussian_blur_layer.cc delaboratory-0.8/layers/gaussian_blur_layer.cc --- delaboratory-0.7/layers/gaussian_blur_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gaussian_blur_layer.cc 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,61 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gaussian_blur_layer.h" +#include "blur.h" +#include "preset.h" +#include "view_manager.h" +#include "logger.h" + +deGaussianBlurLayer::deGaussianBlurLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 2, 600); + reset->addNumericValue("radius", 200); + applyPreset("reset"); +} + +deGaussianBlurLayer::~deGaussianBlurLayer() +{ +} + +bool deGaussianBlurLayer::updateMainImageSingleChannel(int channel) +{ + logInfo("blur start"); + + deValue r = getNumericValue("radius") * viewManager.getRealScale();; + + deSize size = mainLayerImage.getChannelSize(); + + const deValue* source = getSourceImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(channel); + + bool result = false; + deBlurType type = deGaussianBlur; + + result = blurChannel(source, destination, size, r, r, type, 0.0); + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + logInfo("blur DONE"); + + return result; +} + diff -Nru delaboratory-0.7/layers/gaussian_blur_layer.h delaboratory-0.8/layers/gaussian_blur_layer.h --- delaboratory-0.7/layers/gaussian_blur_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gaussian_blur_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,40 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GAUSSIAN_BLUR_LAYER_H +#define _DE_GAUSSIAN_BLUR_LAYER_H + +#include "layer_with_blending.h" + +class deGaussianBlurLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "gaussian_blur";}; + deViewManager& viewManager; + + public: + deGaussianBlurLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deGaussianBlurLayer(); + + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "gaussian blur";}; + +}; + +#endif diff -Nru delaboratory-0.7/layers/gaussian_blur_single_layer.cc delaboratory-0.8/layers/gaussian_blur_single_layer.cc --- delaboratory-0.7/layers/gaussian_blur_single_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gaussian_blur_single_layer.cc 2012-07-03 22:57:08.000000000 +0000 @@ -0,0 +1,75 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gaussian_blur_single_layer.h" +#include "blur.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" + +deGaussianBlurSingleLayer::deGaussianBlurSingleLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 2, 600); + reset->addNumericValue("radius", 200); + + createPropertyChoice("channel", getChannelNames(colorSpace)); + + applyPreset("reset"); +} + +deGaussianBlurSingleLayer::~deGaussianBlurSingleLayer() +{ +} +bool deGaussianBlurSingleLayer::updateMainImageNotThreadedWay() +{ + deSize size = mainLayerImage.getChannelSize(); + int n = size.getN(); + + int nc = getColorSpaceSize(colorSpace); + + deBlurType type = deGaussianBlur; + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + + int channel = getPropertyChoice("channel")->getIndex(); + + const deValue* source = getSourceImage().startRead(channel); + + int i; + + deValue* destination = mainLayerImage.startWrite(0); + + blurChannel(source, destination, size, r, r, type, 0.0); + + getSourceImage().finishRead(channel); + + for (i = 1; i < nc; i++) + { + deValue* dd = mainLayerImage.startWrite(i); + copyChannel(destination, dd, n); + mainLayerImage.finishWrite(i); + } + + mainLayerImage.finishWrite(0); + + + return true; +} + diff -Nru delaboratory-0.7/layers/gaussian_blur_single_layer.h delaboratory-0.8/layers/gaussian_blur_single_layer.h --- delaboratory-0.7/layers/gaussian_blur_single_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gaussian_blur_single_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,39 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GAUSSIAN_BLUR_SINGLE_LAYER_H +#define _DE_GAUSSIAN_BLUR_SINGLE_LAYER_H + +#include "layer_with_blending.h" + +class deGaussianBlurSingleLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "gaussian_blur_single";}; + deViewManager& viewManager; + + + public: + deGaussianBlurSingleLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deGaussianBlurSingleLayer(); + + virtual bool updateMainImageNotThreadedWay(); + +}; + +#endif diff -Nru delaboratory-0.7/layers/gradient_layer.cc delaboratory-0.8/layers/gradient_layer.cc --- delaboratory-0.7/layers/gradient_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gradient_layer.cc 2012-07-01 13:24:19.000000000 +0000 @@ -0,0 +1,102 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gradient_layer.h" +#include "gradient.h" +#include "preset.h" +#include "view_manager.h" +#include "property_numeric.h" + +deGradientLayer::deGradientLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + if (colorSpace == deColorSpaceCMYK) + { + setBlendMode(deBlendScreen); + } + else + { + setBlendMode(deBlendMultiply); + } + + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("length", -3.0, 3.0); + reset->addNumericValue("length", 1.0); + + createPropertyNumeric("direction", 0, 360); + reset->addNumericValue("direction", 0.0); + + createPropertyNumeric("center_x", -1, 1); + reset->addNumericValue("center_x", 0.0); + createPropertyNumeric("center_y", -1, 1); + reset->addNumericValue("center_y", 0.0); + + createPropertyNumeric("sinus", -1, 1); + reset->addNumericValue("sinus", 0.0); + + applyPreset("reset"); + disableNotLuminance(); +} + +deGradientLayer::~deGradientLayer() +{ +} + +bool deGradientLayer::isChannelNeutral(int channel) +{ + return false; +} + +bool deGradientLayer::updateMainImageSingleChannel(int channel) +{ + deSize size = mainLayerImage.getChannelSize(); + + deValue* destination = mainLayerImage.startWrite(channel); + + deValue x1; + deValue y1; + deValue x2; + deValue y2; + + viewManager.getZoom(x1, y1, x2, y2); + + deValue r = getNumericValue("length"); + deValue a = getNumericValue("direction"); + + deValue cx = getNumericValue("center_x"); + deValue cy = getNumericValue("center_y"); + + deValue sinus = getNumericValue("sinus"); + + gradientChannel(destination, size, cx, cy, r, a, sinus); + + mainLayerImage.finishWrite(channel); + + return true; +} + +bool deGradientLayer::onImageClick(deValue x, deValue y) +{ + dePropertyNumeric* cx = getPropertyNumeric("center_x"); + cx->set(2 * x - 1); + dePropertyNumeric* cy = getPropertyNumeric("center_y"); + cy->set(2 * y - 1); + + return true; +} diff -Nru delaboratory-0.7/layers/gradient_layer.h delaboratory-0.8/layers/gradient_layer.h --- delaboratory-0.7/layers/gradient_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/gradient_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_GRADIENT_LAYER_H +#define _DE_GRADIENT_LAYER_H + +#include "layer_with_blending.h" +class deViewManager; + +class deGradientLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "gradient";}; + deViewManager& viewManager; + + public: + deGradientLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deGradientLayer(); + + virtual bool isChannelNeutral(int index); + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "gradient";}; + + virtual bool onImageClick(deValue x, deValue y); + +}; + +#endif diff -Nru delaboratory-0.7/layers/high_pass_layer.cc delaboratory-0.8/layers/high_pass_layer.cc --- delaboratory-0.7/layers/high_pass_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/high_pass_layer.cc 2012-06-13 02:25:26.000000000 +0000 @@ -0,0 +1,159 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "high_pass_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "fill_channel.h" +#include "color_space_utils.h" +#include "blur.h" +#include "blend_channel.h" +#include "logger.h" + +deHighPassLayer::deHighPassLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("radius", 1, 20); + reset->addNumericValue("radius", 4); + + createPropertyNumeric("power", 1.0, 20.0); + reset->addNumericValue("power", 1.0); + + applyPreset("reset"); + +} + +deHighPassLayer::~deHighPassLayer() +{ +} + +bool deHighPassLayer::isChannelNeutral(int channel) +{ + return false; +} + +bool deHighPassLayer::updateMainImageNotThreadedWay() +{ + deSize size = mainLayerImage.getChannelSize(); + int n = size.getN(); + + deValue* mask = NULL; + try + { + mask = new deValue [n]; + } + catch (std::bad_alloc) + { + logError("allocating memory in USM"); + if (mask) + { + delete [] mask; + } + return false; + } + + int channel; + + int nc = getColorSpaceSize(colorSpace); + int no = 3; // assume original image has 3 channels + + // clear destination + fillChannel(mask, n, 0.0); + + deValue t = 0.0; + deBlurType type = deGaussianBlur; + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + + int i; + /* + for (channel = 0; channel < nc; channel++) + { + mainLayerImage.enableChannel(channel); + } + */ + + // calc high pass + for (channel = 0; channel < no; channel++) + { + const deValue* source = getOriginalImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(0); // use 0 channel for blur + blurChannel(source, destination, size, r, r, type, t); + for (i = 0; i < n; i++) + { + deValue d = source[i] - destination[i]; + mask[i] += d; + } + getOriginalImage().finishRead(channel); + mainLayerImage.finishWrite(0); + } + + deValue p = getNumericValue("power"); + + for (i = 0; i < n; i++) + { + deValue d = mask[i]; + + d = 0.5 + p * d; + + if (d < 0) + { + d = 0; + } + else if (d > 1) + { + d = 1; + } + + mask[i] = d; + } + + for (channel = 0; channel < nc; channel++) + { + /* + if (!isChannelEnabled(channel)) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + } + else + */ + { + deValue* destination = mainLayerImage.startWrite(channel); + int i; + for (i = 0; i < n; i++) + { + destination[i] = mask[i]; + } + mainLayerImage.finishWrite(channel); + } + } + + delete [] mask; + + return true; +} + +void deHighPassLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const +{ + deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); + + getOriginalImage().updateChannelUsage(channelUsage, layerIndex); +} + diff -Nru delaboratory-0.7/layers/high_pass_layer.h delaboratory-0.8/layers/high_pass_layer.h --- delaboratory-0.7/layers/high_pass_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/high_pass_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_HIGH_PASS_LAYER_H +#define _DE_HIGH_PASS_LAYER_H + +#include "layer_with_blending.h" + +class deHighPassLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "high_pass";}; + deViewManager& viewManager; + + virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; + + public: + deHighPassLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deHighPassLayer(); + + virtual bool isChannelNeutral(int index); + virtual bool updateMainImageNotThreadedWay(); + + virtual std::string getActionName() {return "high pass";}; + +}; + +#endif diff -Nru delaboratory-0.7/layers/levels_layer.cc delaboratory-0.8/layers/levels_layer.cc --- delaboratory-0.7/layers/levels_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/levels_layer.cc 2012-07-15 06:13:09.000000000 +0000 @@ -0,0 +1,175 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "levels_layer.h" +#include "copy_channel.h" +#include "color_space_utils.h" +#include "property_levels.h" +#include "curve.h" +#include "preset.h" +#include "histogram.h" +#include "logger.h" +#include "str.h" + +deLevelsLayer::deLevelsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + reset->addOperation("reset"); + + dePreset* autoLevels = createPreset("auto levels"); + autoLevels->addOperation("auto levels"); + + dePreset* autoLevelsLight = createPreset("auto levels light"); + autoLevelsLight->addOperation("auto levels light"); + + dePreset* autoLevelsHeavy = createPreset("auto levels heavy"); + autoLevelsHeavy->addOperation("auto levels heavy"); + + int n = getColorSpaceSize(colorSpace); + + properties.push_back(new dePropertyLevels("levels", n)); + +} + +deLevelsLayer::~deLevelsLayer() +{ +} + +bool deLevelsLayer::isChannelNeutral(int channel) +{ + dePropertyLevels* propertyLevels = getPropertyLevels(); + if (!propertyLevels) + { + return true; + } + + const deLevels& levels = propertyLevels->getLevels(channel); + return levels.isNeutral(); + +} + +bool deLevelsLayer::updateMainImageSingleChannel(int channel) +{ + logInfo("processing levels channel " + str(channel)); + + dePropertyLevels* propertyLevels = getPropertyLevels(); + if (!propertyLevels) + { + return false; + } + + const deLevels& levels = propertyLevels->getLevels(channel); + + const deValue* source = getSourceImage().startRead(channel); + deValue* target = mainLayerImage.startWrite(channel); + int n = mainLayerImage.getChannelSize().getN(); + + deBaseCurve curve; + + curve.addPoint(0, 0); + curve.addPoint(levels.getMin(), 0); + curve.addPoint(levels.getMiddle(), 0.5); + curve.addPoint(levels.getMax(), 1); + curve.addPoint(1, 1); + + curve.build(); + + logInfo("levels curve build min: " + str(levels.getMin()) + " middle: " + str(levels.getMiddle()) + " max: " + str(levels.getMax())); + curve.process(source, target, n); + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return true; +} + +dePropertyLevels* deLevelsLayer::getPropertyLevels() +{ + deProperty* p = getProperty("levels"); + return dynamic_cast(p); +} + +void deLevelsLayer::executeOperation(const std::string& operation) +{ + logInfo("levels layer operation: " + operation); + + int n = getColorSpaceSize(colorSpace); + + dePropertyLevels* propertyLevels = getPropertyLevels(); + if (!propertyLevels) + { + return; + } + + int i; + for (i = 0; i < n; i++) + { + deLevels& levels = propertyLevels->getLevels(i); + + deValue min = 0.0; + deValue middle = 0.5; + deValue max = 1.0; + + if (operation == "auto levels") + { + calcAutoLevels(i, min, middle, max, 0.0005, 0.4); + } + + if (operation == "auto levels light") + { + calcAutoLevels(i, min, middle, max, 0.005, 0.4); + } + + if (operation == "auto levels heavy") + { + calcAutoLevels(i, min, middle, max, 0.02, 0.4); + } + + levels.setMin(min); + levels.setMiddle(middle); + levels.setMax(max); + + logInfo("set levels min: " + str(min) + " middle: " + str(middle) + " max: " + str(max)); + + if (!shouldUseAutoLevels(colorSpace, i)) + { + disableChannel(i); + logInfo("levels - disabling channel " + str(i)); + } + } + + setOpacity(0.7); + +} + +void deLevelsLayer::calcAutoLevels(int channel, deValue& min, deValue& middle, deValue& max, deValue margin1, deValue margin2) +{ + const deValue* c = getSourceImage().startRead(channel); + int n = getSourceImage().getChannelSize().getN(); + + int s = 1024; + deHistogram histogram(s); + + histogram.clear(); + histogram.calc(c, n); + + getSourceImage().finishRead(channel); + + histogram.calcLevels(margin1, margin2, min, middle, max); +} diff -Nru delaboratory-0.7/layers/levels_layer.h delaboratory-0.8/layers/levels_layer.h --- delaboratory-0.7/layers/levels_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/levels_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,51 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LEVELS_LAYER_H +#define _DE_LEVELS_LAYER_H + +#include "layer_with_blending.h" +class dePropertyLevels; + +class deLevelsLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "levels";}; + + void createPropertyLevels(int channel); + + void calcAutoLevels(int channel, deValue& min, deValue& middle, deValue& max, deValue margin1, deValue margin2); + + public: + deLevelsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deLevelsLayer(); + + virtual bool isChannelNeutral(int index); + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "levels";}; + + dePropertyLevels* getPropertyLevels(); + + virtual void executeOperation(const std::string& o); + + + +}; + +#endif diff -Nru delaboratory-0.7/layers/local_contrast_layer.cc delaboratory-0.8/layers/local_contrast_layer.cc --- delaboratory-0.7/layers/local_contrast_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/local_contrast_layer.cc 2012-07-03 22:57:08.000000000 +0000 @@ -0,0 +1,68 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "local_contrast_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" + +deLocalContrastLayer::deLocalContrastLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 10, 600); + reset->addNumericValue("radius", 200); + applyPreset("reset"); + setOpacity(0.2); + disableNotForSharpen(); +} + +deLocalContrastLayer::~deLocalContrastLayer() +{ +} + +bool deLocalContrastLayer::updateMainImageSingleChannel(int channel) +{ + if (!isChannelEnabled(channel)) + { + copySourceChannel(channel); + return true; + } + + deValue r = getNumericValue("radius") * viewManager.getRealScale();; + deValue a = 0.5; + deValue t = 0.0; + + deSize size = mainLayerImage.getChannelSize(); + + const deValue* source = getSourceImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(channel); + + bool result = false; + + if ((source) && (destination)) + { + result = unsharpMask(source, destination, size, a, r, t, deBoxBlur); + } + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return result; +} + diff -Nru delaboratory-0.7/layers/local_contrast_layer.h delaboratory-0.8/layers/local_contrast_layer.h --- delaboratory-0.7/layers/local_contrast_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/local_contrast_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,39 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_LOCAL_CONTRAST_LAYER_H +#define _DE_LOCAL_CONTRAST_LAYER_H + +#include "layer_with_blending.h" + +class deLocalContrastLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "local_contrast";}; + deViewManager& viewManager; + + public: + deLocalContrastLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deLocalContrastLayer(); + + virtual bool updateMainImageSingleChannel(int channel); + + +}; + +#endif diff -Nru delaboratory-0.7/layers/mixer_layer.cc delaboratory-0.8/layers/mixer_layer.cc --- delaboratory-0.7/layers/mixer_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/mixer_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,136 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "mixer_layer.h" +//#include "project.h" +#include +#include "color_space_utils.h" +#include "channel_manager.h" +#include "property_mixer.h" +#include "preset.h" +#include "logger.h" + +deMixerLayer::deMixerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + reset->addOperation("reset"); + + int n = getColorSpaceSize(colorSpace); + + properties.push_back(new dePropertyMixer("mixer", n)); + + applyPreset("reset"); + +} + +deMixerLayer::~deMixerLayer() +{ +} + +bool deMixerLayer::updateMainImageSingleChannel(int channel) +{ +/* + if (!isChannelEnabled(channel)) + { + mainLayerImage.disableChannel(channel, getSourceImage().getChannelIndex(channel)); + return true; + } + */ + + const deImage& sourceImage = getSourceImage(); + + //mainLayerImage.enableChannel(channel); + + //int c = mainLayerImage.getChannelIndex(channel); + + dePropertyMixer* p = dynamic_cast(getProperty("mixer")); + if (!p) + { + logError("no property mixer"); + return false; + } + + int channelSize = mainLayerImage.getChannelSize().getN(); + deValue* destination = mainLayerImage.startWrite(channel); + p->getMixer(channel)->process(sourceImage, destination, channelSize); + mainLayerImage.finishWrite(channel); + + return true; +} + + +deMixer* deMixerLayer::getMixer(int index) +{ + dePropertyMixer* p = dynamic_cast(getProperty("mixer")); + if (!p) + { + return NULL; + } + return p->getMixer(index); +} + +bool deMixerLayer::isChannelNeutral(int index) +{ + dePropertyMixer* p = dynamic_cast(getProperty("mixer")); + if (!p) + { + return false; + } + return p->getMixer(index)->isNeutral(index); +} + +void deMixerLayer::setWeight(int s, int d, deValue value) +{ + dePropertyMixer* p = dynamic_cast(getProperty("mixer")); + if (!p) + { + return; + } + p->getMixer(d)->setWeight(s, value); +} + +deValue deMixerLayer::getWeight(int s, int d) +{ + dePropertyMixer* p = dynamic_cast(getProperty("mixer")); + if (!p) + { + return -1; + } + return p->getMixer(d)->getWeight(s); +} + +void deMixerLayer::executeOperation(const std::string& operation) +{ + int n = getColorSpaceSize(colorSpace); + + int i; + for (i = 0; i < n; i++) + { + int j; + for (j = 0; j < n; j++) + { + deValue v = 0.0; + if (i == j) + { + v = 1.0; + } + setWeight(i, j, v); + } + } +} diff -Nru delaboratory-0.7/layers/mixer_layer.h delaboratory-0.8/layers/mixer_layer.h --- delaboratory-0.7/layers/mixer_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/mixer_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,53 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MIXER_LAYER_H +#define _DE_MIXER_LAYER_H + +#include "layer_with_blending.h" +#include "mixer.h" + +class deMixerLayer:public deLayerWithBlending +{ + protected: + virtual std::string getType() const {return "mixer";}; + virtual std::string getLabel() const {return "channel mixer";}; + + public: + deMixerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager); + virtual ~deMixerLayer(); + + deMixer* getMixer(int index); + + virtual bool isChannelNeutral(int index); + + void setWeight(int s, int d, deValue value); + deValue getWeight(int s, int d); + + virtual std::string getActionName() {return "mixer";}; + + virtual bool updateMainImageSingleChannel(int i); + + virtual void executeOperation(const std::string& operation); + + + + +}; + +#endif diff -Nru delaboratory-0.7/layers/recover_highlights_layer.cc delaboratory-0.8/layers/recover_highlights_layer.cc --- delaboratory-0.7/layers/recover_highlights_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/recover_highlights_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "recover_highlights_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" + +deRecoverHighlightsLayer::deRecoverHighlightsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 2, 600); + reset->addNumericValue("radius", 200); + + createPropertyChoice("channel", getChannelNames(colorSpace)); + + applyPreset("reset"); + setOpacity(0.5); +} + +deRecoverHighlightsLayer::~deRecoverHighlightsLayer() +{ +} + +bool deRecoverHighlightsLayer::updateMainImageNotThreadedWay() +{ + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + + int channel = getPropertyChoice("channel")->getIndex(); + + bool result = shadowsHighlights(r, channel, getSourceImage(), mainLayerImage, false); + + return result; +} + diff -Nru delaboratory-0.7/layers/recover_highlights_layer.h delaboratory-0.8/layers/recover_highlights_layer.h --- delaboratory-0.7/layers/recover_highlights_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/recover_highlights_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RECOVER_HIGHLIGHTS_LAYER_H +#define _DE_RECOVER_HIGHLIGHTS_LAYER_H + +#include "layer_with_blending.h" + +class deRecoverHighlightsLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "recover_highlights";}; + deViewManager& viewManager; + + public: + deRecoverHighlightsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deRecoverHighlightsLayer(); + + virtual bool updateMainImageNotThreadedWay(); + +}; + +#endif diff -Nru delaboratory-0.7/layers/recover_shadows_layer.cc delaboratory-0.8/layers/recover_shadows_layer.cc --- delaboratory-0.7/layers/recover_shadows_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/recover_shadows_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "recover_shadows_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" + +deRecoverShadowsLayer::deRecoverShadowsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 2, 600); + reset->addNumericValue("radius", 200); + + createPropertyChoice("channel", getChannelNames(colorSpace)); + + applyPreset("reset"); + setOpacity(0.5); +} + +deRecoverShadowsLayer::~deRecoverShadowsLayer() +{ +} + +bool deRecoverShadowsLayer::updateMainImageNotThreadedWay() +{ + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + + int channel = getPropertyChoice("channel")->getIndex(); + + bool result = shadowsHighlights(r, channel, getSourceImage(), mainLayerImage, true); + + return result; +} + diff -Nru delaboratory-0.7/layers/recover_shadows_layer.h delaboratory-0.8/layers/recover_shadows_layer.h --- delaboratory-0.7/layers/recover_shadows_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/recover_shadows_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_RECOVER_SHADOWS_LAYER_H +#define _DE_RECOVER_SHADOWS_LAYER_H + +#include "layer_with_blending.h" + +class deRecoverShadowsLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "recover_shadows";}; + deViewManager& viewManager; + + public: + deRecoverShadowsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deRecoverShadowsLayer(); + + virtual bool updateMainImageNotThreadedWay(); + +}; + +#endif diff -Nru delaboratory-0.7/layers/saturation_layer.cc delaboratory-0.8/layers/saturation_layer.cc --- delaboratory-0.7/layers/saturation_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/saturation_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,111 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "saturation_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" +#include "str.h" +#include "curve.h" + +deSaturationLayer::deSaturationLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("saturation", -1, 1); + reset->addNumericValue("saturation", 0.0); + + createPropertyNumeric("green / magenta", -1, 1); + reset->addNumericValue("green / magenta", 0.0); + + createPropertyNumeric("blue / yellow", -1, 1); + reset->addNumericValue("blue / yellow", 0.0); + + applyPreset("reset"); + if (colorSpace != deColorSpaceLAB) + { + disableAll(); + } + else + { + disableChannel(0); + } +} + +deSaturationLayer::~deSaturationLayer() +{ +} + +bool deSaturationLayer::updateMainImageSingleChannel(int channel) +{ + deValue s = getNumericValue("saturation"); + deValue s2 = 0.0; + if (channel == 1) + { + s2 = getNumericValue("green / magenta"); + } + if (channel == 2) + { + s2 = getNumericValue("blue / yellow"); + } + + s = s + s2; + + const deValue* source = getSourceImage().startRead(channel); + deValue* target = mainLayerImage.startWrite(channel); + int n = mainLayerImage.getChannelSize().getN(); + + deBaseCurve curve; + + if (s > 0) + { + if (s > 1) + { + s = 1.0; + } + s = 0.99 * s; + curve.addPoint(0, 0); + curve.addPoint(s / 2.0, 0); + curve.addPoint(0.5, 0.5); + curve.addPoint(1 - s/2.0, 1); + curve.addPoint(1, 1); + } + else + { + if (s < -1) + { + s = -1; + } + s = -s; + curve.addPoint(0, s / 2.0); + curve.addPoint(0.5, 0.5); + curve.addPoint(1, 1 - s / 2.0); + } + + curve.build(); + + curve.process(source, target, n); + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return true; +} diff -Nru delaboratory-0.7/layers/saturation_layer.h delaboratory-0.8/layers/saturation_layer.h --- delaboratory-0.7/layers/saturation_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/saturation_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,37 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SATURATION_LAYER_H +#define _DE_SATURATION_LAYER_H + +#include "layer_with_blending.h" + +class deSaturationLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "saturation";}; + + public: + deSaturationLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deSaturationLayer(); + + virtual bool updateMainImageSingleChannel(int i); + +}; + +#endif diff -Nru delaboratory-0.7/layers/sharpen_layer.cc delaboratory-0.8/layers/sharpen_layer.cc --- delaboratory-0.7/layers/sharpen_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/sharpen_layer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,79 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sharpen_layer.h" +#include "usm.h" +#include "preset.h" +#include "view_manager.h" + +deSharpenLayer::deSharpenLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + dePreset* reset = createPreset("reset"); + createPropertyNumeric("radius", 1, 20); + reset->addNumericValue("radius", 4); + createPropertyNumeric("threshold", 0.0, 0.03); + reset->addNumericValue("threshold", 0.0); + applyPreset("reset"); + setOpacity(0.1); + disableNotForSharpen(); +} + +deSharpenLayer::~deSharpenLayer() +{ +} + +bool deSharpenLayer::isChannelNeutral(int channel) +{ + return false; +} + +bool deSharpenLayer::updateMainImageSingleChannel(int channel) +{ +/* + if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) + { + int s = getSourceImage().getChannelIndex(channel); + mainLayerImage.disableChannel(channel, s); + return true; + } + */ + + deValue r = getNumericValue("radius") * viewManager.getRealScale(); + deValue a = 50.0; + deValue t = getNumericValue("threshold"); + + deSize size = mainLayerImage.getChannelSize(); + +// mainLayerImage.enableChannel(channel); + const deValue* source = getSourceImage().startRead(channel); + deValue* destination = mainLayerImage.startWrite(channel); + + bool result = false; + + if ((source) && (destination)) + { + result = unsharpMask(source, destination, size, a, r, t, deGaussianBlur); + } + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return result; +} + diff -Nru delaboratory-0.7/layers/sharpen_layer.h delaboratory-0.8/layers/sharpen_layer.h --- delaboratory-0.7/layers/sharpen_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/sharpen_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,41 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SHARPEN_LAYER_H +#define _DE_SHARPEN_LAYER_H + +#include "layer_with_blending.h" + +class deSharpenLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "sharpen";}; + deViewManager& viewManager; + + public: + deSharpenLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deSharpenLayer(); + + virtual bool isChannelNeutral(int index); + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "sharpen";}; + +}; + +#endif diff -Nru delaboratory-0.7/layers/source_image_layer.cc delaboratory-0.8/layers/source_image_layer.cc --- delaboratory-0.7/layers/source_image_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/source_image_layer.cc 2012-07-26 00:53:58.000000000 +0000 @@ -0,0 +1,110 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "source_image_layer.h" +#include "channel_manager.h" +#include +#include "view_manager.h" +#include "logger.h" +#include "static_image.h" +#include "str.h" +#include "property_boolean.h" +#include "property_choice.h" +#include "property_numeric.h" + +deSourceImageLayer::deSourceImageLayer(deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace) +:deBaseLayerWithProperties(_colorSpace, _previewChannelManager) , +viewManager(_viewManager), +sourceImage(_sourceImage) +{ + std::vector r; + r.push_back("0"); + r.push_back("90"); + r.push_back("180"); + r.push_back("270"); + createPropertyChoice("rotate", r); + createPropertyBoolean("horizontal mirror"); + createPropertyBoolean("vertical mirror"); + getPropertyChoice("rotate")->setSize(); + + createPropertyNumeric("contrast", 0, 1.0); + if (colorSpace == deColorSpaceProPhoto) + { + getPropertyNumeric("contrast")->set(0.9); + } + else + { + getPropertyNumeric("contrast")->set(1.0); + } +} + +deSourceImageLayer::~deSourceImageLayer() +{ +} + +bool deSourceImageLayer::updateMainImageNotThreadedWay() +{ + const deSize ds = mainLayerImage.getChannelSize(); + if (ds.getW() == 0) + { + return false; + } + + deValue z_x1; + deValue z_y1; + deValue z_x2; + deValue z_y2; + viewManager.getZoom(z_x1, z_y1, z_x2, z_y2); + + bool mirrorX = getPropertyBoolean("horizontal mirror")->get(); + bool mirrorY = getPropertyBoolean("vertical mirror")->get(); + deValue contrast = getNumericValue("contrast"); + int rotate = getInt(getPropertyChoice("rotate")->get()); + + int channel; + for (channel = 0; channel < 3; channel++) + { + deValue* destination = mainLayerImage.startWrite(channel); + + if (destination) + { + sourceImage.copyToChannel(channel, destination, z_x1, z_y1, z_x2, z_y2, ds, mirrorX, mirrorY, rotate, contrast); + } + + mainLayerImage.finishWrite(channel); + } + + return true; +} + +deValue deSourceImageLayer::getAspect() const +{ + deValue aspect = sourceImage.getAspect(); + + if (aspect == 0) + { + return 0; + } + + int rotate = getInt(getPropertyChoice("rotate")->get()); + if ((rotate == 90) || (rotate == 270)) + { + aspect = 1.0 / aspect; + } + return aspect; +} diff -Nru delaboratory-0.7/layers/source_image_layer.h delaboratory-0.8/layers/source_image_layer.h --- delaboratory-0.7/layers/source_image_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/source_image_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_SOURCE_IMAGE_LAYER_H +#define _DE_SOURCE_IMAGE_LAYER_H + +class deProject; +#include "image.h" +class deChannelManager; +class deViewManager; +class deStaticImage; +#include "base_layer_with_properties.h" + +class deSourceImageLayer:public deBaseLayerWithProperties +{ + private: + deViewManager& viewManager; + deStaticImage& sourceImage; + + virtual std::string getType() const {return "original";}; + + virtual bool updateMainImageNotThreadedWay(); + + public: + deSourceImageLayer(deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace); + virtual ~deSourceImageLayer(); + + virtual bool updateMainImageSingleChannel(int channel) {return false;}; + + deValue getAspect() const; + +}; + +#endif diff -Nru delaboratory-0.7/layers/tone_layer.cc delaboratory-0.8/layers/tone_layer.cc --- delaboratory-0.7/layers/tone_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/tone_layer.cc 2012-06-24 01:28:48.000000000 +0000 @@ -0,0 +1,112 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "tone_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" +#include "str.h" +#include "curve.h" +#include "property_boolean.h" + +deToneLayer::deToneLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + + createPropertyChoice("channel", getChannelNames(colorSpace)); + + int n = getColorSpaceSize(colorSpace); + + int i; + for (i = 0; i < n; i++) + { + std::string nd = "dark " + getChannelName(colorSpace, i); + createPropertyNumeric(nd, 0, 1); + reset->addNumericValue(nd, 0.0); + } + + for (i = 0; i < n; i++) + { + std::string nl = "half " + getChannelName(colorSpace, i); + createPropertyNumeric(nl, 0, 1); + reset->addNumericValue(nl, 0.5); + } + + for (i = 0; i < n; i++) + { + std::string nl = "light " + getChannelName(colorSpace, i); + createPropertyNumeric(nl, 0, 1); + reset->addNumericValue(nl, 1.0); + } + + applyPreset("reset"); +} + +deToneLayer::~deToneLayer() +{ +} +bool deToneLayer::updateMainImageNotThreadedWay() +{ + deSize size = mainLayerImage.getChannelSize(); + int n = size.getN(); + + int nc = getColorSpaceSize(colorSpace); + + int c = getPropertyChoice("channel")->getIndex(); + + const deValue* source = getSourceImage().startRead(c); + + if (!source) + { + logError("broken source in tone layer"); + return false; + } + + int channel; + for (channel = 0; channel < nc; channel++) + { + std::string nd = "dark " + getChannelName(colorSpace, channel); + std::string nh = "half " + getChannelName(colorSpace, channel); + std::string nl = "light " + getChannelName(colorSpace, channel); + deValue dark = getNumericValue(nd); + deValue light = getNumericValue(nl); + deValue half = getNumericValue(nh); + + deValue* destination = mainLayerImage.startWrite(channel); + + deBaseCurve curve; + + curve.addPoint(0, dark); + curve.addPoint(0.5, half); + curve.addPoint(1, light); + + curve.build(); + + curve.process(source, destination, n); + + mainLayerImage.finishWrite(channel); + } + + getSourceImage().finishRead(c); + + return true; +} + diff -Nru delaboratory-0.7/layers/tone_layer.h delaboratory-0.8/layers/tone_layer.h --- delaboratory-0.7/layers/tone_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/tone_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,39 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_TONE_LAYER_H +#define _DE_TONE_LAYER_H + +#include "layer_with_blending.h" + +class deToneLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "tone";}; + + public: + deToneLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deToneLayer(); + + virtual bool updateMainImageNotThreadedWay(); + + virtual std::string getActionName() {return "tone";}; + +}; + +#endif diff -Nru delaboratory-0.7/layers/vignette_layer.cc delaboratory-0.8/layers/vignette_layer.cc --- delaboratory-0.7/layers/vignette_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/vignette_layer.cc 2012-07-03 22:57:08.000000000 +0000 @@ -0,0 +1,119 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "vignette_layer.h" +#include "vignette.h" +#include "preset.h" +#include "view_manager.h" +#include "property_numeric.h" + +deVignetteLayer::deVignetteLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) +{ + if (colorSpace == deColorSpaceCMYK) + { + setBlendMode(deBlendScreen); + } + else + { + setBlendMode(deBlendMultiply); + } + + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("radius", 0.3, 3.0); + reset->addNumericValue("radius", 1.5); + + createPropertyNumeric("aspect", -0.9, 0.9); + reset->addNumericValue("aspect", 0.0); + + createPropertyNumeric("center_x", -1, 1); + reset->addNumericValue("center_x", 0.0); + createPropertyNumeric("center_y", -1, 1); + reset->addNumericValue("center_y", 0.0); + + applyPreset("reset"); + disableNotLuminance(); +} + +deVignetteLayer::~deVignetteLayer() +{ +} + +bool deVignetteLayer::isChannelNeutral(int channel) +{ + return false; +} + +bool deVignetteLayer::updateMainImageSingleChannel(int channel) +{ + if (!isChannelEnabled(channel)) + { + copySourceChannel(channel); + return true; + } + + deSize size = mainLayerImage.getChannelSize(); + + deValue* destination = mainLayerImage.startWrite(channel); + + deValue light = 1.0; + deValue darkness = 0.0; + deValue spot = 0.5; + + deValue x1; + deValue y1; + deValue x2; + deValue y2; + + viewManager.getZoom(x1, y1, x2, y2); + + deValue r = getNumericValue("radius"); + deValue a = getNumericValue("aspect"); + + deValue rx = r; + if (a < 0.0) + { + rx *= (a + 1); + } + deValue ry = r; + if (a > 0.0) + { + ry *= (1 - a); + } + deValue cx = getNumericValue("center_x"); + deValue cy = getNumericValue("center_y"); + + deEllipse ellipse = calcEllipse(rx, ry, cx, cy, x1, y1, x2, y2); + + vignetteChannel(destination, size, ellipse, light, darkness, spot); + + mainLayerImage.finishWrite(channel); + + return true; +} + +bool deVignetteLayer::onImageClick(deValue x, deValue y) +{ + dePropertyNumeric* cx = getPropertyNumeric("center_x"); + cx->set(2 * x - 1); + dePropertyNumeric* cy = getPropertyNumeric("center_y"); + cy->set(2 * y - 1); + + return true; +} diff -Nru delaboratory-0.7/layers/vignette_layer.h delaboratory-0.8/layers/vignette_layer.h --- delaboratory-0.7/layers/vignette_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/vignette_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_VIGNETTE_LAYER_H +#define _DE_VIGNETTE_LAYER_H + +#include "layer_with_blending.h" +class deViewManager; + +class deVignetteLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "vignette";}; + deViewManager& viewManager; + + public: + deVignetteLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); + virtual ~deVignetteLayer(); + + virtual bool isChannelNeutral(int index); + virtual bool updateMainImageSingleChannel(int channel); + + virtual std::string getActionName() {return "vignette";}; + + virtual bool onImageClick(deValue x, deValue y); + +}; + +#endif diff -Nru delaboratory-0.7/layers/white_balance_layer.cc delaboratory-0.8/layers/white_balance_layer.cc --- delaboratory-0.7/layers/white_balance_layer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/white_balance_layer.cc 2012-07-09 17:34:43.000000000 +0000 @@ -0,0 +1,138 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "white_balance_layer.h" +#include "preset.h" +#include "view_manager.h" +#include "color_space_utils.h" +#include "copy_channel.h" +#include "logger.h" +#include "str.h" +#include "curve.h" +#include "property_numeric.h" + +deWhiteBalanceLayer::deWhiteBalanceLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) +:deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) +{ + dePreset* reset = createPreset("reset"); + + createPropertyNumeric("green / magenta", -1, 1); + reset->addNumericValue("green / magenta", 0.0); + + createPropertyNumeric("g / m finetune", -1, 1); + reset->addNumericValue("g / m finetune", 0.0); + + createPropertyNumeric("blue / yellow", -1, 1); + reset->addNumericValue("blue / yellow", 0.0); + + createPropertyNumeric("b / y finetune", -1, 1); + reset->addNumericValue("b / y finetune", 0.0); + + applyPreset("reset"); + if (colorSpace != deColorSpaceLAB) + { + disableAll(); + } + else + { + disableChannel(0); + } +} + +deWhiteBalanceLayer::~deWhiteBalanceLayer() +{ +} + +bool deWhiteBalanceLayer::updateMainImageSingleChannel(int channel) +{ + deValue s = 0.0; + deValue s2 = 0.0; + if (channel == 1) + { + s = getNumericValue("green / magenta"); + s2 = getNumericValue("g / m finetune"); + } + if (channel == 2) + { + s = getNumericValue("blue / yellow"); + s2 = getNumericValue("b/ y finetune"); + } + + s = 0.5 * s + 0.1 * s2; + + if (s > 0.49) + { + s = 0.49; + } + if (s < -0.49) + { + s = -0.49; + } + + const deValue* source = getSourceImage().startRead(channel); + deValue* target = mainLayerImage.startWrite(channel); + int n = mainLayerImage.getChannelSize().getN(); + + deBaseCurve curve; + + curve.addPoint(0, 0); + curve.addPoint(0.5 - s , 0.5); + curve.addPoint(1, 1); + + curve.build(); + + curve.process(source, target, n); + + getSourceImage().finishRead(channel); + mainLayerImage.finishWrite(channel); + + return true; +} + +bool deWhiteBalanceLayer::onImageClick(deValue x, deValue y) +{ + if (colorSpace != deColorSpaceLAB) + { + return false; + } + + const deImage& source = getSourceImage(); + + const deSize size = source.getChannelSize(); + + int p = (y * size.getH() ) * size.getW() + (x * size.getW()); + + const deValue* pixelsA = source.startRead(1); + const deValue* pixelsB = source.startRead(2); + + deValue a = pixelsA[p] - 0.5; + deValue b = pixelsB[p] - 0.5; + + source.finishRead(1); + source.finishRead(2); + + a = -2 * a; + b = -2 * b; + + getPropertyNumeric("green / magenta")->set(a); + getPropertyNumeric("g / m finetune")->set(0.0); + getPropertyNumeric("blue / yellow")->set(b); + getPropertyNumeric("b / y finetune")->set(0.0); + + return true; +} diff -Nru delaboratory-0.7/layers/white_balance_layer.h delaboratory-0.8/layers/white_balance_layer.h --- delaboratory-0.7/layers/white_balance_layer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/layers/white_balance_layer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,38 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_WHITE_BALANCE_LAYER_H +#define _DE_WHITE_BALANCE_LAYER_H + +#include "layer_with_blending.h" + +class deWhiteBalanceLayer:public deLayerWithBlending +{ + private: + virtual std::string getType() const {return "white balance";}; + + public: + deWhiteBalanceLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); + virtual ~deWhiteBalanceLayer(); + + virtual bool updateMainImageSingleChannel(int i); + virtual bool onImageClick(deValue x, deValue y); + +}; + +#endif diff -Nru delaboratory-0.7/Makefile delaboratory-0.8/Makefile --- delaboratory-0.7/Makefile 2012-04-10 13:49:04.000000000 +0000 +++ delaboratory-0.8/Makefile 2012-07-30 10:51:11.000000000 +0000 @@ -1,37 +1,88 @@ + APP=delaboratory -FILES = delaboratory value size project main_frame image_io channel channel_manager layer source_image_layer layer_stack view_manager layer_grid_panel image_area_panel image_panel renderer color_space image scale_channel curves_layer curve curve_point curve_shape curve_function_bezier action_frame curves_editor curves_panel blend_mode blend_frame frame slider power rgb2xyz2lab apply_luminance_color conversion_layer convert_image copy_image copy_channel conversion_functions hsl_hsv histogram histogram_panel str layer_factory action_layer mixer mixer_layer mixer_editor mixer_editor_channel control_panel gradient_panel apply_image_layer apply_image_frame blur blur_type process_linear cmyk blur_layer blur_frame usm_layer usm_frame view_mode_panel bw help_frame help_color_spaces_frame help_color_spaces_frame2 convert_pixel memory_info_frame sampler_manager sampler layer_frame help_color_spaces_frame3 help_color_spaces_frame4 help_color_spaces_frame5 skin_color_chart help_color_spaces_frame6 fractal xml conversion_bw_layer mixer_bw_editor histogram_mode_panel file_dialogs benchmark_frame benchmarks layer_processor property_value external_editor frame_factory property_value_slider property property_choice choice property_choice_ui property_boolean check_box property_boolean_ui dodge_burn_layer dodge_burn_frame blend_channel shadows_highlights_layer shadows_highlights_frame high_pass_layer high_pass_frame vignette_layer vignette samplers_panel sampler_panel layer_frame_manager vignette_frame conversion_bw2hue_layer hue_saturation_frame static_image rendered_image dcraw_support raw_module basic_setting basic_layer basic_frame zoom_panel zoom_manager equalizer equalizer_frame equalizer_layer threads_panel palette color_matrix_frame color_matrix +all: ${APP} + +CXX=g++ + +ifeq (${OS}, MACOSX) +WXCONFIG=/Users/partha/local/wxw-2.9/bin/wx-config +else +WXCONFIG=wx-config +#WXCONFIG=wx-config-2.9 +endif + +FILES = delaboratory main_frame image_io layer_grid_panel image_area_panel image_panel curves_panel frame slider histogram_panel control_panel gradient_panel view_mode_panel help_frame help_color_spaces_frame help_color_spaces_frame2 help_color_spaces_frame3 help_color_spaces_frame4 help_color_spaces_frame5 help_color_spaces_frame6 histogram_mode_panel file_dialogs external_editor choice property_choice_ui check_box property_boolean_ui samplers_panel sampler_panel layer_frame_manager rendered_image dcraw_support raw_module zoom_panel threads_panel color_matrix_frame mutex color_space_utils semaphore main_window canvas canvas_wx bitmap bitmap_wx window window_wx panel_wx property_numeric_ui button warning_panel property_levels_ui mutex_read_write property_mixer_ui channel_selector property_curves_ui tiff logger str_wx update_main_layer_image layer_processor_threads progress_dialog message_box update_blend gui tmp + +LAYERS = curves_layer mixer_layer auto_dodge_layer auto_burn_layer recover_shadows_layer recover_highlights_layer high_pass_layer vignette_layer source_image_layer gaussian_blur_layer gaussian_blur_single_layer conversion_layer equalizer_layer c2g_layer copy_layer gradient_layer fill_layer levels_layer tone_layer exposure_layer white_balance_layer saturation_layer local_contrast_layer sharpen_layer + +ALGORITHMS = blur usm c2g scale_channel sample_pixel blend_channel vignette gradient blur_type blend_mode blend_color_luminosity fill_channel radial_lut + +CORE = base_layer base_layer_with_properties base_layer_with_source channel_manager layer_stack conversion_cpu conversion_processor property color_space value image power size copy_channel histogram layer_factory operation_processor sampler_manager sampler preset static_image view_manager zoom_manager str switchable_layer color_matrix palette layer_processor flatten_layers layer_with_blending test_image skin_color_chart renderer generic_layer_frame layer_frame preset_button project + +PROPERTIES = property_numeric property_mixer mixer property_curves curve curve_point curve_shape curve_function_bezier property_choice property_boolean property_levels + +OBJECTS_TMP = ${addsuffix .o, ${FILES}} +OBJECTS = ${addprefix obj/, ${OBJECTS_TMP}} +LAYERS_OBJECTS_TMP = ${addsuffix .o, ${LAYERS}} +LAYERS_OBJECTS = ${addprefix obj/, ${LAYERS_OBJECTS_TMP}} +CORE_OBJECTS_TMP = ${addsuffix .o, ${CORE}} +CORE_OBJECTS = ${addprefix obj/, ${CORE_OBJECTS_TMP}} +PROPERTIES_OBJECTS_TMP = ${addsuffix .o, ${PROPERTIES}} +PROPERTIES_OBJECTS = ${addprefix obj/, ${PROPERTIES_OBJECTS_TMP}} +ALGORITHMS_OBJECTS_TMP = ${addsuffix .o, ${ALGORITHMS}} +ALGORITHMS_OBJECTS = ${addprefix obj/, ${ALGORITHMS_OBJECTS_TMP}} + +CXXFLAGS= ifeq (${OS}, WINDOWS) # settings for Windows build LDFLAGS=`/opt/wxw/bin/wx-config --libs` `pkg-config --libs libxml-2.0` -L/opt/lib -ltiff -CXXFLAGS=`/opt/wxw/bin/wx-config --cxxflags` `pkg-config --cflags libxml-2.0` -I/opt/include -OBJECTS = delab.o ${addsuffix .o, ${FILES}} +CXXFLAGS_WX=`/opt/wxw/bin/wx-config --cxxflags` `pkg-config --cflags libxml-2.0` -I/opt/include +OBJECTS += delab.o EXE=.exe + else # settings for standard build LDFLAGS=`${WXCONFIG} --libs` `xml2-config --libs` -ltiff -CXXFLAGS=`${WXCONFIG} --cxxflags` `xml2-config --cflags` -OBJECTS = ${addsuffix .o, ${FILES}} +CXXFLAGS_WX=`${WXCONFIG} --cxxflags` `xml2-config --cflags` endif +# warnings from wxWidgets +CXXFLAGS_WX+=-Wno-long-long -Wno-variadic-macros + +INCLUDES=-I gui_wx -I layers -I algorithms -I core -I properties + +CXXFLAGS += ${INCLUDES} +CXXFLAGS_WX += ${INCLUDES} + SOURCES_TMP = ${addsuffix .cc, ${FILES}} -SOURCES = ${addprefix src/, ${SOURCES_TMP}} +SOURCES = ${addprefix gui_wx/, ${SOURCES_TMP}} +LAYERS_SOURCES_TMP = ${addsuffix .cc, ${LAYERS}} +LAYERS_SOURCES = ${addprefix layers/, ${LAYERS_SOURCES_TMP}} +CORE_SOURCES_TMP = ${addsuffix .cc, ${CORE}} +CORE_SOURCES = ${addprefix core/, ${CORE_SOURCES_TMP}} +PROPERTIES_SOURCES_TMP = ${addsuffix .cc, ${PROPERTIES}} +PROPERTIES_SOURCES = ${addprefix properties/, ${PROPERTIES_SOURCES_TMP}} +ALGORITHMS_SOURCES_TMP = ${addsuffix .cc, ${ALGORITHMS}} +ALGORITHMS_SOURCES = ${addprefix algorithms/, ${ALGORITHMS_SOURCES_TMP}} HEADERS_TMP = ${addsuffix .h, ${FILES}} -HEADERS = ${addprefix src/, ${HEADERS_TMP}} - -CXX=g++ -WXCONFIG=wx-config -#WXCONFIG=wx-config-2.9 +HEADERS = ${addprefix gui_wx/, ${HEADERS_TMP}} +LAYERS_HEADERS_TMP = ${addsuffix .h, ${LAYERS}} +LAYERS_HEADERS = ${addprefix layers/, ${LAYERS_HEADERS_TMP}} +CORE_HEADERS_TMP = ${addsuffix .h, ${CORE}} +CORE_HEADERS = ${addprefix core/, ${CORE_HEADERS_TMP}} +PROPERTIES_HEADERS_TMP = ${addsuffix .h, ${PROPERTIES}} +PROPERTIES_HEADERS = ${addprefix properties/, ${PROPERTIES_HEADERS_TMP}} +ALGORITHMS_HEADERS_TMP = ${addsuffix .h, ${ALGORITHMS}} +ALGORITHMS_HEADERS = ${addprefix algorithms/, ${ALGORITHMS_HEADERS_TMP}} STRIP=strip -# choose your architecture -#OPTFLAGS=-march=core2 ifeq (${DEB_BUILD_GNU_CPU}, x86_64) OPTFLAGS=-march=x86-64 @@ -39,46 +90,52 @@ OPTFLAGS=-march=i686 endif +# choose your architecture +#OPTFLAGS=-march=core2 + ifeq (${DEBUG}, YES) # debug stuff CXXFLAGS+=-g -Wall -pedantic else # release stuff -# CXXFLAGS+=-ffast-math -fpermissive ${OPTFLAGS} -DNDEBUG -# -Ofast -fpermissive ${OPTFLAGS} -DNDEBUG -CXXFLAGS+=-Ofast -fpermissive ${OPTFLAGS} -DNDEBUG +CXXFLAGS+=-Ofast ${OPTFLAGS} -DNDEBUG endif -# warnings from wxWidgets -CXXFLAGS+=-Wno-long-long -Wno-variadic-macros +include .depend -${APP}: ${OBJECTS} - ${CXX} -c ${CXXFLAGS} -o logger.o src/logger.cc -DLOGGING - ${CXX} -o ${APP}-with-logs ${OBJECTS} ${LDFLAGS} logger.o - ${CXX} -c ${CXXFLAGS} -o logger.o src/logger.cc - ${CXX} -o ${APP} ${OBJECTS} ${LDFLAGS} logger.o +${APP}: ${CORE_OBJECTS} ${LAYERS_OBJECTS} ${ALGORITHMS_OBJECTS} ${PROPERTIES_OBJECTS} ${OBJECTS} + ${CXX} -o ${APP} ${CORE_OBJECTS} ${OBJECTS} ${LAYERS_OBJECTS} ${ALGORITHMS_OBJECTS} ${PROPERTIES_OBJECTS} ${LDFLAGS} ifeq (${DEBUG}, YES) else -# ${STRIP} ${APP}-with-logs${EXE} ${STRIP} ${APP}${EXE} endif -%.o: src/%.cc - ${CXX} -c ${CXXFLAGS} $< +obj/%.o: gui_wx/%.cc + ${CXX} -c ${CXXFLAGS_WX} -o $@ $< -depend: $(SOURCES) ${HEADERS} - $(CXX) $(CXXFLAGS) -MM $^>>./.depend; +obj/%.o: layers/%.cc + ${CXX} -c ${CXXFLAGS} -o $@ $< -include .depend +obj/%.o: core/%.cc + ${CXX} -c ${CXXFLAGS} -o $@ $< + +obj/%.o: properties/%.cc + ${CXX} -c ${CXXFLAGS} -o $@ $< + +obj/%.o: algorithms/%.cc + ${CXX} -c ${CXXFLAGS} -o $@ $< + +depend: $(SOURCES) ${HEADERS} ${CORE_SOURCES} ${CORE_HEADERS} + $(CXX) $(CXXFLAGS_WX) ${INCLUDES} -MM $^ >>./.depend; -all: ${APP} install: mkdir -p $(DESTDIR)/usr/bin install ${APP} $(DESTDIR)/usr/bin - clean: rm -f ./.depend touch .depend - rm -f *.o ${APP}${EXE} -# rm -f *.o ${APP}${EXE} ${APP}-with-logs${EXE} + rm -f ${APP}${EXE} + rm -f obj/*.o + + diff -Nru delaboratory-0.7/properties/curve.cc delaboratory-0.8/properties/curve.cc --- delaboratory-0.7/properties/curve.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve.cc 2012-07-15 12:42:56.000000000 +0000 @@ -0,0 +1,309 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curve.h" +#include +#include +#include +#include +#include "str.h" +#include "logger.h" + +#define CURVE_POINT_PICK_DISTANCE 0.03 +#define VERTICAL_STEP 0.01 + +#define CURVE_SHAPE_SIZE 256 + +deBaseCurve::deBaseCurve() +:shape(CURVE_SHAPE_SIZE) +{ +} + +deBaseCurve::~deBaseCurve() +{ +} + +void deBaseCurve::clearPoints() +{ + mutex.lock(); + controlPoints.clear(); + mutex.unlock(); +} + +int deBaseCurve::addPoint(deValue x, deValue y) +{ + if ((x < 0) || (x > 1)) + { + return -1; + } + if (y < 0) + { + y = 0; + } + if (y > 1) + { + y = 1; + } + /* + if ((y < 0) || (y > 1)) + { + return -1; + }*/ + + mutex.lock(); + + bool moved = false; + int p = -1; + int i = 0; + + deCurvePoints::iterator j; + for (j = controlPoints.begin(); j != controlPoints.end(); j++) + { + deCurvePoint& point = *j; + if (point.getX() == x) + { + point.move(x, y); + moved = true; + p = i; + } + i++; + } + + if (!moved) + { + controlPoints.push_back(deCurvePoint(x,y)); + p = controlPoints.size() - 1; + } + + mutex.unlock(); + + return p; +} + +void deBaseCurve::build() +{ + mutex.lock(); + + shape.build(controlPoints); + + mutex.unlock(); +} + +void deBaseCurve::process(const deValue* pixels, deValue* p, int n) const +{ + mutex.lock(); + + int i; + for (i = 0; i < n; i++) + { + deValue value = pixels[i]; + deValue result = shape.calc(value); + + if (result < 0) + { + p[i] = 0; + } + else if (result > 1) + { + p[i] = 1; + } + else + { + p[i] = result; + } + } + + mutex.unlock(); +} + +deValue deBaseCurve::calcValue(deValue value) const +{ + return shape.calc(value); +} + +int deBaseCurve::findPoint(deValue x, deValue y) const +{ + mutex.lock(); + + deCurvePoints::const_iterator j; + int i = 0; + + for (j = controlPoints.begin(); j != controlPoints.end(); j++) + { + const deCurvePoint& point = *j; + deValue xx = x - point.getX(); + float yy = y - point.getY(); + if (sqrt (xx * xx + yy * yy) < CURVE_POINT_PICK_DISTANCE) + { + mutex.unlock(); + return i; + } + i++; + } + + mutex.unlock(); + return -1; +} + +void deBaseCurve::deletePoint(int p) +{ + if (p < 0) + { + logError("negative p in curve delete point"); + return; + } + + mutex.lock(); + + if (controlPoints.size() == 0) + { + logError("empty control points in curve delete point"); + mutex.unlock(); + return; + } + + deCurvePoints::iterator i = controlPoints.begin(); + while (p > 0) + { + i++; + p--; + if (i == controlPoints.end()) + { + int s = controlPoints.size(); + logError("end of control points in curve delete point, p was " + str(p) + " size of control points was " + str(s)); + mutex.unlock(); + return; + } + } + + controlPoints.erase(i); + + mutex.unlock(); +} + +void deBaseCurve::movePoint(int p, deValue x, deValue y) +{ + if (p < 0) + { + logError("negative p in curve move point"); + return; + } + + if ((x < 0) || (x > 1)) + { + logError("bad x in curve move point"); + return; + } + if ((y < 0) || (y > 1)) + { + logError("bad y in curve move point"); + return; + } + + mutex.lock(); + + if ((unsigned int)p >= controlPoints.size()) + { + logError("too big p in curve move point"); + mutex.unlock(); + return; + } + + deCurvePoints::iterator i = controlPoints.begin(); + while (p > 0) + { + i++; + p--; + } + + deValue xx = (*i).getX(); + + if (xx == 0) + { + x = 0; + } + else + { + if (x == 0) + { + logInfo("can't move point on curve to x=0"); + mutex.unlock(); + return; + } + } + + if (xx == 1) + { + x = 1; + } + else + { + if (x == 1) + { + logInfo("can't move point on curve to x=1"); + mutex.unlock(); + return; + } + } + + (*i).move(x, y); + + mutex.unlock(); +} + +const deCurvePoint& deBaseCurve::getPoint(int n) const +{ + mutex.lock(); + + deCurvePoints::const_iterator i = controlPoints.begin(); + while (n > 0) + { + i++; + n--; + } + + mutex.unlock(); + return *i; +} + +const deCurvePoints& deBaseCurve::getControlPoints() const +{ + return controlPoints; +} + +bool deBaseCurve::isNeutral() const +{ + if (controlPoints.size() != 2) + { + return false; + } + deCurvePoints::const_iterator i = controlPoints.begin(); + deCurvePoint a = *i; + if (a.getY() != 0) + { + return false; + } + i++; + deCurvePoint b = *i; + if (b.getY() != 1) + { + return false; + } + return true; +} + diff -Nru delaboratory-0.7/properties/curve_function_bezier.cc delaboratory-0.8/properties/curve_function_bezier.cc --- delaboratory-0.7/properties/curve_function_bezier.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_function_bezier.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,59 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curve_function_bezier.h" + +deCurveFunctionBezier::deCurveFunctionBezier() +{ + x0 = 0; + x3 = 0; + y0 = 0; + y1 = 0; + y2 = 0; + y3 = 0; +} + +void deCurveFunctionBezier::set(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3) +{ + x0 = _x0; + x3 = _x3; + y0 = _y0; + y1 = _y1; + y2 = _y2; + y3 = _y3; +} + +deCurveFunctionBezier::~deCurveFunctionBezier() +{ +} + + +deValue deCurveFunctionBezier::calc(deValue value) const +{ + deValue d = x3 - x0; + if (d == 0.0) + { + return y0; + } + + deValue t = (value - x0) / d; + deValue t1 = 1.0 - t; + + return (y0 * t1 * t1 * t1) + 3 * (y1 * t1 * t1 * t) + 3 * (y2 * t1 * t * t) + (y3 * t * t * t); +} + diff -Nru delaboratory-0.7/properties/curve_function_bezier.h delaboratory-0.8/properties/curve_function_bezier.h --- delaboratory-0.7/properties/curve_function_bezier.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_function_bezier.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,43 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVE_FUNCTION_BEZIER_H +#define _DE_CURVE_FUNCTION_BEZIER_H + +#include "value.h" + +class deCurveFunctionBezier +{ + private: + deValue x0; + deValue x3; + deValue y0; + deValue y1; + deValue y2; + deValue y3; + + public: + deCurveFunctionBezier(); + virtual ~deCurveFunctionBezier(); + + virtual deValue calc(deValue value) const; + + void set(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3); +}; + +#endif diff -Nru delaboratory-0.7/properties/curve.h delaboratory-0.8/properties/curve.h --- delaboratory-0.7/properties/curve.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,64 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVE_H +#define _DE_CURVE_H + +#include "curve_point.h" +#include "curve_shape.h" +#include +#include "mutex.h" +#include + +class deChannel; + +class deBaseCurve +{ + protected: + deCurvePoints controlPoints; + deCurveShape shape; + + mutable deMutex mutex; + + deBaseCurve(const deBaseCurve& c); + deBaseCurve& operator =(const deBaseCurve& c); + + public: + deBaseCurve(); + virtual ~deBaseCurve(); + + void clearPoints(); + int addPoint(deValue x, deValue y); + + void build(); + void process(const deValue* source, deValue* destination, int n) const; + + int findPoint(deValue x, deValue y) const; + void deletePoint(int p); + void movePoint(int p, deValue x, deValue y); + + bool isNeutral() const; + + const deCurvePoints& getControlPoints() const; + const deCurvePoint& getPoint(int n) const; + + deValue calcValue(deValue value) const; + +}; + +#endif diff -Nru delaboratory-0.7/properties/curve_point.cc delaboratory-0.8/properties/curve_point.cc --- delaboratory-0.7/properties/curve_point.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_point.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,34 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curve_point.h" + +deCurvePoint::deCurvePoint(deValue _x, deValue _y) +:x(_x), y(_y) +{ +} + +deCurvePoint::~deCurvePoint() +{ +} + +void deCurvePoint::move(deValue _x, deValue _y) +{ + x = _x; + y = _y; +} diff -Nru delaboratory-0.7/properties/curve_point.h delaboratory-0.8/properties/curve_point.h --- delaboratory-0.7/properties/curve_point.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_point.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,45 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVE_POINT_H +#define _DE_CURVE_POINT_H + +#include "value.h" +#include + +class deCurvePoint +{ + private: + deValue x; + deValue y; + + deCurvePoint(); + public: + deCurvePoint(deValue _x, deValue _y); + virtual ~deCurvePoint(); + + deValue getX() const {return x;}; + deValue getY() const {return y;}; + + void move(deValue _x, deValue _y); + +}; + +typedef std::vector deCurvePoints; + +#endif diff -Nru delaboratory-0.7/properties/curve_shape.cc delaboratory-0.8/properties/curve_shape.cc --- delaboratory-0.7/properties/curve_shape.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_shape.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,147 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "curve_shape.h" +#include +#include "curve_function_bezier.h" +#include + +deCurveShape::deCurveShape(int _size) +:size(_size), functions(_size) +{ +} + +deCurveShape::~deCurveShape() +{ +} + +deValue deCurveShape::calc(deValue value) const +{ + if ( value <= 0 ) + { + return functions.at(0).calc(0); + } + else if (value >= 1) + { + return functions.at(size-1).calc(1); + } + else + { + deValue s = size - 1; + int p = s * value; + + return functions.at(p).calc(value); + } +} + +void deCurveShape::build(const deCurvePoints& points) +{ + typedef std::map deNodes; + deNodes nodes; + deCurvePoints::const_iterator j; + + for (j = points.begin(); j != points.end(); j++) + { + const deCurvePoint& point = *j; + deValue x = point.getX(); + deValue y = point.getY(); + nodes.insert(std::pair(x, y)); + } + + /* math formulas from GIMP + gimp_curve_plot from gimpcurve.c */ + + deNodes::const_iterator i; + + for (i = nodes.begin(); i != nodes.end(); i++) + { + bool left = false; + bool right = false; + + deValue x0 = (*i).first; + deValue y0 = (*i).second; + deNodes::const_iterator j = i; + deNodes::const_iterator k = i; + j++; + k++; + deValue x3 = x0; + deValue y3 = y0; + if (j != nodes.end()) + { + x3 = (*j).first; + y3 = (*j).second; + k++; + if (k != nodes.end()) + { + right = true; + } + } + + deNodes::const_iterator h = i; + if (h != nodes.begin()) + { + h--; + left = true; + } + + deValue dx = x3 - x0; + deValue dy = y3 - y0; + + deValue y1; + deValue y2; + + if ((!left) && (!right)) + { + y1 = y0 + dy / 3.0; + y2 = y0 + dy * 2.0 / 3.0; + } + + if ((!left) && (right)) + { + deValue s = ((*k).second - y0) / ((*k).first - x0); + y2 = y3 - s * dx / 3.0; + y1 = y0 + (y2 - y0) / 2.0; + } + + if ((left) && (!right)) + { + deValue s = (y3 - (*h).second) / (x3 - (*h).first); + + y1 = y0 + s * dx / 3.0; + y2 = y3 + (y1 - y3) / 2.0; + } + + if ((left) && (right)) + { + deValue s1 = (y3 - (*h).second) / (x3 - (*h).first); + deValue s2 = ((*k).second - y0) / ((*k).first - x0); + + y1 = y0 + s1 * dx / 3.0; + y2 = y3 - s2 * dx / 3.0; + } + + int p1 = x0 * (size - 1); + int p2 = x3 * (size - 1); + int iii; + for (iii = p1; iii <= p2; iii++) + { + functions.at(iii).set(x0, x3, y0, y1, y2, y3); + } + } + +} diff -Nru delaboratory-0.7/properties/curve_shape.h delaboratory-0.8/properties/curve_shape.h --- delaboratory-0.7/properties/curve_shape.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/curve_shape.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_CURVE_SHAPE_H +#define _DE_CURVE_SHAPE_H + +#include +#include "value.h" +#include "curve_point.h" +#include + +class deCurveFunctionBezier; + +class deCurveShape +{ + private: + int size; + std::vector functions; + + public: + deCurveShape(int _size); + ~deCurveShape(); + + void build(const deCurvePoints& points); + + deValue calc(deValue value) const; +}; + +#endif diff -Nru delaboratory-0.7/properties/mixer.cc delaboratory-0.8/properties/mixer.cc --- delaboratory-0.7/properties/mixer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/mixer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,158 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "mixer.h" +#include "str.h" +#include +#include +#include "logger.h" +#include "image.h" + +deMixer::deMixer(int _size) +:size(_size) +{ + weights = new deValue [size]; +} + +deMixer::~deMixer() +{ + delete [] weights; +} + +deValue deMixer::getWeight(int c) const +{ + lock(); + + if ((c < 0) || (c >= size)) + { + unlock(); + return 0.0; + } + + unlock(); + return weights[c]; +} + +void deMixer::setWeight(int c, deValue value) +{ + if ((c < 0) || (c >= size)) + { + return; + } + + lock(); + + weights[c] = value; + + unlock(); +} + +void deMixer::process(const deImage& sourceImage, deValue* destination, int n) +{ + if (size < 1) + { + return; + } + + int i; + + lock(); + + const deValue *p1 = sourceImage.startRead(0); + + // FIXME clipping + + if (size == 1) + { + for (i = 0; i < n; i++) + { + deValue result = weights[0] * p1[i]; + destination[i] = result; + } + } + + if (size > 2) + { + const deValue *p2 = sourceImage.startRead(1); + const deValue *p3 = sourceImage.startRead(2); + + if (size == 3) + { + for (i = 0; i < n; i++) + { + deValue result = weights[0] * p1[i]; + result += weights[1] * p2[i]; + result += weights[2] * p3[i]; + destination[i] = result; + } + } + + if (size == 4) + { + const deValue *p4 = sourceImage.startRead(3); + for (i = 0; i < n; i++) + { + deValue result = weights[0] * p1[i]; + result += weights[1] * p2[i]; + result += weights[2] * p3[i]; + result += weights[3] * p4[i]; + destination[i] = result; + } + sourceImage.finishRead(3); + } + + sourceImage.finishRead(1); + sourceImage.finishRead(2); + } + + sourceImage.finishRead(0); + unlock(); +} + +bool deMixer::isNeutral(int index) const +{ + int i; + for (i = 0; i < size; i++) + { + if (i == index) + { + if (weights[i] != 1.0) + { + return false; + } + } + else + { + if (weights[i] != 0.0) + { + return false; + } + } + } + return true; +} + +void deMixer::lock() const +{ + mutex.lock(); +} + +void deMixer::unlock() const +{ + mutex.unlock(); +} diff -Nru delaboratory-0.7/properties/mixer.h delaboratory-0.8/properties/mixer.h --- delaboratory-0.7/properties/mixer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/mixer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,54 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_MIXER_H +#define _DE_MIXER_H + +#include "value.h" +#include "mutex.h" +class deChannel; +class deImage; + +class deMixer +{ + private: + int size; + deValue* weights; + + mutable deMutex mutex; + + deMixer(const deMixer& mixer); + deMixer operator=(const deMixer& mixer); + + void lock() const; + void unlock() const; + + public: + deMixer(int _size); + virtual ~deMixer(); + + deValue getWeight(int c) const; + void setWeight(int c, deValue value); + + void process(const deImage& sourceImage, deValue* destination, int n); + + bool isNeutral(int index) const; + +}; + +#endif diff -Nru delaboratory-0.7/properties/property_boolean.cc delaboratory-0.8/properties/property_boolean.cc --- delaboratory-0.7/properties/property_boolean.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_boolean.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,42 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_boolean.h" +#include "str.h" + +dePropertyBoolean::dePropertyBoolean(const std::string& _name) +:deProperty(_name) +{ + value = false; +} + +dePropertyBoolean::~dePropertyBoolean() +{ +} + +void dePropertyBoolean::set(bool _value) +{ + value = _value; +} + + +bool dePropertyBoolean::get() const +{ + return value; +} + diff -Nru delaboratory-0.7/properties/property_boolean.h delaboratory-0.8/properties/property_boolean.h --- delaboratory-0.7/properties/property_boolean.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_boolean.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,37 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_BOOLEAN_H +#define _DE_PROPERTY_BOOLEAN_H + +#include "property.h" + +class dePropertyBoolean:public deProperty +{ + private: + bool value; + + public: + dePropertyBoolean(const std::string& _name); + virtual ~dePropertyBoolean(); + + void set(bool _value); + bool get() const; +}; + +#endif diff -Nru delaboratory-0.7/properties/property_choice.cc delaboratory-0.8/properties/property_choice.cc --- delaboratory-0.7/properties/property_choice.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_choice.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,83 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_choice.h" +#include "str.h" +#include "logger.h" + +dePropertyChoice::dePropertyChoice(const std::string& _name, const std::vector _choices) +:deProperty(_name), choices(_choices) +{ + value = 0; +} + +dePropertyChoice::~dePropertyChoice() +{ +} + +void dePropertyChoice::set(std::string s) +{ + std::vector::const_iterator i = choices.begin(); + int index = 0; + while (i != choices.end()) + { + if (*i == s) + { + value = index; + return; + } + i++; + index++; + } + logError("can't set choice value " + s); + value = -1; +} + +std::string dePropertyChoice::get() const +{ + if (value < 0) + { + return ""; + } + if ((unsigned)value >= choices.size()) + { + return ""; + } + return choices[value]; +} + +int dePropertyChoice::getIndex() const +{ + return value; +} + +void dePropertyChoice::setIndex(int index) +{ + value = index; +} + +std::vector createNumbers(int index) +{ + std::vector result; + int i; + for (i = 0; i < index; i++) + { + result.push_back(str(i)); + } + return result; +} diff -Nru delaboratory-0.7/properties/property_choice.h delaboratory-0.8/properties/property_choice.h --- delaboratory-0.7/properties/property_choice.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_choice.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,49 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_CHOICE_H +#define _DE_PROPERTY_CHOICE_H + +#include "property.h" +#include + +class dePropertyChoice:public deProperty +{ + private: + int value; + + std::vector choices; + + public: + dePropertyChoice(const std::string& _name, const std::vector _choices); + virtual ~dePropertyChoice(); + + const std::vector& getChoices() const {return choices;}; + + int getIndex() const; + void setIndex(int index); + + std::string get() const; + void set(std::string _value); + + +}; + +std::vector createNumbers(int index); + +#endif diff -Nru delaboratory-0.7/properties/property_curves.cc delaboratory-0.8/properties/property_curves.cc --- delaboratory-0.7/properties/property_curves.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_curves.cc 2012-07-15 07:36:44.000000000 +0000 @@ -0,0 +1,196 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_curves.h" +#include "str.h" + +dePropertyCurves::dePropertyCurves(const std::string& _name, int _size) +:deProperty(_name), size(_size) +{ + horizontalChannel = -1; + int i; + for (i = 0; i < size; i++) + { + curves.push_back( new deBaseCurve()); + } +} + +dePropertyCurves::~dePropertyCurves() +{ + int i; + for (i = 0; i < size; i++) + { + delete curves[i]; + } +} + +void dePropertyCurves::setHorizontalChannel(int channel) +{ + horizontalChannel = channel; +} + +int dePropertyCurves::getHorizontalChannel() const +{ + return horizontalChannel; +} + +bool dePropertyCurves::onKey(int key, int i, deValue p) +{ + deValue v = -1; + + if (key == 'W') + { + v = 1.0; + } + + if (key == 'B') + { + v = 0.0; + } + + if (key == 'A') + { + if (size == 4) + { + if (i == 0) + { + v = 4.0 / 100.0; + } + if (i == 1) + { + v = 3.0 / 100.0; + } + if (i == 2) + { + v = 15.0 / 100.0; + } + if (i == 3) + { + v = 0; + } + } + } + + if (key == 'S') + { + if (size == 4) + { + if (i == 0) + { + v = 15.0 / 100.0; + } + if (i == 1) + { + v = 35.0 / 100.0; + } + if (i == 2) + { + v = 55.0 / 100.0; + } + if (i == 3) + { + v = 0; + } + } + } + + if (key == 'D') + { + if (size == 4) + { + if (i == 0) + { + v = 69.0 / 100.0; + } + if (i == 1) + { + v = 53.0 / 100.0; + } + if (i == 2) + { + v = 54.0 / 100.0; + } + if (i == 3) + { + v = 53.0 / 100.0; + } + } + } + + if (key == 'G') + { + if (size == 4) + { + if (i == 0) + { + v = 9.0 / 100.0; + } + if (i == 1) + { + v = 7.0 / 100.0; + } + if (i == 2) + { + v = 9.0 / 100.0; + } + if (i == 3) + { + v = 0.0 / 100.0; + } + } + } + + if (key == 'H') + { + if (size == 4) + { + if (i == 0) + { + v = 12.0 / 100.0; + } + if (i == 1) + { + v = 17.0 / 100.0; + } + if (i == 2) + { + v = 22.0 / 100.0; + } + if (i == 3) + { + v = 0.0 / 100.0; + } + } + } + + if (key == ' ') + { + v = p; + } + + if (v >= 0) + { + curves[i]->addPoint(p, v); + curves[i]->build(); + return true; + } + + return false; + + +} diff -Nru delaboratory-0.7/properties/property_curves.h delaboratory-0.8/properties/property_curves.h --- delaboratory-0.7/properties/property_curves.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_curves.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,48 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_CURVES_H +#define _DE_PROPERTY_CURVES_H + +#include "property.h" +#include "value.h" +#include +#include "curve.h" + +class dePropertyCurves:public deProperty +{ + private: + std::vector curves; + int size; + int horizontalChannel; + + public: + dePropertyCurves(const std::string& _name, int _size); + virtual ~dePropertyCurves(); + + int getSize() const; + + const deBaseCurve* getCurve(int index) const {return (curves[index]);}; + deBaseCurve* getCurve(int index) {return (curves[index]);}; + void setHorizontalChannel(int channel); + int getHorizontalChannel() const; + bool onKey(int key, int i, deValue v); + +}; + +#endif diff -Nru delaboratory-0.7/properties/property_levels.cc delaboratory-0.8/properties/property_levels.cc --- delaboratory-0.7/properties/property_levels.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_levels.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,131 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_levels.h" +#include "str.h" + +deLevels::deLevels() +{ + min = 0; + middle = 0.5; + max = 1.0; +} + +deLevels::~deLevels() +{ +} + +void deLevels::setMin(deValue _value) +{ + min = _value; + + sort(); +} + +deValue deLevels::getMin() const +{ + return min; +} + +void deLevels::setMiddle(deValue _value) +{ + middle = _value; + + sort(); +} + +deValue deLevels::getMiddle() const +{ + return middle; +} + +void deLevels::setMax(deValue _value) +{ + max = _value; + + sort(); +} + +deValue deLevels::getMax() const +{ + return max; +} + +void deLevels::sort() +{ + if ((min <= middle) && (middle <= max)) + { + return; + } + + deValue m = 0.01; + + if (middle > 1.0 - m) + { + middle = 1.0 + m; + } + + if (middle < m) + { + middle = m; + } + + if (min > middle - m) + { + min = middle - m; + } + + if (max < middle + m) + { + max = middle + m; + } +} + +bool deLevels::isNeutral() const +{ + if (min != 0.0) + { + return false; + } + if (middle != 0.5) + { + return false; + } + if (max != 1.0) + { + return false; + } + return true; +} + + +dePropertyLevels::dePropertyLevels(const std::string& _name, int _size) +:deProperty(_name), size(_size) +{ + int i; + for (i = 0; i < size; i++) + { + levels.push_back( deLevels()); + } +} + +dePropertyLevels::~dePropertyLevels() +{ +} + + diff -Nru delaboratory-0.7/properties/property_levels.h delaboratory-0.8/properties/property_levels.h --- delaboratory-0.7/properties/property_levels.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_levels.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,66 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_LEVELS_H +#define _DE_PROPERTY_LEVELS_H + +#include "property.h" +#include "value.h" +#include + +class deLevels +{ + private: + deValue min; + deValue middle; + deValue max; + + void sort(); + + public: + deLevels(); + virtual ~deLevels(); + + void setMin(deValue _value); + deValue getMin() const; + void setMiddle(deValue _value); + deValue getMiddle() const; + void setMax(deValue _value); + deValue getMax() const; + + bool isNeutral() const; +}; + +class dePropertyLevels:public deProperty +{ + private: + std::vector levels; + int size; + + public: + dePropertyLevels(const std::string& _name, int _size); + virtual ~dePropertyLevels(); + + int getSize() const; + + const deLevels& getLevels(int index) const {return levels[index];}; + deLevels& getLevels(int index) {return levels[index];}; + +}; + +#endif diff -Nru delaboratory-0.7/properties/property_mixer.cc delaboratory-0.8/properties/property_mixer.cc --- delaboratory-0.7/properties/property_mixer.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_mixer.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,74 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_mixer.h" +#include "mixer.h" +#include "logger.h" +#include "str.h" + +dePropertyMixer::dePropertyMixer(const std::string& _name, int _size) +:deProperty(_name), size(_size) +{ + int i; + for (i = 0; i < size; i++) + { + mixers.push_back( new deMixer(size)); + //mixers[i]->reset(i); + } +} + +dePropertyMixer::~dePropertyMixer() +{ + int i; + for (i = 0; i < size; i++) + { + delete mixers[i]; + } +} + +const deMixer* dePropertyMixer::getMixer(int index) const +{ + if (index < 0) + { + logError("getMixer index: " + str(index)); + return NULL; + } + if (index >= size) + { + logError("getMixer index: " + str(index)); + return NULL; + } + + return mixers[index]; +} + +deMixer* dePropertyMixer::getMixer(int index) +{ + if (index < 0) + { + logError("getMixer index: " + str(index)); + return NULL; + } + if (index >= size) + { + logError("getMixer index: " + str(index)); + return NULL; + } + + return mixers[index]; +} diff -Nru delaboratory-0.7/properties/property_mixer.h delaboratory-0.8/properties/property_mixer.h --- delaboratory-0.7/properties/property_mixer.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_mixer.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,42 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_MIXER_H +#define _DE_PROPERTY_MIXER_H + +#include "property.h" +#include "mixer.h" +#include +class deMixer; + +class dePropertyMixer:public deProperty +{ + private: + std::vector mixers; + int size; + + public: + dePropertyMixer(const std::string& _name, int _size); + virtual ~dePropertyMixer(); + + const deMixer* getMixer(int index) const; + deMixer* getMixer(int index); + +}; + +#endif diff -Nru delaboratory-0.7/properties/property_numeric.cc delaboratory-0.8/properties/property_numeric.cc --- delaboratory-0.7/properties/property_numeric.cc 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_numeric.cc 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,59 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "property_numeric.h" +#include "str.h" + +dePropertyNumeric::dePropertyNumeric(const std::string& _name, deValue _min, deValue _max) +:deProperty(_name), min(_min), max(_max) +{ + value = (min + max) / 2.0; +} + +dePropertyNumeric::~dePropertyNumeric() +{ +} + +void dePropertyNumeric::set(deValue _value) +{ + value = _value; + if (value > max) + { + value = max; + } + if (value < min) + { + value = min; + } +} + +deValue dePropertyNumeric::get() const +{ + return value; +} + +deValue dePropertyNumeric::getMin() const +{ + return min; +} + +deValue dePropertyNumeric::getMax() const +{ + return max; +} + diff -Nru delaboratory-0.7/properties/property_numeric.h delaboratory-0.8/properties/property_numeric.h --- delaboratory-0.7/properties/property_numeric.h 1970-01-01 00:00:00.000000000 +0000 +++ delaboratory-0.8/properties/property_numeric.h 2012-06-08 22:38:01.000000000 +0000 @@ -0,0 +1,44 @@ +/* + delaboratory - color correction utility + Copyright (C) 2011 Jacek Poplawski + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _DE_PROPERTY_NUMERIC_H +#define _DE_PROPERTY_NUMERIC_H + +#include "property.h" +#include "value.h" + +class dePropertyNumeric:public deProperty +{ + private: + deValue value; + + deValue min; + deValue max; + + public: + dePropertyNumeric(const std::string& _name, deValue _min, deValue _max); + virtual ~dePropertyNumeric(); + + void set(deValue _value); + deValue get() const; + + deValue getMin() const; + deValue getMax() const; +}; + +#endif Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/benchmark_blur.jpg and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/benchmark_blur.jpg differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/benchmark_colors.jpg and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/benchmark_colors.jpg differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/general.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/general.png differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/gimp.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/gimp.png differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/gmic.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/gmic.png differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/layers.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/layers.png differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/o3_vs_ofast_march_core2.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/o3_vs_ofast_march_core2.png differ Binary files /tmp/Mb0N5dfvU2/delaboratory-0.7/screenshots/workflow.png and /tmp/089SUp3GQB/delaboratory-0.8/screenshots/workflow.png differ diff -Nru delaboratory-0.7/src/action_frame.cc delaboratory-0.8/src/action_frame.cc --- delaboratory-0.7/src/action_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/action_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "action_frame.h" -#include "action_layer.h" -#include "layer_frame_manager.h" - -deActionFrame::deActionFrame(wxWindow *parent, deActionLayer& _layer, deLayerFrameManager& _frameManager) -:deLayerFrame(parent, _layer, _layer.getLabel(), _frameManager) -{ - frameManager.addActionFrame(this); -} - -deActionFrame::~deActionFrame() -{ - frameManager.removeActionFrame(this); -} - diff -Nru delaboratory-0.7/src/action_frame.h delaboratory-0.8/src/action_frame.h --- delaboratory-0.7/src/action_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/action_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_ACTION_FRAME_H -#define _DE_ACTION_FRAME_H - -#include "layer_frame.h" -#include "value.h" - -class deActionFrame:public deLayerFrame -{ - private: - public: - deActionFrame(wxWindow *parent, deActionLayer& _layer, deLayerFrameManager& _frameManager); - virtual ~deActionFrame(); - - virtual bool onImageClick(deValue x, deValue y) {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/action_layer.cc delaboratory-0.8/src/action_layer.cc --- delaboratory-0.7/src/action_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/action_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,1044 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "action_layer.h" -#include "layer_stack.h" -#include "layer_processor.h" -#include "view_manager.h" -#include "channel_manager.h" -#include "apply_luminance_color.h" -#include "blend_frame.h" -#include "blur.h" -#include "copy_channel.h" -#include "process_linear.h" -#include "str.h" -#include "xml.h" -#include "blend_channel.h" -#include "logger.h" - -class deUpdateActionThread:public wxThread -{ - private: - virtual void *Entry() - { - bool result = layer.updateActionOnThread(channel); - if (!result) - { - logError("update action failed"); - layer.setError(); - } - semaphore.Post(); - return NULL; - } - deActionLayer& layer; - int channel; - wxSemaphore& semaphore; - public: - deUpdateActionThread(deActionLayer& _layer, int _channel, wxSemaphore& _semaphore) - :layer(_layer), - channel(_channel), - semaphore(_semaphore) - { - } - virtual ~deUpdateActionThread() - { - } -}; - -class deUpdateBlendThread:public wxThread -{ - private: - virtual void *Entry() - { - layer.updateBlendOnThread(channel); - semaphore.Post(); - return NULL; - } - deActionLayer& layer; - int channel; - wxSemaphore& semaphore; - public: - deUpdateBlendThread(deActionLayer& _layer, int _channel, wxSemaphore& _semaphore) - :layer(_layer), - channel(_channel), - semaphore(_semaphore) - { - } - virtual ~deUpdateBlendThread() - { - } -}; - -bool deActionLayer::updateActionAllChannels() -{ - logMessage("update action all channels start"); - - int n = getColorSpaceSize(colorSpace); - int i; - - wxSemaphore semaphore(0, n); - - errorOnUpdate = false; - - for (i = 0; i < n; i++) - { - logMessage("creating update action thread for channel " + str(i)); - deUpdateActionThread* thread = new deUpdateActionThread(*this, i, semaphore); - - if ( thread->Create() != wxTHREAD_NO_ERROR ) - { - std::cout << "creating thread... CREATE ERROR" << std::endl; - } - - if ( thread->Run() != wxTHREAD_NO_ERROR ) - { - std::cout << "creating thread... RUN ERROR" << std::endl; - } - } - - for (i = 0; i < n; i++) - { - logMessage("waiting for update action thread for channel " + str(i)); - semaphore.Wait(); - } - - logMessage("update action all channels end"); - - if (errorOnUpdate) - { - return false; - } - else - { - return true; - } -} - -bool deActionLayer::updateBlendAllChannels() -{ - logMessage("update blend all channels start"); - - int n = getColorSpaceSize(colorSpace); - int i; - - wxSemaphore semaphore(0, n); - - for (i = 0; i < n; i++) - { - deUpdateBlendThread* thread = new deUpdateBlendThread(*this, i, semaphore); - - if ( thread->Create() != wxTHREAD_NO_ERROR ) - { - std::cout << "creating thread... CREATE ERROR" << std::endl; - } - - if ( thread->Run() != wxTHREAD_NO_ERROR ) - { - std::cout << "creating thread... RUN ERROR" << std::endl; - } - } - - for (i = 0; i < n; i++) - { - semaphore.Wait(); - } - - logMessage("update blend all channels end"); - - return true; - -} - -bool deActionLayer::updateImageInActionLayer(bool action, bool blend, int channel) -{ -// std::cout << "updateImageInActionLayer " << channel << std::endl; - if (action) - { - if (channel >= 0) - { - if (!updateAction(channel)) - { - return false; - } - } - else - { - if (!updateActionAllChannels()) - { - return false; - } - } - } - - if (blend) - { - if ((blendMask) || (blendMaskShow)) - { - if (!renderBlendMask()) - { - return false; - } - } - - if (channel >= 0) - { - if (!updateBlend(channel)) - { - return false; - } - } - else - { - if (!updateBlendAllChannels()) - { - return false; - } - } - } - - if (!updateApply()) - { - return false; - } - - return true; -} - - -deActionLayer::deActionLayer(const std::string& _name, deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager) -:deLayer(_name, _colorSpace, _index, _sourceLayer), - layerStack(_layerStack), - channelManager(_channelManager), - viewManager(_viewManager), - imageActionPass(_colorSpace, _channelManager), - imageBlendMask(deColorSpaceBW, _channelManager), - imageApplyPass(_colorSpace, _channelManager), - imageBlendPass(_colorSpace, _channelManager) -{ - enabled = true; - blendMode = deBlendNormal; - applyMode = deApplyLuminanceAndColor; - opacity = 1.0; - blendMask = false; - blendMaskShow = false; - blendMaskLayer = 0; - blendMaskChannel = 0; - blendBlurRadius = 0; - blendMaskMin = 0; - blendMaskMax = 1; - - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - channels.insert(i); - } -} - -deActionLayer::~deActionLayer() -{ - disableBlendMaskChannel(); -} - -void deActionLayer::disableNotLuminance() -{ - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - if (!isChannelLuminance(colorSpace, i)) - { - channels.erase(i); - } - } -} - -void deActionLayer::enableBlendMaskChannel() -{ - imageBlendMask.enableChannel(0); -} - -void deActionLayer::disableBlendMaskChannel() -{ - imageBlendMask.disableChannel(0, -1); -} - -void deActionLayer::setBlendBlurRadius(deValue r) -{ - blendBlurRadius = r; -} - -const deImage& deActionLayer::getSourceImage() const -{ - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - return sourceImage; -} - -bool deActionLayer::isEnabled() const -{ - return enabled; -} - -void deActionLayer::setEnabled(bool e) -{ - enabled = e; -} - -deChannel* deActionLayer::getSourceChannel(int index) -{ - return channelManager.getChannel(getSourceImage().getChannelIndex(index)); -} - -deSize deActionLayer::getChannelSize() const -{ - return channelManager.getChannelSize(); -} - -const deImage& deActionLayer::getImage() const -{ - if (!enabled) - { - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - return sourceImage; - } - - if (applyMode != deApplyLuminanceAndColor) - { - return imageApplyPass; - } - - if (isBlendingEnabled()) - { - return imageBlendPass; - } - - return imageActionPass; -} - -deValue deActionLayer::getOpacity() -{ - return opacity; -} - -bool deActionLayer::updateApply() -{ - logMessage("update apply start"); - - if (!enabled) - { - return true; - } - - if (applyMode == deApplyLuminanceAndColor) - { - imageApplyPass.disableAllChannels(); - return true; - } - - imageApplyPass.enableAllChannels(); - - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - - int channelSize = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return false; - } - deChannel* sc2 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - if (!sc2) - { - return false; - } - deChannel* sc3 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - if (!sc3) - { - return false; - } - - sc1->lockRead(); - sc2->lockRead(); - sc3->lockRead(); - - deValue* r1 = sc1->getPixels(); - deValue* g1 = sc2->getPixels(); - deValue* b1 = sc3->getPixels(); - - deChannel* bc1 = NULL; - deChannel* bc2 = NULL; - deChannel* bc3 = NULL; - - if (isBlendingEnabled()) - { - bc1 = channelManager.getChannel(imageBlendPass.getChannelIndex(0)); - bc2 = channelManager.getChannel(imageBlendPass.getChannelIndex(1)); - bc3 = channelManager.getChannel(imageBlendPass.getChannelIndex(2)); - } - else - { - bc1 = channelManager.getChannel(imageActionPass.getChannelIndex(0)); - bc2 = channelManager.getChannel(imageActionPass.getChannelIndex(1)); - bc3 = channelManager.getChannel(imageActionPass.getChannelIndex(2)); - } - - bc1->lockRead(); - bc2->lockRead(); - bc3->lockRead(); - - deValue* r2 = bc1->getPixels(); - deValue* g2 = bc2->getPixels(); - deValue* b2 = bc3->getPixels(); - - deChannel* dc1 = channelManager.getChannel(imageApplyPass.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(imageApplyPass.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(imageApplyPass.getChannelIndex(2)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - - deValue* r = dc1->getPixels(); - deValue* g = dc2->getPixels(); - deValue* b = dc3->getPixels(); - - int i; - - if (applyMode == deApplyLuminance) - { - for (i = 0; i < channelSize; i++) - { - applyLuminance(r1[i], g1[i], b1[i], r2[i], g2[i], b2[i], r[i], g[i], b[i]); - } - } - if (applyMode == deApplyColor) - { - for (i = 0; i < channelSize; i++) - { - applyColor(r1[i], g1[i], b1[i], r2[i], g2[i], b2[i], r[i], g[i], b[i]); - } - } - - sc1->unlockRead(); - sc2->unlockRead(); - sc3->unlockRead(); - - bc1->unlockRead(); - bc2->unlockRead(); - bc3->unlockRead(); - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - - logMessage("update apply end"); - - return true; -} - -void deActionLayer::setApplyMode(deApplyMode mode) -{ - applyMode = mode; -} - - -bool deActionLayer::updateBlend(int i) -{ - logMessage("update blend start"); - - if (!enabled) - { - return true; - } - - deLayer* source = layerStack.getLayer(sourceLayer); - - if (!source) - { - return false; - } - - const deImage& sourceImage = source->getImage(); - - int channelSize = channelManager.getChannelSize().getN(); - - int s = sourceImage.getChannelIndex(i); - - if (!isBlendingEnabled()) - { - return true; - } - - if (isChannelNeutral(i)) - { - if (blendMode == deBlendNormal) - { - imageBlendPass.disableChannel(i, s); - return true; - } - } - - if (!isChannelEnabled(i)) - { - imageBlendPass.disableChannel(i, s); - return true; - } - - deChannel* sourceChannel = channelManager.getChannel(s); - if (!sourceChannel) - { - return false; - } - - int c = imageActionPass.getChannelIndex(i); - deChannel* channel = channelManager.getChannel(c); - if (!channel) - { - return false; - } - - imageBlendPass.enableChannel(i); - int b = imageBlendPass.getChannelIndex(i); - deChannel* blendChannel_ = channelManager.getChannel(b); - if (!blendChannel_) - { - return false; - } - - sourceChannel->lockRead(); - channel->lockRead(); - blendChannel_->lockWrite(); - - deValue* maskPixels = NULL; - - if ((blendMask) || (blendMaskShow)) - { - if (blendMask) - { - deChannel* allocatedMaskChannel = channelManager.getChannel(imageBlendMask.getChannelIndex(0)); - - allocatedMaskChannel->lockRead(); - - maskPixels = allocatedMaskChannel->getPixels(); - - } - } - else - { - disableBlendMaskChannel(); - } - - deValue* sourcePixels = sourceChannel->getPixels(); - deValue* overlayPixels = channel->getPixels(); - deValue* resultPixels = blendChannel_->getPixels(); - - blendChannel(sourcePixels, overlayPixels, resultPixels, maskPixels, blendMode, opacity, channelSize); - - - sourceChannel->unlockRead(); - channel->unlockRead(); - blendChannel_->unlockWrite(); - - if (blendMask) - { - deChannel* allocatedMaskChannel = channelManager.getChannel(imageBlendMask.getChannelIndex(0)); - - allocatedMaskChannel->unlockRead(); - } - - logMessage("update blend end"); - - return true; - -} - -void deActionLayer::setBlendMode(deBlendMode mode) -{ - blendMode = mode; -} - -bool deActionLayer::isBlendingEnabled() const -{ - if (opacity < 1.0) - { - return true; - } - - if (blendMode != deBlendNormal) - { - return true; - } - - if (blendMask) - { - return true; - } - - return false; -} - -void deActionLayer::setOpacity(deValue _opacity) -{ - opacity = _opacity; -} - -bool deActionLayer::updateImage() -{ -// std::cout << "updateImage :(" << std::endl; - return updateImageInActionLayer(true, true, -1); -} - -bool deActionLayer::updateAction(int i) -{ - bool actionResult = false; - - if ((i < 0) || (i>=getColorSpaceSize(colorSpace))) - { - logError("updateAction for invalid channel " +str(i)+ " requested"); - return false; - }; - - - -// std::cout << "updateAction " << i << std::endl; - - logMessage("update action start i:" +str(i)); - - if (!enabled) - { - return true; - } - - logMessage("update action 2 i:" +str(i)); - - deLayer* source = layerStack.getLayer(sourceLayer); - - logMessage("update action 3 i:" +str(i)); - - const deImage& sourceImage = source->getImage(); - - int channelSize = channelManager.getChannelSize().getN(); - - int s = sourceImage.getChannelIndex(i); - - if (simpleActionProcessing()) - { - return processAction(i); - } - - logMessage("update action 4 i:" +str(i)); - - if ((isChannelNeutral(i)) || (!isChannelEnabled(i))) - { - logMessage("update action 4a i:" +str(i)); - deChannel* sourceChannel = channelManager.getChannel(s); - sourceChannel->lockRead(); - sourceChannel->unlockRead(); - imageActionPass.disableChannel(i, s); -// std::cout << "imageActionPass.disableChannel " << i << std::endl; - return true; - } - else - { - if (singleChannelProcessing()) - { - logMessage("update action 5 i:" +str(i)); - deChannel* sourceChannel = channelManager.getChannel(s); - if (sourceChannel) - { - imageActionPass.enableChannel(i); -// std::cout << "imageActionPass.enableChannel " << i << std::endl; - int c = imageActionPass.getChannelIndex(i); - deChannel* channel = channelManager.getChannel(c); - logMessage("update action 6 i:" +str(i)); - - if (channel) - { - logMessage("update action 7 i:" +str(i)); - channel->lockWrite(); - logMessage("update action 8 i:" +str(i)); - sourceChannel->lockRead(); - logMessage("update action 9 i:" +str(i)); - - actionResult = processAction(i, *sourceChannel, *channel, channelManager.getChannelSize()); - - logMessage("update action 10 i:" +str(i)); - - sourceChannel->unlockRead(); - channel->unlockWrite(); - } - } - } - else - { - logMessage("update action 999 i:" +str(i)); - int s1 = sourceImage.getChannelIndex(0); - int s2 = sourceImage.getChannelIndex(1); - int s3 = sourceImage.getChannelIndex(2); - int s4 = sourceImage.getChannelIndex(3); - - deChannel* sc1 = channelManager.getChannel(s1); - deChannel* sc2 = channelManager.getChannel(s2); - deChannel* sc3 = channelManager.getChannel(s3); - deChannel* sc4 = channelManager.getChannel(s4); - - imageActionPass.enableChannel(i); - int c = imageActionPass.getChannelIndex(i); - deChannel* channel = channelManager.getChannel(c); - - if (channel) - { - if (sc1) - { - sc1->lockRead(); - } - if (sc2) - { - sc2->lockRead(); - } - if (sc3) - { - sc3->lockRead(); - } - if (sc4) - { - sc4->lockRead(); - } - channel->lockWrite(); - - actionResult = processAction4(i, sc1, sc2, sc3, sc4, *channel, channelSize); - - channel->unlockWrite(); - - if (sc1) - { - sc1->unlockRead(); - } - if (sc2) - { - sc2->unlockRead(); - } - if (sc3) - { - sc3->unlockRead(); - } - if (sc4) - { - sc4->unlockRead(); - } - } - } - } - - logMessage("update action end i:" +str(i)); - - return actionResult; - -} - -void deActionLayer::updateChannelUsage(std::map& channelUsage) const -{ - if (!enabled) - { - return; - } - - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - sourceImage.updateChannelUsage(channelUsage, index); - - imageActionPass.updateChannelUsage(channelUsage, index); - - if (isBlendingEnabled()) - { - imageBlendPass.updateChannelUsage(channelUsage, index); - } - - if (applyMode != deApplyLuminanceAndColor) - { - imageApplyPass.updateChannelUsage(channelUsage, index); - } - - if (blendMask) - { - deLayer* l = layerStack.getLayer(blendMaskLayer); - const deImage& im = l->getImage(); - im.updateChannelUsage(channelUsage, index); - } -} - -void deActionLayer::setBlendMask(int l, int c) -{ - blendMaskLayer = l; - blendMaskChannel = c; - blendMask = true; -} - -void deActionLayer::disableBlendMask() -{ - blendMask = false; -} - -deColorSpace deActionLayer::getBlendMaskLayerColorSpace() const -{ - deLayer* maskLayer = layerStack.getLayer(blendMaskLayer); - const deImage& maskImage = maskLayer->getImage(); - return maskImage.getColorSpace(); -} - -bool deActionLayer::renderBlendMask() -{ - logMessage("render blend mask"); - - enableBlendMaskChannel(); - - deLayer* maskLayer = layerStack.getLayer(blendMaskLayer); - const deImage& maskImage = maskLayer->getImage(); - int m = maskImage.getChannelIndex(blendMaskChannel); - deChannel* maskChannel = channelManager.getChannel(m); - if (!maskChannel) - { - return true; - } - - maskChannel->lockRead(); - - deValue* maskPixels = maskChannel->getPixels(); - - deChannel* allocatedMaskChannel = channelManager.getChannel(imageBlendMask.getChannelIndex(0)); - - allocatedMaskChannel->lockWrite(); - - deValue* allocatedMaskPixels = allocatedMaskChannel->getPixels(); - - deBlurType type = deGaussianBlur; - deValue t= 0.0; - - if (blendBlurRadius <= 0) - { - copyChannel(maskChannel->getPixels(), allocatedMaskChannel->getPixels(), channelManager.getChannelSize()); - } - else - { - deValue r = viewManager.getRealScale() * blendBlurRadius; - bool result = blurChannel(maskPixels, allocatedMaskPixels, channelManager.getChannelSize(), r, r, type, t); - if (!result) - { - return false; - } - } - - processLinear(allocatedMaskPixels, allocatedMaskPixels, channelManager.getChannelSize().getN(), blendMaskMin, blendMaskMax, false); - - allocatedMaskChannel->unlockWrite(); - maskChannel->unlockRead(); - - logMessage("render blend mask done"); - - return true; - -} - -void deActionLayer::showBlendMask() -{ - blendMaskShow = true; -} - -void deActionLayer::hideBlendMask() -{ - blendMaskShow = false; -} - -void deActionLayer::setBlendMaskMin(deValue v) -{ - blendMaskMin = v; -} - -void deActionLayer::setBlendMaskMax(deValue v) -{ - blendMaskMax = v; -} - -bool deActionLayer::isChannelEnabled(int index) const -{ - return channels.count(index) > 0; -} - -void deActionLayer::enableChannel(int index) -{ - channels.insert(index); -} - -void deActionLayer::disableChannel(int index) -{ - channels.erase(index); -} - -void deActionLayer::saveBlend(xmlNodePtr root) -{ - saveChild(root, "enabled", str(enabled)); - saveChild(root, "blend_mode", getBlendModeName(blendMode)); - saveChild(root, "opacity", str(opacity)); - saveChild(root, "blend_mask", str(blendMask)); - saveChild(root, "blend_mask_layer", str(blendMaskLayer)); - saveChild(root, "blend_mask_channel", str(blendMaskChannel)); - saveChild(root, "blend_blur_radius", str(blendBlurRadius)); - saveChild(root, "blend_mask_min", str(blendMaskMin)); - saveChild(root, "blend_mask_max", str(blendMaskMax)); - - std::string apply = "normal"; - if (applyMode == deApplyLuminance) - { - apply = "luminance"; - } - if (applyMode == deApplyColor) - { - apply = "color"; - } - saveChild(root, "apply", apply); - - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - bool c = isChannelEnabled(i); - saveChild(root, "channel", str(c)); - } -} - -void deActionLayer::loadBlend(xmlNodePtr root) -{ - xmlNodePtr child = root->xmlChildrenNode; - - int channelIndex = 0; - channels.clear(); - - while (child) - { - - if ((!xmlStrcmp(child->name, BAD_CAST("channel")))) - { - bool c = getBool(getContent(child)); - if (c) - { - channels.insert(channelIndex); - } - channelIndex++; - } - - if ((!xmlStrcmp(child->name, BAD_CAST("enabled")))) - { - enabled = getBool(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mode")))) - { - blendMode = blendModeFromString(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mask")))) - { - blendMask = getBool(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("opacity")))) - { - opacity = getValue(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_blur_radius")))) - { - blendBlurRadius = getValue(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mask_min")))) - { - blendMaskMin = getValue(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mask_max")))) - { - blendMaskMax = getValue(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mask_layer")))) - { - blendMaskLayer = getInt(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("blend_mask_channel")))) - { - blendMaskChannel = getInt(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("apply")))) - { - std::string apply = getContent(child); - applyMode = deApplyLuminanceAndColor; - if (apply == "luminance") - { - applyMode = deApplyLuminance; - } - if (apply == "color") - { - applyMode = deApplyColor; - } - } - - - child = child->next; - - } - -} - -bool deActionLayer::updateActionOnThread(int i) -{ - return updateAction(i); -} - -void deActionLayer::updateBlendOnThread(int i) -{ - updateBlend(i); -} - - -void deActionLayer::processChannel(int channel) -{ - updateImageInActionLayer(true, true, channel); -} - -void deActionLayer::processBlend() -{ -// std::cout << "processBlend :(" << std::endl; - updateImageInActionLayer(false, true, -1); -} - -void deActionLayer::setError() -{ - errorOnUpdate = true; -} - -void deActionLayer::setHistogramChannel(int channel) -{ - viewManager.setHistogramChannel(channel); -} - diff -Nru delaboratory-0.7/src/action_layer.h delaboratory-0.8/src/action_layer.h --- delaboratory-0.7/src/action_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/action_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_ACTION_LAYER_H -#define _DE_ACTION_LAYER_H - -#include "layer.h" -#include "blend_mode.h" -#include "size.h" -#include "image.h" -#include "channel.h" -class deLayerStack; -class deChannelManager; -class deViewManager; -#include - -enum deApplyMode -{ - deApplyLuminance, - deApplyColor, - deApplyLuminanceAndColor -}; - -class deActionLayer:public deLayer -{ - private: - - bool enabled; - - std::set channels; - - deBlendMode blendMode; - deValue opacity; - - deApplyMode applyMode; - - bool blendMask; - bool blendMaskShow; - - int blendMaskLayer; - int blendMaskChannel; - - deValue blendBlurRadius; - deValue blendMaskMin; - deValue blendMaskMax; - - bool errorOnUpdate; - - virtual bool hasAction() const {return true;}; - virtual bool hasBlending() const {return true;}; - virtual bool canDisable() const {return true;}; - - virtual bool simpleActionProcessing() const {return false;}; - - virtual const deImage& getSourceImage() const; - - virtual bool isEnabled() const; - virtual void setEnabled(bool e); - - virtual const deImage& getImage() const; - - virtual bool isChannelNeutral(int index) = 0; - - bool updateAction(int i); - - bool renderBlendMask(); - - bool isBlendingEnabled() const; - - bool updateActionAllChannels(); - bool updateBlendAllChannels(); - - protected: - deLayerStack& layerStack; - - private: - - deChannelManager& channelManager; - - protected: - deViewManager& viewManager; - - deImage imageActionPass; - - deImage imageBlendMask; - - void disableNotLuminance(); - - private: - deImage imageApplyPass; - - deImage imageBlendPass; - - bool updateBlend(int i); - bool updateApply(); - - virtual bool processAction(int i) {return false;}; - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) {return false;}; - virtual bool processAction4(int i, const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& channel, int channelSize) {return false;}; - - virtual bool singleChannelProcessing() const = 0; - - virtual bool updateImage(); - - public: - deActionLayer(const std::string& _name, deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager); - virtual ~deActionLayer(); - - deChannel* getSourceChannel(int index); - deSize getChannelSize() const; - void setOpacity(deValue _alpha); - void setBlendMode(deBlendMode mode); - deBlendMode getBlendMode() const {return blendMode;}; - deApplyMode getApplyMode() const {return applyMode;}; - void setApplyMode(deApplyMode mode); - deValue getOpacity(); - - deColorSpace getBlendMaskLayerColorSpace() const; - - virtual void updateChannelUsage(std::map& channelUsage) const; - - deViewManager& getViewManager() {return viewManager;}; - - void showBlendMask(); - void hideBlendMask(); - void setBlendMask(int l, int c); - void disableBlendMask(); - int getAllocatedBlendMaskChannel() const {return imageBlendMask.getChannelIndex(0);}; - - void enableBlendMaskChannel(); - void disableBlendMaskChannel(); - - deValue getBlendBlurRadius() const {return blendBlurRadius;}; - void setBlendBlurRadius(deValue r); - void tryRenderBlendMask(); - bool isBlendMaskEnabled() const {return blendMask;}; - bool isBlendMaskVisible() const {return blendMaskShow;}; - - int getBlendMaskLayer() const {return blendMaskLayer;}; - int getBlendMaskChannel() const {return blendMaskChannel;}; - - void setBlendMaskMin(deValue v); - void setBlendMaskMax(deValue v); - - deValue getBlendMaskMin() const {return blendMaskMin;}; - deValue getBlendMaskMax() const {return blendMaskMax;}; - - bool isChannelEnabled(int index) const; - void enableChannel(int index); - void disableChannel(int index); - - virtual void loadBlend(xmlNodePtr root); - virtual void saveBlend(xmlNodePtr root); - - bool updateImageInActionLayer(bool action, bool blend, int channel); - bool updateActionOnThread(int i); - void updateBlendOnThread(int i); - - virtual void processChannel(int channel); - virtual void processBlend(); - - void setError(); - - void setHistogramChannel(int channel); - - -}; - -#endif diff -Nru delaboratory-0.7/src/apply_image_frame.cc delaboratory-0.8/src/apply_image_frame.cc --- delaboratory-0.7/src/apply_image_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_image_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "apply_image_frame.h" -#include "apply_image_layer.h" -#include "property_choice_ui.h" -#include "property_boolean_ui.h" -#include "layer_processor.h" - -deApplyImageFrame::deApplyImageFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - deApplyImageLayer& applyImageLayer = dynamic_cast(layer); - - wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - appliedLayer = new dePropertyChoiceUI(this, applyImageLayer.getAppliedLayer(), applyImageLayer, layerProcessor); - mainSizer->Add(appliedLayer); - - applySingleChannel = new dePropertyBooleanUI(this, applyImageLayer.getApplySingleChannel(), applyImageLayer, layerProcessor); - mainSizer->Add(applySingleChannel); - - int i; - for (i = 0; i < 4; i++) - { - int style = 0; - if (i == 0) - { - style = wxRB_GROUP; - } - wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); - mainSizer->Add(b, 0); - channels[i] = b; - } - - setChannels(); - - Fit(); - - Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deApplyImageFrame::select)); -} - -deApplyImageFrame::~deApplyImageFrame() -{ -} - -void deApplyImageFrame::select(wxCommandEvent &event) -{ - deApplyImageLayer& applyImageLayer = dynamic_cast(layer); - - int i = event.GetId(); - int j; - for (j = 0; j < 4; j++) - { - if (channels[j]->GetId() == i) - { - applyImageLayer.setAppliedChannel(j); - } - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} - -void deApplyImageFrame::setChannels() -{ - deApplyImageLayer& applyImageLayer = dynamic_cast(layer); - - deColorSpace colorSpace = applyImageLayer.getAppliedColorSpace(); - int n = getColorSpaceSize(colorSpace); - int s = applyImageLayer.getAppliedChannel(); - int i; - for (i = 0; i < 4; i++) - { - if (i < n) - { - std::string name = getChannelName(colorSpace, i); - channels[i]->SetLabel(wxString::FromAscii(name.c_str())); - channels[i]->Show(); - } - else - { - channels[i]->Hide(); - } - if (applyImageLayer.isSingleChannel()) - { - channels[i]->Enable(); - } - else - { - channels[i]->Disable(); - } - if (i == s) - { - channels[i]->SetValue(1); - } - } -} - -void deApplyImageFrame::onUpdateProperties() -{ - setChannels(); -} - diff -Nru delaboratory-0.7/src/apply_image_frame.h delaboratory-0.8/src/apply_image_frame.h --- delaboratory-0.7/src/apply_image_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_image_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_APPLY_IMAGE_FRAME_H -#define _DE_APPLY_IMAGE_FRAME_H - -#include "action_frame.h" -class dePropertyChoiceUI; -class dePropertyBooleanUI; -class deLayerProcessor; - -class deApplyImageFrame:public deActionFrame -{ - private: - dePropertyChoiceUI* appliedLayer; - dePropertyBooleanUI* applySingleChannel; - wxChoice* layerChoice; - wxRadioButton* channels[4]; - deLayerProcessor& layerProcessor; - - void select(wxCommandEvent &event); - - void setChannels(); - - public: - deApplyImageFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deApplyImageFrame(); - - virtual void onUpdateProperties(); - -}; - - -#endif diff -Nru delaboratory-0.7/src/apply_image_layer.cc delaboratory-0.8/src/apply_image_layer.cc --- delaboratory-0.7/src/apply_image_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_image_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "apply_image_layer.h" -#include "layer_stack.h" -#include "channel_manager.h" -#include "xml.h" -#include "str.h" -#include "frame_factory.h" - -deApplyImageLayer::deApplyImageLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager), -appliedLayer("applied_layer"), -applySingleChannel("apply_single_channel") -{ - appliedChannel = 0; - applySingleChannel.set(false); - - std::vector& choices = appliedLayer. getChoices(); - unsigned int i; - for (i = 0; i < index; i++) - { - choices.push_back(str(i)); - } - - appliedLayer.setIndex(index - 1); - -} - -deApplyImageLayer::~deApplyImageLayer() -{ -} - -bool deApplyImageLayer::processAction(int i) -{ - int a = getInt(appliedLayer.get()); - deLayer* applied = layerStack.getLayer(a); - if (!applied) - { - return false; - } - const deImage& appliedImage = applied->getImage(); - int n = getColorSpaceSize(appliedImage.getColorSpace()); - - int c = -1 ; - - if (applySingleChannel.get()) - { - c = appliedImage.getChannelIndex(appliedChannel); - } - else - { - if (i < n) - { - c = appliedImage.getChannelIndex(i); - } - else - { - c = appliedImage.getChannelIndex(0); - } - } - - imageActionPass.disableChannel(i, c); - - return true; -} - -deColorSpace deApplyImageLayer::getAppliedColorSpace() -{ - int a = getInt(appliedLayer.get()); - deLayer* applied = layerStack.getLayer(a); - if (!applied) - { - return deColorSpaceInvalid; - } - const deImage& appliedImage = applied->getImage(); - return appliedImage.getColorSpace(); -} - -bool deApplyImageLayer::isChannelNeutral(int index) -{ - return false; -} - -void deApplyImageLayer::setAppliedChannel(int c) -{ - appliedChannel = c; -} - -void deApplyImageLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - - appliedLayer.save(root); - applySingleChannel.save(root); - - saveChild(root, "applied_channel", str(appliedChannel)); -} - -void deApplyImageLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - - appliedLayer.load(child); - applySingleChannel.load(child); - - if ((!xmlStrcmp(child->name, BAD_CAST("applied_channel")))) - { - appliedChannel = getValue(getContent(child)); - } - - child = child->next; - - } -} - -bool deApplyImageLayer::isSingleChannel() const -{ - return applySingleChannel.get(); -} diff -Nru delaboratory-0.7/src/apply_image_layer.h delaboratory-0.8/src/apply_image_layer.h --- delaboratory-0.7/src/apply_image_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_image_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_APPLY_IMAGE_LAYER_H -#define _DE_APPLY_IMAGE_LAYER_H - -#include "action_layer.h" -#include "property_choice.h" -#include "property_boolean.h" - -class deApplyImageLayer:public deActionLayer -{ - private: - dePropertyChoice appliedLayer; - dePropertyBoolean applySingleChannel; - int appliedChannel; - - virtual bool simpleActionProcessing() const {return true;}; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "apply_image";}; - virtual std::string getLabel() const {return "apply image";}; - - public: - deApplyImageLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deApplyImageLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i); - - bool isSingleChannel() const; - - void setAppliedChannel(int c); - - dePropertyChoice& getAppliedLayer() {return appliedLayer;}; - dePropertyBoolean& getApplySingleChannel() {return applySingleChannel;}; - - int getAppliedChannel() const {return appliedChannel;}; - - deColorSpace getAppliedColorSpace(); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "setup";}; - - virtual bool randomize() {return false;}; - - -}; - -#endif diff -Nru delaboratory-0.7/src/apply_luminance_color.cc delaboratory-0.8/src/apply_luminance_color.cc --- delaboratory-0.7/src/apply_luminance_color.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_luminance_color.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "apply_luminance_color.h" -#include "rgb2xyz2lab.h" - -void applyLuminance(deValue r1, deValue g1, deValue b1, deValue r2, deValue g2, deValue b2, deValue &r, deValue &g, deValue &b) -{ - deValue x1; - deValue y1; - deValue z1; - rgb2xyz(r1, g1, b1, x1, y1, z1); - - deValue lab_l1; - deValue lab_a1; - deValue lab_b1; - xyz2lab(x1, y1, z1, lab_l1, lab_a1, lab_b1); - - deValue x2; - deValue y2; - deValue z2; - rgb2xyz(r2, g2, b2, x2, y2, z2); - - deValue lab_l2; - deValue lab_a2; - deValue lab_b2; - xyz2lab(x2, y2, z2, lab_l2, lab_a2, lab_b2); - - deValue x; - deValue y; - deValue z; - lab2xyz(lab_l2, lab_a1, lab_b1, x, y, z); - - xyz2rgb(x, y, z, r, g, b); - - if (r < 0.0) - { - r = 0.0; - } - if (r > 1.0) - { - r = 1.0; - } - if (g < 0.0) - { - g = 0.0; - } - if (g > 1.0) - { - g = 1.0; - } - if (b < 0.0) - { - b = 0.0; - } - if (b > 1.0) - { - b = 1.0; - } -} - -void applyColor(deValue r1, deValue g1, deValue b1, deValue r2, deValue g2, deValue b2, deValue &r, deValue &g, deValue &b) -{ - deValue x1; - deValue y1; - deValue z1; - rgb2xyz(r1, g1, b1, x1, y1, z1); - - deValue lab_l1; - deValue lab_a1; - deValue lab_b1; - xyz2lab(x1, y1, z1, lab_l1, lab_a1, lab_b1); - - deValue x2; - deValue y2; - deValue z2; - rgb2xyz(r2, g2, b2, x2, y2, z2); - - deValue lab_l2; - deValue lab_a2; - deValue lab_b2; - xyz2lab(x2, y2, z2, lab_l2, lab_a2, lab_b2); - - deValue x; - deValue y; - deValue z; - lab2xyz(lab_l1, lab_a2, lab_b2, x, y, z); - - xyz2rgb(x, y, z, r, g, b); - - if (r < 0.0) - { - r = 0.0; - } - if (r > 1.0) - { - r = 1.0; - } - if (g < 0.0) - { - g = 0.0; - } - if (g > 1.0) - { - g = 1.0; - } - if (b < 0.0) - { - b = 0.0; - } - if (b > 1.0) - { - b = 1.0; - } -} diff -Nru delaboratory-0.7/src/apply_luminance_color.h delaboratory-0.8/src/apply_luminance_color.h --- delaboratory-0.7/src/apply_luminance_color.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/apply_luminance_color.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_APPLY_LUMINANCE_COLOR_H -#define _DE_APPLY_LUMINANCE_COLOR_H - -#include "value.h" - -// these functions are only for RGB colorspace -// for other colorspaces new functions are needed, but they are very easy to implement - -void applyLuminance(deValue r1, deValue g1, deValue b1, deValue r2, deValue g2, deValue b2, deValue &r, deValue &g, deValue &b); -void applyColor(deValue r1, deValue g1, deValue b1, deValue r2, deValue g2, deValue b2, deValue &r, deValue &g, deValue &b); - -#endif diff -Nru delaboratory-0.7/src/basic_frame.cc delaboratory-0.8/src/basic_frame.cc --- delaboratory-0.7/src/basic_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "basic_frame.h" -#include "basic_layer.h" -#include -#include "property_value_slider.h" -#include "layer_processor.h" - -deBasicFrame::deBasicFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deBasicLayer& basicLayer = dynamic_cast(_layer); - - int n = basicLayer.getNumberOfSettings(); - int s = basicLayer.getSeparator(); - - int range = 400; - - wxSizer* sizerS = NULL; - - wxSizer* sizerS1 = new wxStaticBoxSizer(wxVERTICAL, this, _T("primary settings")); - sizer->Add(sizerS1); - - sizerS = sizerS1; - - int i; - for (i = 0; i < n; i++) - { - if (i == s) - { - wxSizer* sizerS2 = new wxStaticBoxSizer(wxVERTICAL, this, _T("secondary settings")); - sizer->Add(sizerS2); - sizerS = sizerS2; - } - - dePropertyValue* p = basicLayer.getBasicProperty(i); - - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, basicLayer, layerProcessor); - basicSliders.push_back(s); - sizerS->Add(s); - } - } - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(reset, 0); - - -/* - int range = 400; - - radius = new dePropertyValueSlider(this, range, basicLayer.getPropertyRadius(), basicLayer, layerProcessor); - sizer->Add(radius); - - amount = new dePropertyValueSlider(this, range, basicLayer.getPropertyAmount(), basicLayer, layerProcessor); - sizer->Add(amount); - - threshold = new dePropertyValueSlider(this, range, basicLayer.getPropertyThreshold(), basicLayer, layerProcessor); - sizer->Add(threshold); - - - - sharp = new wxButton(this, wxID_ANY, _T("sharp"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(sharp, 0); - - hiraloam1 = new wxButton(this, wxID_ANY, _T("hiraloam 1"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(hiraloam1, 0); - - hiraloam2 = new wxButton(this, wxID_ANY, _T("hiraloam 2"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(hiraloam2, 0); - - */ - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deBasicFrame::click)); -} - -deBasicFrame::~deBasicFrame() -{ -} - -void deBasicFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deBasicLayer& basicLayer = dynamic_cast(layer); - - - if (reset->GetId() == id) - { - basicLayer.reset(); - } - - std::vector::iterator i; - for (i = basicSliders.begin(); i != basicSliders.end(); i++) - { - (*i)->setFromProperty(); - } - - /* - - if (sharp->GetId() == id) - { - basicLayer.sharp(); - } - - if (hiraloam1->GetId() == id) - { - basicLayer.hiraloam1(); - } - - if (hiraloam2->GetId() == id) - { - basicLayer.hiraloam2(); - } - - radius->setFromProperty(); - amount->setFromProperty(); - threshold->setFromProperty(); - - */ - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/basic_frame.h delaboratory-0.8/src/basic_frame.h --- delaboratory-0.7/src/basic_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BASIC_FRAME_H -#define _DE_BASIC_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include - -class dePropertyValueSlider; -class deLayerProcessor; - -class deBasicFrame:public deActionFrame -{ - private: - std::vector basicSliders; - - deLayerProcessor& layerProcessor; - - wxButton* reset; - - void click(wxCommandEvent &event); - - public: - deBasicFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deBasicFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/basic_layer.cc delaboratory-0.8/src/basic_layer.cc --- delaboratory-0.7/src/basic_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "basic_layer.h" -#include "process_linear.h" - -deBasicLayer::deBasicLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - getBasicSettings(colorSpace, settings1, settings2); - - std::copy(settings1.begin(), settings1.end(), std::back_inserter(settings)); - std::copy(settings2.begin(), settings2.end(), std::back_inserter(settings)); - - int n = settings.size(); - int i; - for (i = 0; i < n; i++) - { - deBasicSetting& setting = settings[i]; - std::string n = setting.getName(); - dePropertyValue* p = new dePropertyValue(n); - p->setMin(-1.0); - p->setMax(1.0); - int c = setting.getChannel(); - if (c >= 0) - { - p->setChannel(c); - } - basicProperties.push_back(p); - } - - int nn = getColorSpaceSize(colorSpace); - curves = new deCurve[nn]; - - shiftIndex = -1; - shiftValue = 0.0; - - int j; - for (j = 0; j < n; j++) - { - deBasicSetting& s = settings[j]; - if (s.isShift()) - { - for (i = 0; i < nn; i++) - { - if (s.affects(i)) - { - shiftIndex = i; - } - } - } - } -} - -deBasicLayer::~deBasicLayer() -{ - int n = settings.size(); - int i; - for (i = 0; i < n; i++) - { - dePropertyValue* p = basicProperties[i]; - delete p; - } - - delete [] curves; -} - -bool deBasicLayer::isChannelNeutral(int index) -{ - return false; -} - -void deBasicLayer::reset() -{ - int nn = settings.size(); - int j; - for (j = 0; j < nn; j++) - { - basicProperties[j]->set(0.0); - } -} - -void deBasicLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); -} - -void deBasicLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - child = child->next; - } -} - -void deBasicLayer::updateCurve(int i) -{ - deValue brightness = 0.0; - deValue contrast = 0.0; - - int n = settings.size(); - int j; - for (j = 0; j < n; j++) - { - deBasicSetting& s = settings[j]; - if (s.affects(i)) - { - deValue scale = s.getScale(); - dePropertyValue* p = basicProperties[j]; - if (s.isContrast()) - { - contrast += scale * p->get(); - } - if (s.isBrightness()) - { - brightness += scale * p->get(); - } - } - } - - curves[i].setContrastBrightness(contrast, brightness); -} - -bool deBasicLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - if (i == shiftIndex) - { - shiftChannel(sourceChannel.getPixels(), channel.getPixels(), shiftValue, size.getN()); - } - else - { - curves[i].process(sourceChannel, channel, size.getN()); - } - - return true; -} - - - -bool deBasicLayer::randomize() -{ - return true; -} - -int deBasicLayer::getNumberOfSettings() -{ - int n = settings.size(); - return n; -} - -int deBasicLayer::getSeparator() -{ - int n = settings1.size(); - return n; -} - -dePropertyValue* deBasicLayer::getBasicProperty(int n) -{ - dePropertyValue* p = basicProperties[n]; - return p; -} - -void deBasicLayer::onUpdateProperties() -{ - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - updateCurve(i); - } - - int nn = settings.size(); - int j; - for (j = 0; j < nn; j++) - { - deBasicSetting& s = settings[j]; - if (s.isShift()) - { - shiftValue = basicProperties[j]->get(); - } - } -} diff -Nru delaboratory-0.7/src/basic_layer.h delaboratory-0.8/src/basic_layer.h --- delaboratory-0.7/src/basic_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BASIC_LAYER_H -#define _DE_BASIC_LAYER_H - -#include "action_layer.h" -#include "property_value.h" -#include "curve.h" - -class deBasicLayer:public deActionLayer -{ - private: - std::vector settings1; - std::vector settings2; - std::vector settings; - std::vector basicProperties; - deCurve* curves; - int shiftIndex; - deValue shiftValue; - - void updateCurve(int i); - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "basic";}; - virtual std::string getLabel() const {return "basic settings";}; - - public: - deBasicLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deBasicLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "setup";}; - - int getNumberOfSettings(); - int getSeparator(); - dePropertyValue* getBasicProperty(int n); - - virtual bool randomize(); - - - virtual void onUpdateProperties(); - - void reset(); - -}; - -#endif diff -Nru delaboratory-0.7/src/basic_setting.cc delaboratory-0.8/src/basic_setting.cc --- delaboratory-0.7/src/basic_setting.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_setting.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "basic_setting.h" - -deBasicSetting::deBasicSetting(const std::string& _name) -:name(_name) -{ - contrast = false; - brightness = false; - shift = false; - scale = 1.0; -} - -deBasicSetting::~deBasicSetting() -{ -} - - -void deBasicSetting::setScale(deValue _scale) -{ - scale = _scale; -} - -deValue deBasicSetting::getScale() const -{ - return scale; -} - -void deBasicSetting::addChannel(int c) -{ - channels.insert(c); -} - -void deBasicSetting::setContrast() -{ - contrast = true; -} - -void deBasicSetting::setBrightness() -{ - brightness = true; -} - -void deBasicSetting::setShift() -{ - shift = true; -} - -bool deBasicSetting::affects(int c) const -{ - if (channels.count(c) == 1) - { - return true; - } - else - { - return false; - } -} - -int deBasicSetting::getChannel() const -{ - if (channels.size() != 1) - { - return -1; - } - std::set::const_iterator i = channels.begin(); - return *i; -} diff -Nru delaboratory-0.7/src/basic_setting.h delaboratory-0.8/src/basic_setting.h --- delaboratory-0.7/src/basic_setting.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/basic_setting.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BASIC_SETTING_H -#define _DE_BASIC_SETTING_H - -#include -#include -#include "value.h" - -class deBasicSetting -{ - private: - std::string name; - std::set channels; - bool contrast; - bool brightness; - bool shift; - - deValue scale; - public: - deBasicSetting(const std::string& _name); - virtual ~deBasicSetting(); - - void setContrast(); - void setBrightness(); - void setShift(); - - void setScale(deValue _scale); - deValue getScale() const; - - void addChannel(int c); - - std::string getName() const {return name;}; - bool affects(int c) const; - - bool isContrast() const {return contrast;}; - bool isBrightness() const {return brightness;}; - bool isShift() const {return shift;}; - - int getChannel() const; -}; - -#endif diff -Nru delaboratory-0.7/src/benchmark_frame.cc delaboratory-0.8/src/benchmark_frame.cc --- delaboratory-0.7/src/benchmark_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/benchmark_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "benchmark_frame.h" -#include "benchmarks.h" -#include "str.h" - -void deBenchmarkFrame::addBenchmark(const std::string& s, std::string name, int value) -{ - wxStaticText* ls = new wxStaticText(this, wxID_ANY, wxString::FromAscii(s.c_str())); - sizer->Add(ls); - wxStaticText* l = new wxStaticText(this, wxID_ANY, wxString::FromAscii(name.c_str())); - sizer->Add(l); - - wxStaticText* r = new wxStaticText(this, wxID_ANY, _T("")); - - r->SetMinSize(wxSize(100, -1)); - - sizer->Add(r); - results.push_back(r); -} - -void deBenchmarkFrame::addBenchmarkBlur(deSize size, deValue radius, deBlurType type) -{ - std::string name = getBlurTypeName(type) + " r=" + str(radius); - - benchmarks.push_back(new deBenchmarkBlur(size, radius, type)); - int r = 0; - - std::string s = str(size.getW()) + "x" + str(size.getH()); - addBenchmark(s, name, r); -} - -void deBenchmarkFrame::addBenchmarkBlurs( deSize size, deBlurType type) -{ - addBenchmarkBlur(size, 1, type); - addBenchmarkBlur(size, 10, type); - addBenchmarkBlur(size, 50, type); - addBenchmarkBlur(size, 200, type); -} - -void deBenchmarkFrame::addBenchmarkColor(deColorSpace colorSpace) -{ - int size = 10000000; - std::string s = str(size); - int r = 0; - - { - std::string name = "RGB -> " + getColorSpaceName(colorSpace); - benchmarks.push_back(new deBenchmarkColor(size, deColorSpaceRGB, colorSpace)); - addBenchmark(s, name, r); - } - { - std::string name = getColorSpaceName(colorSpace) + " -> RGB"; - benchmarks.push_back(new deBenchmarkColor(size, colorSpace, deColorSpaceRGB)); - addBenchmark(s, name, r); - } -} - -void deBenchmarkFrame::addBenchmarkColor() -{ - std::vector colorSpaces; - - getSupportedColorSpaces(colorSpaces); - unsigned int i; - for (i = 0; i < colorSpaces.size(); i++) - { - deColorSpace colorSpace = colorSpaces[i]; - if (colorSpace != deColorSpaceRGB) - { - addBenchmarkColor(colorSpace); - } - } -} - -deBenchmarkFrame::deBenchmarkFrame(wxWindow *parent, const std::string& type) -:deHelpFrame(parent, "benchmark") -{ - wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - sizer = new wxFlexGridSizer(3, 0, 50); - mainSizer->Add(sizer); - - if (type == "blur") - { - addBenchmarkBlurs(deSize(1024, 1024), deBoxBlur); - addBenchmarkBlurs(deSize(4000, 3000), deBoxBlur); - addBenchmarkBlurs(deSize(1024, 1024), deGaussianBlur); - addBenchmarkBlurs(deSize(4000, 3000), deGaussianBlur); - addBenchmarkBlurs(deSize(1024, 1024), deSurfaceBlur); - addBenchmarkBlurs(deSize(4000, 3000), deSurfaceBlur); - } - if (type == "color") - { - addBenchmarkColor(); - } - - { - wxSizer* totalSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - mainSizer->Add(totalSizer, 0, wxEXPAND); - - wxStaticText* l = new wxStaticText(this, wxID_ANY, _T("total:")); - totalSizer->Add(l, 1, wxEXPAND); - - total = new wxStaticText(this, wxID_ANY, _T("")); - totalSizer->Add(total, 1, wxEXPAND); - } - - Layout(); - Fit(); -} - -deBenchmarkFrame::~deBenchmarkFrame() -{ - unsigned int i; - for (i = 0; i < benchmarks.size(); i++) - { - delete benchmarks[i]; - } -} - -void deBenchmarkFrame::perform() -{ - unsigned int i; - Update(); - Refresh(); - deValue sum = 0.0; - for (i = 0; i < benchmarks.size(); i++) - { - int r = benchmarks[i]->perform(); - int vv = r / 10; - deValue vvv = vv / 100.0; - - sum += vvv; - - results[i]->SetLabel(wxString::FromAscii(str(vvv).c_str())); - - Update(); - Refresh(); - } - total->SetLabel(wxString::FromAscii(str(sum).c_str())); - Update(); - Refresh(); - -} diff -Nru delaboratory-0.7/src/benchmark_frame.h delaboratory-0.8/src/benchmark_frame.h --- delaboratory-0.7/src/benchmark_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/benchmark_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BENCHMARK_FRAME_H -#define _DE_BENCHMARK_FRAME_H - -#include "help_frame.h" -#include "benchmarks.h" - -class deBenchmarkFrame:public deHelpFrame -{ - private: - wxSizer* sizer; - std::vector benchmarks; - std::vector results; - - wxStaticText* total; - - void addBenchmark(const std::string& s, std::string name, int value); - void addBenchmarkBlur(deSize size, deValue radius, deBlurType type); - void addBenchmarkBlurs( deSize size, deBlurType type); - void addBenchmarkColor(); - void addBenchmarkColor(deColorSpace colorSpace); - - public: - deBenchmarkFrame(wxWindow *parent, const std::string& type); - virtual ~deBenchmarkFrame(); - - void perform(); - -}; - -#endif diff -Nru delaboratory-0.7/src/benchmarks.cc delaboratory-0.8/src/benchmarks.cc --- delaboratory-0.7/src/benchmarks.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/benchmarks.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "benchmarks.h" -#include -#include "conversion_functions.h" - -int benchmarkBlur(deSize size, deValue radius, deBlurType type) -{ - deValue* channel1 = new deValue[size.getN()]; - deValue* channel2 = new deValue[size.getN()]; - - int i; - int n = size.getN(); - - for (i = 0; i < n; i++) - { - channel1[i] = (deValue) rand() / RAND_MAX; - } - - int t; - { - wxStopWatch sw; - - blurChannel(channel1, channel2, size, radius, radius, type, 0.1); - - t = sw.Time(); - } - - delete [] channel1; - delete [] channel2; - - return t; -} - - -deBenchmark::deBenchmark() -{ -} - -deBenchmark::~deBenchmark() -{ -} - -deBenchmarkBlur::deBenchmarkBlur(deSize _size, deValue _radius, deBlurType _type) -:size(_size), radius(_radius), type(_type) -{ -} - -deBenchmarkBlur::~deBenchmarkBlur() -{ -} - -int deBenchmarkBlur::perform() -{ - return benchmarkBlur(size, radius, type); -} - -deBenchmarkColor::deBenchmarkColor(int _size, deColorSpace _src, deColorSpace _dst) -:size(_size), src(_src), dst(_dst) -{ -} - -deBenchmarkColor::~deBenchmarkColor() -{ -} - -int deBenchmarkColor::perform() -{ - deValue* s1 = new deValue[size]; - deValue* s2 = new deValue[size]; - deValue* s3 = new deValue[size]; - deValue* s4 = new deValue[size]; - - deValue* d1 = new deValue[size]; - deValue* d2 = new deValue[size]; - deValue* d3 = new deValue[size]; - deValue* d4 = new deValue[size]; - - int i; - for (i = 0; i < size; i++) - { - s1[i] = (deValue) rand() / RAND_MAX; - s2[i] = (deValue) rand() / RAND_MAX; - s3[i] = (deValue) rand() / RAND_MAX; - s4[i] = (deValue) rand() / RAND_MAX; - } - - int t = -0.666; - - { - wxStopWatch sw; - - - deConversion3x3 conversion3x3 = getConversion3x3(src, dst); - if (conversion3x3) - { - for (i = 0; i < size; i++) - { - conversion3x3(s1[i], s2[i], s3[i], d1[i], d2[i], d3[i]); - } - } - - deConversion3x1 conversion3x1 = getConversion3x1(src, dst); - if (conversion3x1) - { - for (i = 0; i < size; i++) - { - conversion3x1(s1[i], s2[i], s3[i], d1[i]); - } - } - - deConversion1x3 conversion1x3 = getConversion1x3(src, dst); - if (conversion1x3) - { - for (i = 0; i < size; i++) - { - conversion1x3(s1[i], d1[i], d2[i], d3[i]); - } - } - - deConversion3x4 conversion3x4 = getConversion3x4(src, dst); - if (conversion3x4) - { - for (i = 0; i < size; i++) - { - conversion3x4(s1[i], s2[i], s3[i], d1[i], d2[i], d3[i], d4[i]); - } - } - - deConversion4x3 conversion4x3 = getConversion4x3(src, dst); - if (conversion4x3) - { - for (i = 0; i < size; i++) - { - conversion4x3(s1[i], s2[i], s3[i], s4[i], d1[i], d2[i], d3[i]); - } - } - - t = sw.Time(); - } - - delete [] s1; - delete [] s2; - delete [] s3; - delete [] s4; - - delete [] d1; - delete [] d2; - delete [] d3; - delete [] d4; - - return t; -} diff -Nru delaboratory-0.7/src/benchmarks.h delaboratory-0.8/src/benchmarks.h --- delaboratory-0.7/src/benchmarks.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/benchmarks.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BENCHMARKS_H -#define _DE_BENCHMARKS_H - -#include "blur.h" -#include "color_space.h" - -class deBenchmark -{ - private: - public: - deBenchmark(); - virtual ~deBenchmark(); - - virtual int perform() = 0; -}; - -class deBenchmarkBlur:public deBenchmark -{ - private: - deSize size; - deValue radius; - deBlurType type; - public: - deBenchmarkBlur(deSize _size, deValue _radius, deBlurType _type); - virtual ~deBenchmarkBlur(); - - virtual int perform(); -}; - -class deBenchmarkColor:public deBenchmark -{ - private: - int size; - deColorSpace src; - deColorSpace dst; - public: - deBenchmarkColor(int _size, deColorSpace _src, deColorSpace _dst); - virtual ~deBenchmarkColor(); - - virtual int perform(); -}; - -#endif diff -Nru delaboratory-0.7/src/blend_channel.cc delaboratory-0.8/src/blend_channel.cc --- delaboratory-0.7/src/blend_channel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_channel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blend_channel.h" - -void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize) -{ - int j; - if (maskPixels) - { - for (j = 0; j < channelSize; j++) - { - deValue src = sourcePixels[j]; - deValue ov = overlayPixels[j]; - deValue dst = calcBlendResult(src, ov, blendMode); - deValue m = maskPixels[j] * opacity; - deValue result = (1 - m) * src + m * dst; - resultPixels[j] = result; - } - } - else - { - for (j = 0; j < channelSize; j++) - { - deValue src = sourcePixels[j]; - deValue ov = overlayPixels[j]; - deValue dst = calcBlendResult(src, ov, blendMode); - deValue result = (1 - opacity) * src + opacity * dst; - resultPixels[j] = result; - } - } -} - diff -Nru delaboratory-0.7/src/blend_channel.h delaboratory-0.8/src/blend_channel.h --- delaboratory-0.7/src/blend_channel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLEND_CHANNEL_H -#define _DE_BLEND_CHANNEL_H - -#include "value.h" -#include "blend_mode.h" - -void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize); - -#endif diff -Nru delaboratory-0.7/src/blend_frame.cc delaboratory-0.8/src/blend_frame.cc --- delaboratory-0.7/src/blend_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,520 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blend_frame.h" -#include "layer.h" -#include "action_layer.h" -#include "view_manager.h" -#include "layer_processor.h" -#include "layer_frame_manager.h" - -class deAlphaSlider:public deSlider -{ - private: - deActionLayer& layer; - deLayerProcessor& layerProcessor; - - public: - deAlphaSlider(wxWindow *parent, int range, deActionLayer& _layer, deLayerProcessor& _layerProcessor) - :deSlider(parent, "opacity", range, 0.0, 1.0, 1.0), layer(_layer), - layerProcessor(_layerProcessor) - { - setValue(layer.getOpacity()); - } - - virtual ~deAlphaSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - //if (finished) - { - layer.setOpacity(value); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - } - } -}; - -class deBlurRadiusSlider:public deSlider -{ - private: - deActionLayer& layer; - deLayerProcessor& layerProcessor; - - public: - deBlurRadiusSlider(wxWindow *parent, int range, deActionLayer& _layer, deLayerProcessor& _layerProcessor) - :deSlider(parent, "blur radius", range, 0.0, 50, 0.0), layer(_layer), - layerProcessor(_layerProcessor) - { - setValue(layer.getBlendBlurRadius()); - } - - virtual ~deBlurRadiusSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - if ((finished) || (layerProcessor.isRealtime())) - { - layer.setBlendBlurRadius(value); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - } - } -}; - -class deBlendMaskMinSlider:public deSlider -{ - private: - deActionLayer& layer; - deLayerProcessor& layerProcessor; - - public: - deBlendMaskMinSlider(wxWindow *parent, int range, deActionLayer& _layer, deLayerProcessor& _layerProcessor) - :deSlider(parent, "min", range, 0.0, 1.0, 0.0), layer(_layer), - layerProcessor(_layerProcessor) - { - setValue(layer.getBlendMaskMin()); - } - - virtual ~deBlendMaskMinSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - if ((finished) || (layerProcessor.isRealtime())) - { - layer.setBlendMaskMin(value); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - } - } -}; - -class deBlendMaskMaxSlider:public deSlider -{ - private: - deActionLayer& layer; - deLayerProcessor& layerProcessor; - - public: - deBlendMaskMaxSlider(wxWindow *parent, int range, deActionLayer& _layer, deLayerProcessor& _layerProcessor) - :deSlider(parent, "max", range, 0.0, 1.0, 0.0), layer(_layer), - layerProcessor(_layerProcessor) - { - setValue(layer.getBlendMaskMax()); - } - - virtual ~deBlendMaskMaxSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - if ((finished) || (layerProcessor.isRealtime())) - { - layer.setBlendMaskMax(value); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - } - } -}; - -deBlendFrame::deBlendFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deLayerFrame(parent, _layer, _layer.getName(), _frameManager), - layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deColorSpace colorSpace = layer.getColorSpace(); - if (colorSpace == deColorSpaceRGB) - { - applyAllowed = true; - } - else - { - applyAllowed = false; - } - - //layer.setBlendFrame(this); - frameManager.addBlendFrame(this); - - getSupportedBlendModes(blendModes); - - deActionLayer& l = dynamic_cast(layer); - - deBlendMode currentBlendMode = l.getBlendMode(); - - wxString* blendModeStrings = new wxString [blendModes.size()]; - unsigned int i; - int selectedBlendMode = 0; - for (i = 0; i < blendModes.size(); i++) - { - blendModeStrings[i] = wxString::FromAscii(getBlendModeName(blendModes[i]).c_str()); - if (currentBlendMode == blendModes[i]) - { - selectedBlendMode = i; - } - } - - choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), blendModes.size(), blendModeStrings); - choice->SetSelection(selectedBlendMode); - - delete [] blendModeStrings; - - sizer->Add(choice, 0); - - alphaSlider = new deAlphaSlider(this, 100, l, layerProcessor); - sizer->Add(alphaSlider, 0); - - wxSizer* sizerLC = new wxStaticBoxSizer(wxVERTICAL, this, _T("luminance / color")); - sizer->Add(sizerLC, 0); - - b1 = new wxRadioButton(this, wxID_ANY, _T("apply luminance and color"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); - sizerLC->Add(b1, 0); - - if (applyAllowed) - { - b2 = new wxRadioButton(this, wxID_ANY, _T("apply luminance")); - sizerLC->Add(b2, 0); - b3 = new wxRadioButton(this, wxID_ANY, _T("apply color")); - sizerLC->Add(b3, 0); - deApplyMode applyMode = l.getApplyMode(); - if (applyMode == deApplyLuminance) - { - b2->SetValue(1); - } - if (applyMode == deApplyColor) - { - b3->SetValue(1); - } - } - else - { - b2 = NULL; - b3 = NULL; - } - - wxSizer* sizerC = new wxStaticBoxSizer(wxVERTICAL, this, _T("channels")); - sizer->Add(sizerC, 0); - - unsigned int nc = getColorSpaceSize(colorSpace); - - for (i = 0; i < nc; i++) - { - wxCheckBox* cb = new wxCheckBox(this, wxID_ANY, wxString::FromAscii(getChannelName(colorSpace, i).c_str())); - cb->SetValue(l.isChannelEnabled(i)); - sizerC->Add(cb, 0); - channels.push_back(cb); - } - - wxSizer* sizerM = new wxStaticBoxSizer(wxVERTICAL, this, _T("mask")); - sizer->Add(sizerM, 0); - - wxSizer* sizerMC = new wxBoxSizer(wxHORIZONTAL); - sizerM->Add(sizerMC); - - maskEnable = new wxCheckBox(this, wxID_ANY, _T("enable")); - sizerMC->Add(maskEnable, 0); - if (l.isBlendMaskEnabled()) - { - maskEnable->SetValue(1); - } - - maskShow = new wxCheckBox(this, wxID_ANY, _T("show")); - sizerMC->Add(maskShow, 0); - - deViewManager& viewManager = l.getViewManager(); - - if ((l.isBlendMaskVisible()) && (viewManager.maskVisible())) - { - maskShow->SetValue(1); - } - - unsigned int n = layer.getIndex(); - - wxString* layerStrings = new wxString [n]; - for (i = 0; i < n; i++) - { - layerStrings[i] = wxString::Format(_T("%i"), i); - } - - maskLayerChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), n, layerStrings); - - delete [] layerStrings; - - maskLayerChoice->SetSelection(l.getBlendMaskLayer()); - - sizerM->Add(maskLayerChoice, 0); - - unsigned int s = l.getBlendMaskChannel(); - - for (i = 0; i < 4; i++) - { - long style = 0; - if (i == 0) - { - style = wxRB_GROUP; - } - wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); - sizerM->Add(b, 0); - maskChannels[i] = b; - if (i == s) - { - maskChannels[i]->SetValue(1); - } - } - - blurRadiusSlider = new deBlurRadiusSlider(this, 100, l, layerProcessor); - sizerM->Add(blurRadiusSlider, 0); - - blendMaskMinSlider = new deBlendMaskMinSlider(this, 100, l, layerProcessor); - sizerM->Add(blendMaskMinSlider, 0); - - blendMaskMaxSlider = new deBlendMaskMaxSlider(this, 100, l, layerProcessor); - sizerM->Add(blendMaskMaxSlider, 0); - - setChannels(); - - showHide(); - - Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deBlendFrame::choose)); - Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deBlendFrame::select)); - Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deBlendFrame::check)); - - Fit(); -} - -deBlendFrame::~deBlendFrame() -{ - deActionLayer& l = dynamic_cast(layer); - deViewManager& viewManager = l.getViewManager(); - viewManager.hideThisMask(l.getAllocatedBlendMaskChannel()); - l.hideBlendMask(); - - layerProcessor.onChangeViewMode(); - - frameManager.removeBlendFrame(this); -} - - -void deBlendFrame::choose(wxCommandEvent &event) -{ - deActionLayer& l = dynamic_cast(layer); - - int id = event.GetId(); - if (id == choice->GetId()) - { - int i = event.GetInt(); - deBlendMode& mode = blendModes[i]; - l.setBlendMode(mode); - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - } - else - { - updateMask(); - } -} - -void deBlendFrame::check(wxCommandEvent &event) -{ - deActionLayer& l = dynamic_cast(layer); - int id = event.GetId(); - deColorSpace colorSpace = layer.getColorSpace(); - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - if (channels[i]->GetId() == id) - { - if (channels[i]->IsChecked()) - { - l.enableChannel(i); - } - else - { - l.disableChannel(i); - } - - int l_index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(l_index, i); - - return; - } - } - - updateMask(); -} - -void deBlendFrame::select(wxCommandEvent &event) -{ - deActionLayer& l = dynamic_cast(layer); - int i = event.GetId(); - - if (applyAllowed) - { - if (i == b1->GetId()) - { - l.setApplyMode(deApplyLuminanceAndColor); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - - return; - } - else if (i == b2->GetId()) - { - l.setApplyMode(deApplyLuminance); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - - return; - } - else if (i == b3->GetId()) - { - l.setApplyMode(deApplyColor); - - int index = layer.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); - - return; - } - } - - updateMask(); - -} - -void deBlendFrame::setChannels() -{ - deActionLayer& l = dynamic_cast(layer); - deColorSpace colorSpace = l.getBlendMaskLayerColorSpace(); - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < 4; i++) - { - if (i < n) - { - std::string name = getChannelName(colorSpace, i); - maskChannels[i]->SetLabel(wxString::FromAscii(name.c_str())); - maskChannels[i]->Show(); - } - else - { - maskChannels[i]->Hide(); - } - } - Layout(); -} - -int deBlendFrame::getBlendChannel() -{ - int i; - for (i = 0; i < 4; i++) - { - if (maskChannels[i]->GetValue() == 1) - { - return i; - } - } - return -1; -} - -void deBlendFrame::updateMask() -{ - deActionLayer& l = dynamic_cast(layer); - deViewManager& viewManager = l.getViewManager(); - - int layer = maskLayerChoice->GetSelection(); - int channel = getBlendChannel(); - - if (maskShow->IsChecked()) - { - l.setBlendMask(layer, channel); - l.showBlendMask(); - } - else - { - l.hideBlendMask(); - } - - if (maskEnable->IsChecked()) - { - l.setBlendMask(layer, channel); - } - else - { - l.disableBlendMask(); - } - - //l.onBlendSet(); - - if (maskShow->IsChecked()) - { - viewManager.showMask(l.getAllocatedBlendMaskChannel()); - } - else - { - viewManager.hideMask(); - } - - setChannels(); - showHide(); - - int index = l.getIndex(); - layerProcessor.markUpdateBlendAllChannels(index); -} - -void deBlendFrame::showHide() -{ - deActionLayer& l = dynamic_cast(layer); - int i; - if (l.isBlendMaskEnabled()) - { - maskLayerChoice->Enable(); - for (i = 0; i < 4; i++) - { - maskChannels[i]->Enable(); - } - blurRadiusSlider->Enable(); - blendMaskMinSlider->Enable(); - blendMaskMaxSlider->Enable(); - } - else - { - maskLayerChoice->Disable(); - for (i = 0; i < 4; i++) - { - maskChannels[i]->Disable(); - } - blurRadiusSlider->Disable(); - blendMaskMinSlider->Disable(); - blendMaskMaxSlider->Disable(); - } -} diff -Nru delaboratory-0.7/src/blend_frame.h delaboratory-0.8/src/blend_frame.h --- delaboratory-0.7/src/blend_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLEND_FRAME_H -#define _DE_BLEND_FRAME_H - -#include "layer_frame.h" -#include "blend_mode.h" -#include "slider.h" -class deLayerProcessor; - -class deBlendFrame:public deLayerFrame -{ - private: - bool applyAllowed; - - void choose(wxCommandEvent &event); - void check(wxCommandEvent &event); - void select(wxCommandEvent &event); - - void setChannels(); - - wxChoice* choice; - deSlider* alphaSlider; - deSlider* blurRadiusSlider; - deSlider* blendMaskMinSlider; - deSlider* blendMaskMaxSlider; - wxRadioButton *b1; - wxRadioButton *b2; - wxRadioButton *b3; - wxChoice* maskLayerChoice; - std::vector blendModes; - std::vector channels; - wxRadioButton* maskChannels[4]; - deLayerProcessor& layerProcessor; - - wxCheckBox* maskEnable; - wxCheckBox* maskShow; - - int getBlendChannel(); - - void updateMask(); - - void showHide(); - - public: - deBlendFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deBlendFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/blend_mode.cc delaboratory-0.8/src/blend_mode.cc --- delaboratory-0.7/src/blend_mode.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_mode.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blend_mode.h" -#include - -std::string getBlendModeName(deBlendMode mode) -{ - switch (mode) - { - case deBlendNormal: - return "normal"; - case deBlendMultiply: - return "multiply"; - case deBlendScreen: - return "screen"; - case deBlendOverlay: - return "overlay"; - case deBlendOverlayInvert: - return "overlay invert"; - case deBlendAdd: - return "add"; - case deBlendGrainExtract: - return "graint extract"; - case deBlendGrainMerge: - return "graint merge"; - case deBlendSub: - return "sub"; - case deBlendDifference: - return "difference"; - case deBlendDarken: - return "darken"; - case deBlendLighten: - return "lighten"; - case deBlendDodge: - return "dodge"; - case deBlendBurn: - return "burn"; - default: - return "unknown"; - } -} - -deBlendMode blendModeFromString(const std::string& s) -{ - if (s == "normal") - { - return deBlendNormal; - } - - if (s == "multiply") - { - return deBlendMultiply; - } - - if (s == "screen") - { - return deBlendScreen; - } - - if (s == "overlay") - { - return deBlendOverlay; - } - - if (s == "overlay invert") - { - return deBlendOverlayInvert; - } - - if (s == "add") - { - return deBlendAdd; - } - - if (s == "grain extract") - { - return deBlendGrainExtract; - } - - if (s == "grain merge") - { - return deBlendGrainMerge; - } - - if (s == "sub") - { - return deBlendSub; - } - - if (s == "difference") - { - return deBlendDifference; - } - - if (s == "darken") - { - return deBlendDarken; - } - - if (s == "lighten") - { - return deBlendLighten; - } - - if (s == "dodge") - { - return deBlendDodge; - } - - if (s == "burn") - { - return deBlendBurn; - } - - return deBlendInvalid; - -} - -void getSupportedBlendModes(std::vector& result) -{ - result.push_back(deBlendNormal); - result.push_back(deBlendMultiply); - result.push_back(deBlendScreen); - result.push_back(deBlendOverlay); - result.push_back(deBlendOverlayInvert); - result.push_back(deBlendAdd); - result.push_back(deBlendGrainExtract); - result.push_back(deBlendGrainMerge); - result.push_back(deBlendSub); - result.push_back(deBlendDifference); - result.push_back(deBlendDarken); - result.push_back(deBlendLighten); - result.push_back(deBlendDodge); - result.push_back(deBlendBurn); -} - -deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode) -{ - switch (mode) - { - case deBlendNormal: - return v2; - break; - case deBlendMultiply: - return src*v2; - break; - case deBlendScreen: - return 1 - (1-src)*(1-v2); - break; - case deBlendOverlay: - if (src > 0.5) - { - return 1 - (1 - 2 * ( src - 0.5)) * (1 - v2); - } - else - { - return 2 * src * v2; - } - break; - case deBlendOverlayInvert: - if (src > 0.5) - { - return 1 - (1 - 2 * ( src - 0.5)) * v2; - } - else - { - return 2 * src * (1 - v2); - } - break; - case deBlendAdd: - { - deValue v = src + v2; - if (v < 0) - { - return 0; - } - if (v > 1) - { - return 1; - } - return v; - break; - } - case deBlendGrainExtract: - { - deValue v = 0.5 + src - v2; - if (v < 0) - { - return 0; - } - if (v > 1) - { - return 1; - } - return v; - break; - } - case deBlendGrainMerge: - { - deValue v = src + v2 - 0.5; - if (v < 0) - { - return 0; - } - if (v > 1) - { - return 1; - } - return v; - break; - } - case deBlendSub: - { - deValue v = src - v2; - if (v < 0) - { - return 0; - } - if (v > 1) - { - return 1; - } - return v; - break; - } - case deBlendDifference: - return fabs(src - v2); - break; - case deBlendDarken: - if (src < v2) - { - return src; - } - else - { - return v2; - } - break; - case deBlendLighten: - if (src > v2) - { - return src; - } - else - { - return v2; - } - break; - case deBlendDodge: - { - deValue d = 1 - v2; - if (d == 0) - { - return 1.0; - } - else - { - deValue r = src / d; - if ( r > 1) - { - return 1; - } - else - { - return r; - } - } - break; - } - case deBlendBurn: - { - if (v2 == 0) - { - return 0.0; - } - else - { - deValue v = (1 - src) / v2; - if (v > 1) - { - v = 1; - } - deValue r = 1 - v; - return r; - } - break; - } - default: - return 0; - } -} - diff -Nru delaboratory-0.7/src/blend_mode.h delaboratory-0.8/src/blend_mode.h --- delaboratory-0.7/src/blend_mode.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blend_mode.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLEND_MODES_H -#define _DE_BLEND_MODES_H - -#include -#include -#include "value.h" - -enum deBlendMode -{ - deBlendInvalid, - deBlendNormal, - deBlendMultiply, - deBlendScreen, - deBlendOverlay, - deBlendOverlayInvert, - deBlendDodge, - deBlendBurn, - deBlendAdd, - deBlendGrainExtract, - deBlendGrainMerge, - deBlendSub, - deBlendDifference, - deBlendDarken, - deBlendLighten -}; - -std::string getBlendModeName(deBlendMode mode); -void getSupportedBlendModes(std::vector& result); -deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode); -deBlendMode blendModeFromString(const std::string& s); - -#endif diff -Nru delaboratory-0.7/src/blur.cc delaboratory-0.8/src/blur.cc --- delaboratory-0.7/src/blur.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blur.h" -#include -#include -#include "logger.h" - -void boxBlur(deValue* source, deValue* destination, int n, int s) -{ - int i; - for (i = 0; i < n; i++) - { - deValue result = 0.0; - - int n1 = i - s + 1; - int n2 = i + s - 1; - if (n1 < 0) - { - n1 = 0; - } - - if (n2 >= n) - { - n2 = n - 1; - } - - int j; - for (j = n1; j <= n2; j++) - { - result += source[j]; - } - destination[i] = result / (n2 - n1 + 1.0); - } -} - -void gaussianBlur(deValue* source, deValue* destination, int n, int s, deValue* weights) -{ - int i; - for (i = 0; i < n; i++) - { - deValue result = 0.0; - deValue sum = 0.0; - - int n1 = i - s + 1; - int n2 = i + s - 1; - if (n1 < 0) - { - n1 = 0; - } - - if (n2 >= n) - { - n2 = n - 1; - } - - int j; - int p; - - j = n1; - p = i - n1; - while (p >= 0) - { - deValue v = source[j]; - deValue w = weights[p]; - result += w * v; - sum += w; - - p--; - j++; - } - p = 1; - while (j <= n2) - { - - deValue v = source[j]; - deValue w = weights[p]; - result += w * v; - sum += w; - - p++; - j++; - } - - - destination[i] = result / sum; - } -} - -void surfaceBlur(deValue* source, deValue* destination, int n, int s, deValue* weights, deValue t) -{ - deValue tt = 1.0 - t; - - int i; - for (i = 0; i < n; i++) - { - deValue result = 0.0; - deValue sum = 0.0; - - deValue reference = source[i]; - - int n1 = i - s + 1; - int n2 = i + s - 1; - if (n1 < 0) - { - n1 = 0; - } - - if (n2 >= n) - { - n2 = n - 1; - } - - int j; - int p; - - j = n1; - p = i - n1; - while (p >= 0) - { - deValue v = source[j]; - if (fabs(v - reference) <= tt) - { - deValue w = weights[p]; - result += w * v; - sum += w; - } - - p--; - j++; - } - p = 1; - while (j <= n2) - { - - deValue v = source[j]; - if (fabs(v - reference) <= tt) - { - deValue w = weights[p]; - result += w * v; - sum += w; - } - - p++; - j++; - } - - - destination[i] = result / sum; - } -} - -void fillWeightsFlat(deValue* weights, int blurSize) -{ - int i; - for (i = 0 ; i < blurSize; i++) - { - weights[i] = 1.0; - } -} - -void fillWeightsGaussian(deValue* weights, int blurSize) -{ - int i; - deValue radius = blurSize / 3.0; - deValue rr2 = 2.0 * radius * radius; - for (i = 0 ; i < blurSize; i++) - { - deValue ii = i * i; - deValue ee = exp( - ii / rr2 ); - weights[i] = 1.0 / sqrt(rr2 * M_PI) * ee; - } -} - -bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t) -{ - assert(source); - assert(destination); - - int w = size.getW(); - int h = size.getH(); - - if (w == 0) - { - return false; - } - - if (h == 0) - { - return false; - } - - if ((radiusX <= 0) || (radiusY <= 0)) - { - return false; - } - - assert(w > 0); - assert(h > 0); - - int blurSizeW = radiusX; - if (blurSizeW < 1) - { - blurSizeW = 1; - } - int blurSizeH = radiusY; - if (blurSizeH < 1) - { - blurSizeH = 1; - } - - int maxSize = blurSizeW; - if (blurSizeH > maxSize) - { - maxSize = blurSizeH; - } - - int max = w; - if (h > max) - { - max = h; - } - - deValue* tmp = NULL; - - try - { - tmp = new deValue[size.getN()]; - } - catch (std::bad_alloc) - { - logMessage("ERROR allocating memory in blur"); - if (tmp) - { - delete [] tmp; - } - return false; - } - - deValue* sourceBuffer = new deValue[max]; - deValue* destinationBuffer = new deValue[max]; - deValue* weights = new deValue[maxSize]; - - int i; - int j; - - { - if (type != deBoxBlur) - { - fillWeightsGaussian(weights, blurSizeW); - } - - for (i = 0; i < h; i++) - { - int p = i * w; - for (j = 0; j < w; j++) - { - sourceBuffer[j] = source[p + j]; - } - switch (type) - { - case deBoxBlur: - { - boxBlur(sourceBuffer, destinationBuffer, w, blurSizeW); - break; - } - case deGaussianBlur: - { - gaussianBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights); - break; - } - case deSurfaceBlur: - { - surfaceBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights, t); - break; - } - default: - break; - } - for (j = 0; j < w; j++) - { - tmp[p + j] = destinationBuffer[j]; - } - } - } - - - { - if (type != deBoxBlur) - { - fillWeightsGaussian(weights, blurSizeH); - } - - for (i = 0; i < w; i++) - { - for (j = 0; j < h; j++) - { - sourceBuffer[j] = tmp[j * w + i]; - } - switch (type) - { - case deBoxBlur: - { - boxBlur(sourceBuffer, destinationBuffer, h, blurSizeH); - break; - } - case deGaussianBlur: - { - gaussianBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights); - break; - } - case deSurfaceBlur: - { - surfaceBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights, t); - break; - } - default: - break; - } - for (j = 0; j < h; j++) - { - destination[j * w + i] = destinationBuffer[j]; - } - } - } - - delete [] tmp; - delete [] weights; - delete [] destinationBuffer; - delete [] sourceBuffer; - - return true; -} - diff -Nru delaboratory-0.7/src/blur_frame.cc delaboratory-0.8/src/blur_frame.cc --- delaboratory-0.7/src/blur_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blur_frame.h" -#include "blur_layer.h" -#include -#include "property_value_slider.h" -#include "property_choice_ui.h" - -deBlurFrame::deBlurFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deBlurLayer& blurLayer = dynamic_cast(_layer); - - int range = 100; - - radius = new dePropertyValueSlider(this, range, blurLayer.getPropertyRadius(), blurLayer, layerProcessor); - sizer->Add(radius); - - threshold = new dePropertyValueSlider(this, range, blurLayer.getPropertyThreshold(), blurLayer, layerProcessor); - sizer->Add(threshold); - - blurType = new dePropertyChoiceUI(this, blurLayer.getPropertyType(), blurLayer, layerProcessor); - sizer->Add(blurType); - - onUpdateProperties(); - - Fit(); - -} - -deBlurFrame::~deBlurFrame() -{ -} - -void deBlurFrame::onUpdateProperties() -{ - deBlurLayer& blurLayer = dynamic_cast(layer); - if (blurLayer.getPropertyType().get() == "surface") - { - threshold->Enable(); - } - else - { - threshold->Disable(); - } -} diff -Nru delaboratory-0.7/src/blur_frame.h delaboratory-0.8/src/blur_frame.h --- delaboratory-0.7/src/blur_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLUR_FRAME_H -#define _DE_BLUR_FRAME_H - -#include "action_frame.h" -#include -#include "blur_type.h" -class dePropertyValueSlider; -class dePropertyChoiceUI; -class deLayerProcessor; - -class deBlurFrame:public deActionFrame -{ - private: - dePropertyValueSlider* radius; - dePropertyValueSlider* threshold; - dePropertyChoiceUI* blurType; - deLayerProcessor& layerProcessor; - - public: - deBlurFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deBlurFrame(); - - virtual void onUpdateProperties(); - -}; - - -#endif diff -Nru delaboratory-0.7/src/blur.h delaboratory-0.8/src/blur.h --- delaboratory-0.7/src/blur.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLUR_H -#define _DE_BLUR_H - -#include "value.h" -#include "blur_type.h" -#include "size.h" -#include "channel.h" - -bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t); - -#endif diff -Nru delaboratory-0.7/src/blur_layer.cc delaboratory-0.8/src/blur_layer.cc --- delaboratory-0.7/src/blur_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blur_layer.h" -#include "project.h" -#include -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "layer_processor.h" - -deBlurLayer::deBlurLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager), - blurRadius("blur_radius"), - threshold("threshold"), - blurType("blur_type") -{ - blurRadius.setLabel("radius"); - blurRadius.setMin(0); - blurRadius.setMax(50); - getSupportedBlurTypes(blurType.getChoices()); - blurType.setLabel("blur type"); - reset(); -} - -deBlurLayer::~deBlurLayer() -{ -} - -void deBlurLayer::reset() -{ - blurRadius.set(5); - blurType.set("gaussian"); -} - -bool deBlurLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - const deValue* source = sourceChannel.getPixels(); - deValue* destination = channel.getPixels(); - - deValue r = viewManager.getRealScale() * blurRadius.get(); - - deBlurType type = blurTypeFromString(blurType.get()); - - logMessage("blur r=" + str(r)); - - bool result = blurChannel(source, destination, size, r, r, type, threshold.get()); - - logMessage("blur done"); - - return result; -} - -bool deBlurLayer::isChannelNeutral(int index) -{ - return (blurRadius.get() == 0); -} - -void deBlurLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - - blurRadius.save(root); - blurType.save(root); - threshold.save(root); -} - -void deBlurLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - - blurRadius.load(child); - blurType.load(child); - threshold.load(child); - - child = child->next; - - } - -} - -bool deBlurLayer::randomize() -{ - deValue r = (deValue) rand() / RAND_MAX; - - r *= 0.5; - - blurRadius.set(r); - - return true; -} diff -Nru delaboratory-0.7/src/blur_layer.h delaboratory-0.8/src/blur_layer.h --- delaboratory-0.7/src/blur_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLUR_LAYER_H -#define _DE_BLUR_LAYER_H - -#include "action_layer.h" -#include "blur.h" -#include "property_value.h" -#include "property_choice.h" - -class deBlurLayer:public deActionLayer -{ - private: - dePropertyValue blurRadius; - dePropertyValue threshold; - dePropertyChoice blurType; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "blur";}; - - public: - deBlurLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deBlurLayer(); - - void reset(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "blur";}; - - dePropertyValue& getPropertyRadius() {return blurRadius;}; - dePropertyChoice& getPropertyType() {return blurType;}; - dePropertyValue& getPropertyThreshold() {return threshold;}; - - bool randomize(); - -}; - -#endif diff -Nru delaboratory-0.7/src/blur_type.cc delaboratory-0.8/src/blur_type.cc --- delaboratory-0.7/src/blur_type.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_type.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "blur_type.h" - -std::string getBlurTypeName(deBlurType type) -{ - switch (type) - { - case deBoxBlur: - return "box"; - case deGaussianBlur: - return "gaussian"; - case deSurfaceBlur: - return "surface"; - default: - return "unknown"; - } -} - -deBlurType blurTypeFromString(const std::string& s) -{ - if (s == "box") - { - return deBoxBlur; - } - if (s == "gaussian") - { - return deGaussianBlur; - } - if (s == "surface") - { - return deSurfaceBlur; - } - - return deBlurInvalid; -} - -void getSupportedBlurTypes(std::vector& result) -{ - result.push_back(deBoxBlur); - result.push_back(deGaussianBlur); - result.push_back(deSurfaceBlur); -} - -void getSupportedBlurTypes(std::vector& result) -{ - result.push_back("box"); - result.push_back("gaussian"); - result.push_back("surface"); -} diff -Nru delaboratory-0.7/src/blur_type.h delaboratory-0.8/src/blur_type.h --- delaboratory-0.7/src/blur_type.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/blur_type.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BLUR_TYPE_H -#define _DE_BLUR_TYPE_H - -#include -#include - -enum deBlurType -{ - deBlurInvalid, - deBoxBlur, - deGaussianBlur, - deSurfaceBlur -}; - -std::string getBlurTypeName(deBlurType type); -deBlurType blurTypeFromString(const std::string& s); -void getSupportedBlurTypes(std::vector& result); -void getSupportedBlurTypes(std::vector& result); - -#endif diff -Nru delaboratory-0.7/src/bw.cc delaboratory-0.8/src/bw.cc --- delaboratory-0.7/src/bw.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/bw.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "bw.h" - -void rgb2bw(deValue r, deValue g, deValue b, deValue& bw) -{ - bw = (r + g + b) / 3.0; -} - -void bw2rgb(deValue bw, deValue& r, deValue& g, deValue& b) -{ - r = bw; - g = bw; - b = bw; -} diff -Nru delaboratory-0.7/src/bw.h delaboratory-0.8/src/bw.h --- delaboratory-0.7/src/bw.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/bw.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_BW_H -#define _DE_BW_H - -#include "value.h" - -void rgb2bw(deValue r, deValue g, deValue b, deValue& bw); -void bw2rgb(deValue bw, deValue& r, deValue& g, deValue& b); - -#endif diff -Nru delaboratory-0.7/src/channel.cc delaboratory-0.8/src/channel.cc --- delaboratory-0.7/src/channel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/channel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "channel.h" -#include -#include -#include "logger.h" -#include "str.h" - -#define CHANNEL_LOCKING 1 - -deChannel::deChannel() -:readSemaphore(4, 4), -writeMutex(wxMUTEX_RECURSIVE) -{ - pixels = NULL; - maxReaders = 4; - magicSize = -1; -} - -deChannel::~deChannel() -{ - if (pixels) - { - deallocate(); - } -} - -deValue* deChannel::getPixels() -{ - return pixels; -} - -const deValue* deChannel::getPixels() const -{ - return pixels; -} - -deValue deChannel::getValue(int pos) const -{ - if (pos < 0) - { - return 0.0; - } - if (pos >= magicSize) - { - return 0.0; - } - deValue v = pixels[pos]; - return v; -} - -void deChannel::setValue(int pos, const deValue& value) -{ - if (pos < 0) - { - return; - } - if (pos >= magicSize) - { - return; - } - pixels[pos] = value; -} - -void deChannel::setValueClip(int pos, const deValue& value) -{ - if (pos < 0) - { - return; - } - if (pos >= magicSize) - { - return; - } - if (value < 0) - { - pixels[pos] = 0; - return; - } - if (value > 1) - { - pixels[pos] = 1; - return; - } - pixels[pos] = value; -} - -void deChannel::deallocate() -{ - lockWrite(); - assert(pixels); - logMessage("deallocate channel"); - delete [] pixels; - pixels = NULL; - magicSize = 0; - unlockWrite(); -} - -void deChannel::allocate(int size) -{ - lockWrite(); - assert(!pixels); - try - { - pixels = new deValue [size]; - magicSize = size; - } - catch (std::bad_alloc) - { - logMessage("ERROR allocating channel"); - pixels = NULL; - magicSize = 0; - } - - unlockWrite(); -} - -void deChannel::lockRead() const -{ -#if CHANNEL_LOCKING - readSemaphore.Wait(); -#endif -} - -void deChannel::unlockRead() const -{ -#if CHANNEL_LOCKING - readSemaphore.Post(); -#endif -} - -void deChannel::lockWrite() -{ -#if CHANNEL_LOCKING - int i; - for (i = 0; i < maxReaders; i++) - { - readSemaphore.Wait(); - } - lockWithLog(writeMutex, "channel write mutex"); -#endif -} - -void deChannel::unlockWrite() -{ -#if CHANNEL_LOCKING - writeMutex.Unlock(); - int i; - for (i = 0; i < maxReaders; i++) - { - readSemaphore.Post(); - } -#endif -} diff -Nru delaboratory-0.7/src/channel.h delaboratory-0.8/src/channel.h --- delaboratory-0.7/src/channel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CHANNEL_H -#define _DE_CHANNEL_H - -#include "value.h" -#include - -class deChannel -{ - private: - deValue* pixels; - mutable wxSemaphore readSemaphore; - wxMutex writeMutex; - int maxReaders; - int magicSize; - - deChannel(const deChannel& c); - deChannel& operator =(const deChannel& c); - public: - deChannel(); - - virtual ~deChannel(); - - void deallocate(); - void allocate(int size); - - bool isAllocated() const {return pixels;}; - - deValue* getPixels(); - - const deValue* getPixels() const; - - deValue getValue(int pos) const; - void setValue(int pos, const deValue& value); - void setValueClip(int pos, const deValue& value); - - void lockRead() const; - void unlockRead() const; - void lockWrite(); - void unlockWrite(); -}; - -#endif diff -Nru delaboratory-0.7/src/channel_manager.cc delaboratory-0.8/src/channel_manager.cc --- delaboratory-0.7/src/channel_manager.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/channel_manager.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,195 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "channel_manager.h" -#include -#include -#include -#include "logger.h" -#include "str.h" - -deChannelManager::deChannelManager() -:channelSize(0,0), -mutex(wxMUTEX_RECURSIVE) -{ -} - -deChannelManager::~deChannelManager() -{ - unsigned int i; - for (i = 0; i < channels.size(); i++) - { - freeChannel(i); - } -} - -void deChannelManager::setChannelSize(const deSize& size) -{ - lock(); - - channelSize = size; - destroyAllChannels(); - - unlock(); -} - -int deChannelManager::allocateNewChannel() -{ - lock(); - - deChannel* channel = new deChannel(); - channel->allocate(channelSize.getN()); - - if (trashed.size() > 0) - { - std::set::iterator i = trashed.begin(); - int c = *i; - trashed.erase(c); - channels[c] = channel; - logMessage("reused trashed channel " + str(c)); - unlock(); - return c; - } - else - { - channels.push_back(channel); - int c = channels.size() - 1; - logMessage("added channel " + str(c)); - unlock(); - return c; - } - -} - -void deChannelManager::freeChannel(int index) -{ - lock(); - - assert(index >= 0); - assert((unsigned int)index < channels.size()); - - if (channels[index]) - { - delete channels[index]; - channels[index] = NULL; - trashed.insert(index); - } - else - { - } - - unlock(); -} - -deChannel* deChannelManager::getChannel(int index) -{ - if (index < 0) - { - return NULL; - } - lock(); - assert((unsigned int)index < channels.size()); - tryAllocateChannel(index); - deChannel* c = channels[index]; - unlock(); - return c; -} - -void deChannelManager::destroyAllChannels() -{ - lock(); - unsigned int i; - for (i = 0; i < channels.size(); i++) - { - if (channels[i]) - { - tryDeallocateChannel(i); - } - } - unlock(); -} - -deSize deChannelManager::getChannelSize() const -{ - return channelSize; -} - -void deChannelManager::lock() const -{ - lockWithLog(mutex, "channel manager mutex"); -} - -void deChannelManager::unlock() const -{ - mutex.Unlock(); -} - -int deChannelManager::getNumberOfAllocatedChannels() const -{ - lock(); - int n = 0; - unsigned int i; - for (i = 0; i < channels.size(); i++) - { - if (channels[i]) - { - if (channels[i]->isAllocated()) - { - n++; - } - } - } - unlock(); - return n; -} - -void deChannelManager::tryAllocateChannel(int index) -{ - lock(); - - assert(index >= 0); - assert((unsigned int)index < channels.size()); - if ((channels[index])) - { - if (!channels[index]->isAllocated()) - { - logMessage("allocate channel " + str(index)); - channels[index]->allocate(channelSize.getN()); - } - } - - unlock(); -} - -void deChannelManager::tryDeallocateChannel(int index) -{ - lock(); - - assert(index >= 0); - assert((unsigned int)index < channels.size()); - if ((channels[index])) - { - if (channels[index]->isAllocated()) - { - logMessage("deallocate channel " + str(index)); - channels[index]->deallocate(); - } - } - - unlock(); -} diff -Nru delaboratory-0.7/src/channel_manager.h delaboratory-0.8/src/channel_manager.h --- delaboratory-0.7/src/channel_manager.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/channel_manager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CHANNEL_MANAGER_H -#define _DE_CHANNEL_MANAGER_H - -#include "size.h" -#include -#include -#include "channel.h" -#include - -class deImage; -class deLogger; - -class deChannelManager -{ - private: - deSize channelSize; - mutable wxMutex mutex; - - std::vector channels; - std::set trashed; - - deChannelManager(const deChannelManager& m); - deChannelManager& operator =(const deChannelManager& m); - - void lock() const; - void unlock() const; - - public: - deChannelManager(); - virtual ~deChannelManager(); - - void destroyAllChannels(); - - void setChannelSize(const deSize& size); - deSize getChannelSize() const; - - int allocateNewChannel(); - void freeChannel(int index); - - void tryAllocateChannel(int index); - void tryDeallocateChannel(int index); - - deChannel* getChannel(int index); - - - int getNumberOfAllocatedChannels() const; - - void setPrimary(int index); - -}; - -#endif diff -Nru delaboratory-0.7/src/channels.h delaboratory-0.8/src/channels.h --- delaboratory-0.7/src/channels.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/channels.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CHANNELS_H -#define _DE_CHANNELS_H - -// RGB -#define DE_CHANNEL_RED 0 -#define DE_CHANNEL_GREEN 1 -#define DE_CHANNEL_BLUE 2 - -// BW -#define DE_CHANNEL_GRAYSCALE 0 - -// LAB -#define DE_CHANNEL_L 0 -#define DE_CHANNEL_A 1 -#define DE_CHANNEL_B 2 - -// LCH -#define DE_CHANNEL_C 1 -#define DE_CHANNEL_H 2 - -// CMY/CMYK -#define DE_CHANNEL_CYAN 0 -#define DE_CHANNEL_MAGENTA 1 -#define DE_CHANNEL_YELLOW 2 -#define DE_CHANNEL_KEY 3 - -// HSL/HSV -#define DE_CHANNEL_HUE 0 -#define DE_CHANNEL_SATURATION 1 -#define DE_CHANNEL_LIGHTNESS 2 -#define DE_CHANNEL_VALUE 2 - -// XYZ -#define DE_CHANNEL_X 0 -#define DE_CHANNEL_Y 1 -#define DE_CHANNEL_Z 2 - -#endif diff -Nru delaboratory-0.7/src/check_box.cc delaboratory-0.8/src/check_box.cc --- delaboratory-0.7/src/check_box.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/check_box.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "check_box.h" - -deCheckBox::deCheckBox(wxWindow *parent, const std::string& labelString) -:wxPanel(parent) -{ - sizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(sizer); - - checkBox = new wxCheckBox(this, wxID_ANY, wxString::FromAscii(labelString.c_str())); - sizer->Add(checkBox); - - Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deCheckBox::check)); -} - -deCheckBox::~deCheckBox() -{ -} - -void deCheckBox::check(wxCommandEvent &event) -{ - if (checkBox->IsChecked()) - { - onCheck(true); - } - else - { - onCheck(false); - } -} - -void deCheckBox::set(bool b) -{ - if (b) - { - checkBox->SetValue(1); - } - else - { - checkBox->SetValue(0); - } -} diff -Nru delaboratory-0.7/src/check_box.h delaboratory-0.8/src/check_box.h --- delaboratory-0.7/src/check_box.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/check_box.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CHECK_BOX_H -#define _DE_CHECK_BOX_H - -#include -#include - -class deCheckBox:public wxPanel -{ - private: - wxSizer* sizer; - wxCheckBox* checkBox; - - void check(wxCommandEvent &event); - - public: - deCheckBox(wxWindow *parent, const std::string& labelString); - virtual ~deCheckBox(); - - virtual void onCheck(bool c) = 0; - - void set(bool c); -}; - -#endif diff -Nru delaboratory-0.7/src/choice.cc delaboratory-0.8/src/choice.cc --- delaboratory-0.7/src/choice.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/choice.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "choice.h" - -deChoice::deChoice(wxWindow *parent, const std::string& labelString, const std::vector& choices) -:wxPanel(parent) -{ - sizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(sizer); - - label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(labelString.c_str()), wxDefaultPosition, wxSize(100, 30)); - sizer->Add(label, 0, wxCENTER); - - wxString* ws = new wxString [choices.size()]; - unsigned int i; - for (i = 0; i < choices.size(); i++) - { - ws[i] = wxString::FromAscii(choices[i].c_str()); - } - - choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), choices.size(), ws); - sizer->Add(choice); - - Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deChoice::choose)); -} - -deChoice::~deChoice() -{ -} - -void deChoice::choose(wxCommandEvent &event) -{ - int i = event.GetInt(); - onChoose(i); -} - -void deChoice::set(int index) -{ - choice->SetSelection(index); -} diff -Nru delaboratory-0.7/src/choice.h delaboratory-0.8/src/choice.h --- delaboratory-0.7/src/choice.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/choice.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CHOICE_H -#define _DE_CHOICE_H - -#include -#include -#include - -class deChoice:public wxPanel -{ - private: - wxSizer* sizer; - wxStaticText* label; - wxChoice* choice; - - void choose(wxCommandEvent &event); - - public: - deChoice(wxWindow *parent, const std::string& labelString, const std::vector& choices); - virtual ~deChoice(); - - virtual void onChoose(int c) = 0; - - void set(int index); -}; - -#endif diff -Nru delaboratory-0.7/src/cmyk.cc delaboratory-0.8/src/cmyk.cc --- delaboratory-0.7/src/cmyk.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/cmyk.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "cmyk.h" - -void rgb2cmy(deValue r, deValue g, deValue b, deValue& c, deValue& m, deValue& y) -{ - c = 1 - r; - m = 1 - g; - y = 1 - b; -} - -void cmy2rgb(deValue c, deValue m, deValue y, deValue& r, deValue& g, deValue& b) -{ - r = 1 - c; - g = 1 - m; - b = 1 - y; - - if (r < 0) - { - r = 0; - } - else if (r > 1) - { - r = 1; - } - if (g < 0) - { - g = 0; - } - else if (g > 1) - { - g = 1; - } - if (b < 0) - { - b = 0; - } - else if (b > 1) - { - b = 1; - } -} - -void cmy2cmyk(deValue c, deValue m, deValue y, deValue& _c, deValue& _m, deValue& _y, deValue& _k) -{ - deValue k; - if (c < m) - { - if (c < y) - { - k = c; - } - else - { - k = y; - } - } - else - { - if (m < y) - { - k = m; - } - else - { - k = y; - } - } - - k = k - 0.25; - if (k < 0.0) - { - k = 0.0; - } - - if (k > 0.8) - { - k = 0.8; - } - - deValue kk = (1 - k); - - _k = k; - _c = (c - k) / kk; - _m = (m - k) / kk; - _y = (y - k) / kk; -} - -void cmyk2cmy(deValue c, deValue m, deValue y, deValue k, deValue& _c, deValue& _m, deValue& _y) -{ - deValue kk = 1 - k; - - _c = c * kk + k; - _m = m * kk + k; - _y = y * kk + k; -} diff -Nru delaboratory-0.7/src/cmyk.h delaboratory-0.8/src/cmyk.h --- delaboratory-0.7/src/cmyk.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/cmyk.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CMYK_H -#define _DE_CMYK_H - -#include "value.h" - -void rgb2cmy(deValue r, deValue g, deValue b, deValue& c, deValue& m, deValue& y); -void cmy2rgb(deValue c, deValue m, deValue y, deValue& r, deValue& g, deValue& b); -void cmy2cmyk(deValue c, deValue m, deValue y, deValue& _c, deValue& _m, deValue& _y, deValue& _k); -void cmyk2cmy(deValue c, deValue m, deValue y, deValue k, deValue& _c, deValue& _m, deValue& _y); - -#endif diff -Nru delaboratory-0.7/src/color_matrix.cc delaboratory-0.8/src/color_matrix.cc --- delaboratory-0.7/src/color_matrix.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_matrix.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "color_matrix.h" -#include -#include - -deColorMatrix::deColorMatrix(int _w, int _h) -{ - width = _w; - height = _h; - - minX = 0; - minY = 0; - maxX = 1; - maxY = 1; - - int n = width * height; - matrix = new deValue [n]; - density = new int [n]; -} - -deColorMatrix::~deColorMatrix() -{ - delete [] matrix; - delete [] density; -} - -void deColorMatrix::clear() -{ - int n = width * height; - int i; - for (i = 0; i < n; i++) - { - matrix[i] = -1; - density[i] = 0; - } -} - -void deColorMatrix::buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min) -{ - minX = 0; - minY = 0; - maxX = 1; - maxY = 1; - - clear(); - build(channelH, channelV, channelA, n); - int xx; - int yy; - int minxx = width; - int maxxx = -1; - int minyy = height; - int maxyy = -1; - - for (xx = 0; xx < width; xx++) - { - for (yy = 0; yy < height; yy++) - { - int pos = width * yy + xx; - if (density[pos] >= min) - { - if (xx < minxx) - { - minxx = xx; - } - if (yy < minyy) - { - minyy = yy; - } - if (xx > maxxx) - { - maxxx = xx; - } - if (yy > maxyy) - { - maxyy = yy; - } - } - } - } - - if (minxx > 0) - { - minxx--; - } - if (minyy > 0) - { - minyy--; - } - if (maxxx < width - 1) - { - maxxx++; - } - if (maxyy < height - 1) - { - maxyy++; - } - - minX = (deValue) minxx / width; - minY = (deValue) minyy / height; - maxX = (deValue) maxxx / width; - maxY = (deValue) maxyy / height; - - deValue margin = -0.01; - - if (maxX < 0.5 - margin) - { - maxX = 0.5 - margin; - } - if (maxY < 0.5 - margin) - { - maxY = 0.5 - margin; - } - if (minX > 0.5 + margin) - { - minX = 0.5 + margin; - } - if (minY > 0.5 + margin) - { - minY = 0.5 + margin; - } - - clear(); - build(channelH, channelV, channelA, n); - -} - -void deColorMatrix::build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n) -{ - int i; - - for (i = 0; i < n; i++) - { - deValue h = channelH[i]; - deValue v = channelV[i]; - deValue a = channelA[i]; - - if ((h >= 0) && (h < 1) && (v >= 0) && (v < 1) && ((a >= 0) && (a < 1))) - { - int x = (h - minX) / (maxX - minX) * width; - int y = (v - minY) / (maxY - minY) * height; - - if ((x >= 0) && (y >= 0) && (x < width) && (y < height)) - { - int pos = width * y + x; - - int d = density[pos]; - - if (d == 0) - { - density[pos] = 1; - matrix[pos] = a; - } - else - { - density[pos]++; - matrix[pos] += a; - } - } - } - } - - int nn = width * height; - for (i = 0; i < nn; i++) - { - int d = density[i]; - if (d > 0) - { - matrix[i] /= d; - } - } -} - -deValue deColorMatrix::get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const -{ - vx = minX + ((deValue) x / width) * (maxX - minX); - deValue vx2 = minX + ((deValue) (x+1) / width) * (maxX - minX); - deValue vx3 = minX + ((deValue) (x-1) / width) * (maxX - minX); - deValue dx = fabs(0.5 - vx); - deValue dx2 = fabs(0.5 - vx2); - deValue dx3 = fabs(0.5 - vx3); - - vy = minY + ((deValue) y / height) * (maxY - minY); - deValue vy2 = minY + ((deValue) (y+1) / height) * (maxY - minY); - deValue vy3 = minY + ((deValue) (y-1) / height) * (maxY - minY); - deValue dy = fabs(0.5 - vy); - deValue dy2 = fabs(0.5 - vy2); - deValue dy3 = fabs(0.5 - vy3); - - center = false; - if ((dx < dx2) && (dx < dx3)) - { - center = true; - } - if ((dy < dy2) && (dy < dy3)) - { - center = true; - } - - if (x < 0) - { - return -1; - } - if (y < 0) - { - return -1; - } - if (x >= width) - { - return -1; - } - if (y >= height) - { - return -1; - } - int pos = width * y + x; - if (density[pos] < min) - { - return -1; - } - - deValue result = matrix[pos]; - return result; -} diff -Nru delaboratory-0.7/src/color_matrix_frame.cc delaboratory-0.8/src/color_matrix_frame.cc --- delaboratory-0.7/src/color_matrix_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_matrix_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,421 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "color_matrix_frame.h" -#include "color_matrix.h" -#include "gradient_panel.h" -#include "project.h" -#include "layer_stack.h" -#include "layer.h" -#include "channel_manager.h" -#include "conversion_functions.h" -#include "wx/notebook.h" -#include "conversion_functions.h" -#include "convert_image.h" - -#define LAB_TILE_SIZE 20 -#define ALL_TILES_SIZE 800 - -deColorMatrixFrame2::deColorMatrixFrame2(wxWindow *parent, deProject& project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette) -:deHelpFrame(parent, "color matrix") -{ - - const deViewManager& viewManager = project.getViewManager(); - int view = viewManager.getView(); - - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(view); - - if (!layer) - { - return; - } - - const deImage& originalImage = layer->getImage(); - - deChannelManager& channelManager = project.getPreviewChannelManager(); - deSize channelSize = channelManager.getChannelSize(); - int n = channelSize.getN(); - - deImage LABImage(deColorSpaceLAB, channelManager); - LABImage.enableAllChannels(); - convertImage(originalImage, LABImage, channelManager); - - int nn = width * height; - - //int min = (n / 2) / nn; - int min = (n / 1.5) / nn; - - const deValue* valuesVertical = LABImage.getValues(channelVertical); - const deValue* valuesHorizontal = LABImage.getValues(channelHorizontal); - const deValue* valuesAverage = LABImage.getValues(channelAverage); - - int tilesW = width; - int tilesH = height; - - deColorMatrix colorMatrix(tilesW , tilesH); - - colorMatrix.buildZoomed(valuesHorizontal, valuesVertical, valuesAverage, n, min); - - wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - //int s = 2; - int s = 0; - - wxSizer* LABMapSizer = new wxFlexGridSizer(tilesW, s, s); - mainSizer->Add(LABMapSizer); - - int x; - int y; - //for (y = 0; y < tilesH; y++) - for (y = tilesH - 1; y >= 0; y--) - { - for (x = 0; x < tilesW; x++) - { - int style = 0; - - deValue vx = 0; - deValue vy = 0; - bool center; - deValue a = colorMatrix.get(x, y, min, vx, vy, center); - - style = wxBORDER_NONE; - if ((center) && (a < 0)) - { - style = wxBORDER_SIMPLE; - } - - deColorPanel* colorPanel = new deColorPanel(this, wxSize(ALL_TILES_SIZE / width, ALL_TILES_SIZE / height), palette, style); - LABMapSizer->Add(colorPanel); - - if (a >= 0) - { - - deValue v1 = 0; - deValue v2 = 0; - deValue v3 = 0; - switch (channelHorizontal) - { - case 0: - v1 = vx; - break; - case 1: - { - v2 = vx; - break; - } - case 2: - v3 = vx; - break; - default: - break; - } - switch (channelVertical) - { - case 0: - v1 = vy; - break; - case 1: - v2 = vy; - break; - case 2: - v3 = vy; - break; - default: - break; - } - switch (channelAverage) - { - case 0: - v1 = a; - break; - case 1: - v2 = a; - break; - case 2: - v3 = a; - break; - default: - break; - } - - deValue r; - deValue g; - deValue b; - - lab2rgb(v1, v2, v3, r, g, b); - colorPanel->setRGB(r, g, b); - } - else - { -// colorPanel->setRGB(0, 0, 0); - } - - } - } - Fit(); -} - -deColorMatrixFrame2::~deColorMatrixFrame2() -{ -} - -#define LAB_TILES 20 - -deColorMatrixFrame::deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin) -:deHelpFrame(parent, "color matrix"), project(_project) -{ - wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); - mainSizer->Add(notebook, 1, wxEXPAND); - - wxPanel* imagePanel = new wxPanel(notebook); - notebook->AddPage(imagePanel, _T("image")); - wxSizer* imageSizer = new wxBoxSizer(wxVERTICAL); - imagePanel->SetSizer(imageSizer); - - wxPanel* LABPanel = new wxPanel(notebook); - notebook->AddPage(LABPanel, _T("LAB")); - wxSizer* LABSizer = new wxBoxSizer(wxVERTICAL); - LABPanel->SetSizer(LABSizer); - - wxPanel* palettePanel = new wxPanel(notebook); - notebook->AddPage(palettePanel, _T("palette")); - wxSizer* paletteSizer = new wxBoxSizer(wxVERTICAL); - palettePanel->SetSizer(paletteSizer); - - palette = NULL; - palette2 = NULL; - paletteLAB = NULL; - - const deViewManager& viewManager = project.getViewManager(); - int view = viewManager.getView(); - - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(view); - - if (!layer) - { - return; - } - - const deImage& image = layer->getImage(); - deColorSpace colorSpace = image.getColorSpace(); - - deConversion3x3 f3x3 = getConversion3x3(colorSpace, deColorSpaceRGB); - if (!f3x3) - { - return; - } - - deConversion3x3 fLAB = getConversion3x3(colorSpace, deColorSpaceLAB); - if (!fLAB) - { - return; - } - - - palette = new dePalette3(colorSpace); - paletteLAB = new dePalette3(deColorSpaceLAB); - - deChannelManager& channelManager = project.getPreviewChannelManager(); - deSize channelSize = channelManager.getChannelSize(); - - int cs = channelSize.getW(); - - int w = channelSize.getW() / tileW; - int h = channelSize.getH() / tileH; - - int n = w * h; - - int s = 2; - - wxSizer* sizer = new wxFlexGridSizer(w, s, s); - imageSizer->Add(sizer); - - int i; - - int y = 0; - int x = 0; - - for (i = 0; i < n; i++) - { - deColorPanel* colorPanel = new deColorPanel(imagePanel, wxSize(tileRW, tileRH), NULL, 0); - sizer->Add(colorPanel); - - int x1 = x * tileW; - int x2 = (x + 1) * tileW; - int y1 = y * tileH; - int y2 = (y + 1) * tileH; - - deValue sum1 = 0; - deValue sum2 = 0; - deValue sum3 = 0; - - deValue v1; - deValue v2; - deValue v3; - - int xx; - int yy; - - for (yy = y1; yy < y2; yy++) - { - int p = cs * yy + x1; - for (xx = x1; xx < x2; xx++) - { - image.getPixel(0, p, v1); - image.getPixel(1, p, v2); - image.getPixel(2, p, v3); - sum1 += v1; - sum2 += v2; - sum3 += v3; - p++; - } - } - - int ts = tileW * tileH; - - sum1 /= ts; - sum2 /= ts; - sum3 /= ts; - - palette->addColor(deColor3(sum1, sum2, sum3)); - - deValue r; - deValue g; - deValue b; - - f3x3(sum1, sum2, sum3, r, g, b); - - deValue L; - deValue A; - deValue B; - - fLAB(sum1, sum2, sum3, L, A, B); - paletteLAB->addColor(deColor3(L, A, B)); - - colorPanel->setRGB(r, g, b); - - x++; - if (x == w) - { - x = 0; - y++; - } - } - - deValue minA; - deValue maxA; - paletteLAB->getMinMax(2, minA, maxA); - deValue minB; - deValue maxB; - paletteLAB->getMinMax(3, minB, maxB); - - deValue deltaA = maxA - minA; - deValue deltaB = maxB - minB; - deValue delta = deltaA; - if (deltaB > delta) - { - delta = deltaB; - } - - deValue step = delta / LAB_TILES; - - int tiles = deltaA / step + 1; - - wxSizer* LABMapSizer = new wxFlexGridSizer(tiles, s, s); - LABSizer->Add(LABMapSizer); - - deValue A; - deValue B; - deValue rB; - - for (rB = minB; rB < maxB; rB += step) - { - B = maxB + minB - rB; - - for (A = minA; A < maxA; A += step) - { - deColorPanel* colorPanel = new deColorPanel(LABPanel, wxSize(LAB_TILE_SIZE, LAB_TILE_SIZE), NULL, 0); - LABMapSizer->Add(colorPanel); - - deValue L = 1.0; - - if (paletteLAB->find23(A, A + step, B, B + step, L)) - { - deValue r; - deValue g; - deValue b; - lab2rgb(L, A, B, r, g, b); - colorPanel->setRGB(r, g, b); - } - } - } - - palette2 = new dePalette3(colorSpace); - - palette2->optimize(*palette, palSize, margin); - - int s2 = 5; - - wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, palettePanel, _T("palette")); - paletteSizer->Add(sizerS); - - wxSizer* palSizer = new wxFlexGridSizer(palSize / 2, s2, s2); - sizerS->Add(palSizer); - - for (i = 0; i < palette2->getSize(); i++) - { - deColorPanel* colorPanel = new deColorPanel(palettePanel, wxSize(palW, palH), NULL, 0); - palSizer->Add(colorPanel); - - deValue r; - deValue g; - deValue b; - - deColor3 c = palette2->getColor(i); - - f3x3(c.getV1(), c.getV2(), c.getV3(), r, g, b); - - colorPanel->setRGB(r, g, b); - } - - Fit(); - -} - -deColorMatrixFrame::~deColorMatrixFrame() -{ - if (palette) - { - delete palette; - } - if (palette2) - { - delete palette2; - } - if (paletteLAB) - { - delete paletteLAB; - } -} - diff -Nru delaboratory-0.7/src/color_matrix_frame.h delaboratory-0.8/src/color_matrix_frame.h --- delaboratory-0.7/src/color_matrix_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_matrix_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_COLOR_MARTIX_FRAME6_H -#define _DE_COLOR_MATRIX_FRAME6_H - -#include "help_frame.h" -#include "palette.h" -class deProject; - -class deColorMatrixFrame:public deHelpFrame -{ - private: - deProject& project; - dePalette3* palette; - dePalette3* palette2; - dePalette3* paletteLAB; - public: - deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin); - virtual ~deColorMatrixFrame(); -}; - -class deColorMatrixFrame2:public deHelpFrame -{ - private: - public: - deColorMatrixFrame2(wxWindow *parent, deProject& _project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette); - virtual ~deColorMatrixFrame2(); -}; - -#endif diff -Nru delaboratory-0.7/src/color_matrix.h delaboratory-0.8/src/color_matrix.h --- delaboratory-0.7/src/color_matrix.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_matrix.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_COLOR_MATRIX_H -#define _DE_COLOR_MATRIX_H - -#include "value.h" - -class deColorMatrix -{ - private: - int width; - int height; - deValue minX; - deValue minY; - deValue maxX; - deValue maxY; - - deValue* matrix; - int* density; - public: - deColorMatrix(int _w, int _h); - virtual ~deColorMatrix(); - - void clear(); - void build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n); - void buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min); - - deValue get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const; - - -}; - -#endif diff -Nru delaboratory-0.7/src/color_space.cc delaboratory-0.8/src/color_space.cc --- delaboratory-0.7/src/color_space.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_space.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,691 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "color_space.h" -#include "channels.h" - -int getEqualizerChannel(deColorSpace colorSpace) -{ - switch (colorSpace) - { - case deColorSpaceBW: - return 0; - case deColorSpaceRGB: - return -1; - case deColorSpaceProPhoto: - return -1; - case deColorSpaceHSL: - return 0; - case deColorSpaceHSV: - return 0; - case deColorSpaceLAB: - return 0; - case deColorSpaceLCH: - return 2; - case deColorSpaceCMY: - return -1; - case deColorSpaceCMYK: - return 3; - default: - return 0; - } -} - -int getColorSpaceSize(const deColorSpace& colorSpace) -{ - switch (colorSpace) - { - case deColorSpaceBW: - return 1; - case deColorSpaceRGB: - return 3; - case deColorSpaceProPhoto: - return 3; - case deColorSpaceHSL: - return 3; - case deColorSpaceHSV: - return 3; - case deColorSpaceLAB: - return 3; - case deColorSpaceLCH: - return 3; - case deColorSpaceXYZ: - return 3; - case deColorSpaceCMY: - return 3; - case deColorSpaceCMYK: - return 4; - default: - return 0; - } -} - -void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max) -{ - min = 0; - max = 1; -} - -std::string getColorSpaceName(deColorSpace colorSpace) -{ - switch (colorSpace) - { - case deColorSpaceInvalid: - return "invalid"; - case deColorSpaceBW: - return "BW"; - case deColorSpaceRGB: - return "sRGB"; - case deColorSpaceProPhoto: - return "ProPhoto"; - case deColorSpaceHSL: - return "HSL"; - case deColorSpaceHSV: - return "HSV"; - case deColorSpaceLAB: - return "LAB"; - case deColorSpaceLCH: - return "LCH"; - case deColorSpaceXYZ: - return "XYZ"; - case deColorSpaceCMY: - return "CMY"; - case deColorSpaceCMYK: - return "CMYK"; - default: - return "unknown"; - } -} - -deColorSpace colorSpaceFromString(const std::string& name) -{ - if (name == "sRGB") - { - return deColorSpaceRGB; - } - if (name == "ProPhoto") - { - return deColorSpaceProPhoto; - } - if (name == "LAB") - { - return deColorSpaceLAB; - } - if (name == "LCH") - { - return deColorSpaceLCH; - } - if (name == "CMYK") - { - return deColorSpaceCMYK; - } - if (name == "HSL") - { - return deColorSpaceHSL; - } - if (name == "HSV") - { - return deColorSpaceHSV; - } - if (name == "BW") - { - return deColorSpaceBW; - } - if (name == "XYZ") - { - return deColorSpaceXYZ; - } - if (name == "CMY") - { - return deColorSpaceCMY; - } - - return deColorSpaceInvalid; -} - -std::string getChannelName(deColorSpace colorSpace, int channel) -{ - switch (colorSpace) - { - case deColorSpaceInvalid: - return "invalid"; - case deColorSpaceBW: - return "BW"; - case deColorSpaceRGB: - case deColorSpaceProPhoto: - { - switch (channel) - { - case DE_CHANNEL_RED: - return "red"; - case DE_CHANNEL_GREEN: - return "green"; - case DE_CHANNEL_BLUE: - return "blue"; - } - } - case deColorSpaceLAB: - switch (channel) - { - case DE_CHANNEL_L: - return "L"; - case DE_CHANNEL_A: - return "A"; - case DE_CHANNEL_B: - return "B"; - } - case deColorSpaceLCH: - switch (channel) - { - case DE_CHANNEL_L: - return "lightness"; - case DE_CHANNEL_C: - return "chroma"; - case DE_CHANNEL_H: - return "hue"; - } - case deColorSpaceXYZ: - switch (channel) - { - case DE_CHANNEL_X: - return "X"; - case DE_CHANNEL_Y: - return "Y"; - case DE_CHANNEL_Z: - return "Z"; - } - case deColorSpaceHSL: - switch (channel) - { - case DE_CHANNEL_HUE: - return "hue"; - case DE_CHANNEL_SATURATION: - return "saturation"; - case DE_CHANNEL_LIGHTNESS: - return "lightness"; - } - case deColorSpaceHSV: - switch (channel) - { - case DE_CHANNEL_HUE: - return "hue"; - case DE_CHANNEL_SATURATION: - return "saturation"; - case DE_CHANNEL_VALUE: - return "value"; - } - case deColorSpaceCMY: - case deColorSpaceCMYK: - switch (channel) - { - case DE_CHANNEL_CYAN: - return "cyan"; - case DE_CHANNEL_MAGENTA: - return "magenta"; - case DE_CHANNEL_YELLOW: - return "yellow"; - case DE_CHANNEL_KEY: - return "key"; - } - default: - return "unknown"; - } -} - -void getSupportedColorSpaces(std::vector& result) -{ - result.push_back(deColorSpaceRGB); - result.push_back(deColorSpaceProPhoto); - result.push_back(deColorSpaceBW); - result.push_back(deColorSpaceLAB); - result.push_back(deColorSpaceLCH); - result.push_back(deColorSpaceHSL); - result.push_back(deColorSpaceHSV); - result.push_back(deColorSpaceCMYK); -} - -wxColour getChannelwxColour(deColorSpace colorSpace, int channel) -{ - switch (colorSpace) - { - case deColorSpaceRGB: - case deColorSpaceProPhoto: - { - int g = 200; - switch (channel) - { - case DE_CHANNEL_RED: - return wxColour(g, 0, 0); - case DE_CHANNEL_GREEN: - return wxColour(0, g, 0); - case DE_CHANNEL_BLUE: - return wxColour(0, 0, g); - } - } - case deColorSpaceCMYK: - case deColorSpaceCMY: - { - int g = 240; - int g2 = 50; - switch (channel) - { - case DE_CHANNEL_CYAN: - return wxColour(0, g, g); - case DE_CHANNEL_MAGENTA: - return wxColour(g, 0, g); - case DE_CHANNEL_YELLOW: - return wxColour(g, g, 0); - case DE_CHANNEL_KEY: - return wxColour(g2, g2, g2); - } - } - default: - { - // in any other cases just use dark gray - int g = 50; - return wxColour(g, g, g); - } - } - -} - -deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v) -{ - if (colorSpace == deColorSpaceLAB) - { - if (channel == DE_CHANNEL_L) - { - return 100 * v; - } - else - { - return 200 * v - 100.0; - } - } - if (colorSpace == deColorSpaceRGB) - { - return 255 * v; - } - if (colorSpace == deColorSpaceProPhoto) - { - return 255 * v; - } - if ((colorSpace == deColorSpaceCMYK) || (colorSpace == deColorSpaceCMY)) - { - return 100 * v; - } - if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) - { - if (channel == DE_CHANNEL_HUE) - { - return 360 * v; - } - else - { - return 100 * v; - } - } - if (colorSpace == deColorSpaceLCH) - { - if (channel == DE_CHANNEL_H) - { - return 360 * v; - } - else - { - return 100 * v; - } - } - return v; -} - -void getBasicSettings(deColorSpace colorSpace, std::vector& settings1, std::vector& settings2) -{ - switch (colorSpace) - { - case deColorSpaceLAB: - { - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(0); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(0); - settings1.push_back(c); - - deBasicSetting s("saturation"); - s.setContrast(); - s.addChannel(1); - s.addChannel(2); - settings1.push_back(s); - - deBasicSetting gms("A tint"); - gms.setBrightness(); - gms.addChannel(1); - gms.setScale(0.5); - settings2.push_back(gms); - - deBasicSetting gmc("A contrast"); - gmc.setContrast(); - gmc.addChannel(1); - settings2.push_back(gmc); - - deBasicSetting bys("B tint"); - bys.setBrightness(); - bys.addChannel(2); - bys.setScale(0.5); - settings2.push_back(bys); - - deBasicSetting byc("B contrast"); - byc.setContrast(); - byc.addChannel(2); - settings2.push_back(byc); - - break; - } - - case deColorSpaceLCH: - { - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(0); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(0); - settings1.push_back(c); - - deBasicSetting st("saturation"); - st.setBrightness(); - st.addChannel(1); - st.setScale(0.5); - settings1.push_back(st); - - deBasicSetting s("C contrast"); - s.setContrast(); - s.addChannel(1); - settings2.push_back(s); - - deBasicSetting h("hue shift"); - h.setShift(); - h.addChannel(2); - settings2.push_back(h); - - break; - } - - case deColorSpaceHSV: - case deColorSpaceHSL: - { - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(2); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(2); - settings1.push_back(c); - - deBasicSetting st("saturation"); - st.setBrightness(); - st.addChannel(1); - settings1.push_back(st); - - deBasicSetting s("S contrast"); - s.setContrast(); - s.addChannel(1); - settings2.push_back(s); - - deBasicSetting h("hue shift"); - h.setShift(); - h.addChannel(0); - settings2.push_back(h); - - break; - } - - case deColorSpaceBW: - { - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(0); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(0); - settings1.push_back(c); - - break; - } - - case deColorSpaceRGB: - case deColorSpaceProPhoto: - { - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(0); - b.addChannel(1); - b.addChannel(2); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(0); - c.addChannel(1); - c.addChannel(2); - settings1.push_back(c); - - deBasicSetting b0("Red tint"); - b0.setBrightness(); - b0.addChannel(0); - settings2.push_back(b0); - - deBasicSetting c0("Red contrast"); - c0.setContrast(); - c0.addChannel(0); - settings2.push_back(c0); - - deBasicSetting b1("Green tint"); - b1.setBrightness(); - b1.addChannel(1); - settings2.push_back(b1); - - deBasicSetting c1("Green contrast"); - c1.setContrast(); - c1.addChannel(1); - settings2.push_back(c1); - - deBasicSetting b2("Blue tint"); - b2.setBrightness(); - b2.addChannel(2); - settings2.push_back(b2); - - deBasicSetting c2("Blue contrast"); - c2.setContrast(); - c2.addChannel(2); - settings2.push_back(c2); - - break; - } - - case deColorSpaceCMYK: - case deColorSpaceCMY: - { - bool cmyk = false; - if (colorSpace == deColorSpaceCMYK) - { - cmyk = true; - } - - deBasicSetting b("brightness"); - b.setBrightness(); - b.addChannel(0); - b.addChannel(1); - b.addChannel(2); - if (cmyk) - { - b.addChannel(3); - } - b.setScale(-1); - settings1.push_back(b); - - deBasicSetting c("contrast"); - c.setContrast(); - c.addChannel(0); - c.addChannel(1); - c.addChannel(2); - if (cmyk) - { - c.addChannel(3); - } - settings1.push_back(c); - - deBasicSetting b0("Cyan tint"); - b0.setBrightness(); - b0.addChannel(0); - settings2.push_back(b0); - - deBasicSetting c0("Cyan contrast"); - c0.setContrast(); - c0.addChannel(0); - settings2.push_back(c0); - - deBasicSetting b1("Magenta tint"); - b1.setBrightness(); - b1.addChannel(1); - settings2.push_back(b1); - - deBasicSetting c1("Magenta contrast"); - c1.setContrast(); - c1.addChannel(1); - settings2.push_back(c1); - - deBasicSetting b2("Yellow tint"); - b2.setBrightness(); - b2.addChannel(2); - settings2.push_back(b2); - - deBasicSetting c2("Yellow contrast"); - c2.setContrast(); - c2.addChannel(2); - settings2.push_back(c2); - - if (cmyk) - { - deBasicSetting b3("Key tint"); - b3.setBrightness(); - b3.addChannel(3); - settings2.push_back(b3); - - deBasicSetting c3("Key contrast"); - c3.setContrast(); - c3.addChannel(3); - settings2.push_back(c3); - } - - break; - } - - default: - break; - - - }; -} - -bool isChannelLuminance(deColorSpace colorSpace, int channel) -{ - switch (colorSpace) - { - case deColorSpaceLAB: - case deColorSpaceLCH: - { - if (channel == 0) - { - return true; - } - break; - } - case deColorSpaceHSV: - case deColorSpaceHSL: - { - if (channel == 2) - { - return true; - } - break; - } - default: - { - return true; - break; - } - } - - return false; -} - -bool isChannelWrapped(deColorSpace colorSpace, int channel) -{ - switch (colorSpace) - { - case deColorSpaceLCH: - { - if (channel == 2) - { - return true; - } - break; - } - case deColorSpaceHSV: - case deColorSpaceHSL: - { - if (channel == 0) - { - return true; - } - break; - } - default: - break; - } - - return false; -} - -bool isActionSupported(const std::string& action, deColorSpace colorSpace) -{ - if ((action == "equalizer8") || (action == "equalizer16")) - { - switch (colorSpace) - { - case deColorSpaceRGB: - case deColorSpaceCMY: - case deColorSpaceProPhoto: - return false; - default: - return true; - } - } - return true; -} diff -Nru delaboratory-0.7/src/color_space.h delaboratory-0.8/src/color_space.h --- delaboratory-0.7/src/color_space.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/color_space.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_COLOR_SPACE_H -#define _DE_COLOR_SPACE_H - -#include "value.h" -#include -#include -#include -#include "basic_setting.h" - -enum deColorSpace -{ - deColorSpaceInvalid, - deColorSpaceRGB, - deColorSpaceProPhoto, - deColorSpaceBW, - deColorSpaceLAB, - deColorSpaceCMY, - deColorSpaceCMYK, - deColorSpaceHSV, - deColorSpaceHSL, - deColorSpaceXYZ, - deColorSpaceLCH -}; - -int getColorSpaceSize(const deColorSpace& colorSpace); -void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max); -std::string getColorSpaceName(deColorSpace colorSpace); -std::string getChannelName(deColorSpace colorSpace, int channel); -deColorSpace colorSpaceFromString(const std::string& name); - -void getSupportedColorSpaces(std::vector& result); -void getSupportedConversions(const deColorSpace& colorSpace, std::vector& result); - -wxColour getChannelwxColour(deColorSpace colorSpace, int channel); - -deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v); - -void getBasicSettings(deColorSpace colorSpace, std::vector& settings1, std::vector& settings2); - -bool isChannelLuminance(deColorSpace colorSpace, int channel); - -int getEqualizerChannel(deColorSpace colorSpace); -bool isChannelWrapped(deColorSpace colorSpace, int channel); - -bool isActionSupported(const std::string& action, deColorSpace colorSpace); - -#endif diff -Nru delaboratory-0.7/src/control_panel.cc delaboratory-0.8/src/control_panel.cc --- delaboratory-0.7/src/control_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/control_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,328 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "control_panel.h" -#include "project.h" -#include "conversion_functions.h" -#include "layer.h" -#include "layer_factory.h" -#include "layer_grid_panel.h" -#include "file_dialogs.h" -#include "layer_processor.h" -#include "wx/notebook.h" -#include "layer_stack.h" -#include "layer_frame_manager.h" -#include "frame_factory.h" - -const int g_txt = 220; - -deControlPanel::deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deLayerGridPanel* _layerGridPanel) -:wxPanel(parent), project(_project), layerGridPanel(_layerGridPanel), layerProcessor(_processor) -{ - autoUI = false; - - project.setControlPanel(this); - - mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); - mainSizer->Add(notebook, 1, wxEXPAND); - - std::vector actionGroups; - getSupportedActionGroups(actionGroups); - - std::vector actions; - getSupportedActions(actions); - - std::vector::iterator i; - for (i = actionGroups.begin(); i != actionGroups.end(); i++) - { - std::string n = *i; - - wxPanel* actionsPanel = new wxPanel(notebook); - notebook->AddPage(actionsPanel, wxString::FromAscii(n.c_str())); - - wxSizer* gridSizer = new wxGridSizer(3); - actionsPanel->SetSizer(gridSizer); - - std::vector::iterator j; - for (j = actions.begin(); j != actions.end(); j++) - { - std::string an = getActionGroup(*j); - if (an == n) - { - std::string actionDescription = getActionDescription(*j); - wxButton* b = new wxButton(actionsPanel, wxID_ANY, wxString::FromAscii(actionDescription.c_str())); - gridSizer->Add(b); - actionButtons.push_back(b); - actionButtonsNames[b->GetId()] = *j; - } - } - - } - - { - wxPanel* conversionsPanel = new wxPanel(notebook); - notebook->AddPage(conversionsPanel, _T("colorspace")); - - std::vector colorSpaces; - getSupportedColorSpaces(colorSpaces); - - wxSizer* gridSizer = new wxGridSizer(3); - conversionsPanel->SetSizer(gridSizer); - - std::vector::iterator i; - for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) - { - std::string n = getColorSpaceName(*i); - wxButton* b = new wxButton(conversionsPanel, wxID_ANY, wxString::FromAscii(n.c_str())); - gridSizer->Add(b); - convertButtons.push_back(b); - convertButtonsColorSpaces[b->GetId()] = *i; - } - } - - - wxSizer* hSizer = new wxBoxSizer(wxHORIZONTAL); - mainSizer->Add(hSizer, 0, wxCENTER); - - wxSizer* sizerD = new wxStaticBoxSizer(wxVERTICAL, this, _T("delete")); - hSizer->Add(sizerD, 1, wxCENTER); - { - deleteLayer = new wxButton(this, wxID_ANY, _T("delete top layer")); - sizerD->Add(deleteLayer, 0, wxCENTER); - } - - - { - - wxSizer* sizerE = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("export")); - mainSizer->Add(sizerE, 0, wxCENTER); - - { - exportJPEG = new wxButton(this, wxID_ANY, _T("JPEG")); - sizerE->Add(exportJPEG, 0); - } - { - exportTIFF = new wxButton(this, wxID_ANY, _T("16-bit TIFF")); - sizerE->Add(exportTIFF, 0); - } - { - externalEditor = new wxButton(this, wxID_ANY, _T("send to GIMP")); - sizerE->Add(externalEditor, 0); - } - } - - - setConversions(); - - Layout(); - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deControlPanel::click)); -} - -deControlPanel::~deControlPanel() -{ -} - -void deControlPanel::setConversions() -{ - deViewManager& viewManager = project.getViewManager(); - int view = viewManager.getView(); - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(view); - - if (!layer) - { - return; - } - - deColorSpace currentColorSpace = layer->getColorSpace(); - - std::vector::iterator i; - for (i = convertButtons.begin(); i != convertButtons.end(); i++) - { - wxButton* b = *i; - int id = b->GetId(); - deColorSpace colorSpace = convertButtonsColorSpaces[id]; - - bool valid = checkConversion(currentColorSpace, colorSpace); - - if ((currentColorSpace != colorSpace) && (valid)) - { - b->Enable(); - } - else - { - b->Disable(); - } - } - - for (i = actionButtons.begin(); i != actionButtons.end(); i++) - { - wxButton* b = *i; - std::string action = actionButtonsNames[b->GetId()]; - - if (isActionSupported(action, currentColorSpace)) - { - b->Enable(); - } - else - { - b->Disable(); - } - - } -} - -void deControlPanel::onChangeView() -{ - setConversions(); -} - -bool deControlPanel::generateFinalImage(const std::string& app, const std::string& type, const std::string& name) -{ - wxProgressDialog* progressDialog = new wxProgressDialog(_T("generate final image"), _T("generate final image"), 100, GetParent(), wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME); - - bool result = project.exportFinalImage(app, type, name, progressDialog); - - delete progressDialog; - - return result; -} - -void deControlPanel::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - if (deleteLayer->GetId() == id) - { - deLayerStack& layerStack = project.getLayerStack(); - int index = layerStack.getSize() - 1; - project.getLayerFrameManager().onDestroyLayer(index); - layerProcessor.removeTopLayer(); - updateLayerGrid(); - } - - if (exportJPEG->GetId() == id) - { - std::string f = getSaveFile(this, "export JPEG", "jpeg"); - - if (!f.empty()) - { - if (f.rfind(".jpg") != f.size() - 4) - { - f += ".jpg"; - } - - generateFinalImage("", "jpeg", f); - } - } - - if (exportTIFF->GetId() == id) - { - std::string f = getSaveFile(this, "export TIFF", "tiff"); - - if (!f.empty()) - { - if (f.rfind(".tiff") != f.size() - 5) - { - f += ".tiff"; - } - - generateFinalImage("", "tiff", f); - } - } - - if (externalEditor->GetId() == id) - { - generateFinalImage("gimp", "tiff", ""); - } - - std::map::iterator c = convertButtonsColorSpaces.find(id); - if (c != convertButtonsColorSpaces.end()) - { - deColorSpace colorSpace = c->second; - project.addConversionLayer(colorSpace); - onAddLayer(); - } - - std::map::iterator a = actionButtonsNames.find(id); - if (a != actionButtonsNames.end()) - { - std::string action = a->second; - project.addActionLayer(action); - onAddLayer(); - } - -} - -void deControlPanel::updateLayerGrid() -{ - layerGridPanel->clearRows(); - layerGridPanel->buildRows(); - layerGridPanel->Layout(); - layerProcessor.onGUIUpdate(); -} - -void deControlPanel::onKey(int key) -{ - if (key == 'B') - { - project.addActionLayer("blur"); - } - if (key == 'C') - { - project.addActionLayer("curves"); - } - if (key == 'M') - { - project.addActionLayer("mixer"); - } -} - - -void deControlPanel::onAddLayer() -{ - if (autoUI) - { - deLayerFrameManager& frameManager = project.getLayerFrameManager(); - deLayerStack& layerStack = project.getLayerStack(); - int n = layerStack.getSize() - 1; - deLayer* layer = layerStack.getLayer(n); - project.log("auto UI - creating action frame"); - deFrame* actionFrame = createFrame(this, *layer, layerProcessor, frameManager); - if (actionFrame) - { - project.log("auto UI - created action frame"); - actionFrame->Show(true); - } - } -} - -bool deControlPanel::getAutoUI() const -{ - return autoUI; -} - -void deControlPanel::setAutoUI(bool a) -{ - autoUI = a; -} diff -Nru delaboratory-0.7/src/control_panel.h delaboratory-0.8/src/control_panel.h --- delaboratory-0.7/src/control_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/control_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONTROL_PANEL_H -#define _DE_CONTROL_PANEL_H - -#include -#include -#include -#include "color_space.h" -class deProject; -class deLayerGridPanel; -class deLayerProcessor; - -class deControlPanel:public wxPanel -{ - private: - deProject& project; - deLayerGridPanel* layerGridPanel; - deLayerProcessor& layerProcessor; - wxSizer* mainSizer; - - bool autoUI; - - wxButton* exportJPEG; - wxButton* exportTIFF; - wxButton* externalEditor; - - std::map convertButtonsColorSpaces; - std::vector convertButtons; - - std::map actionButtonsNames; - std::vector actionButtons; - - wxButton* deleteLayer; - - void click(wxCommandEvent &event); - - void setConversions(); - - bool generateFinalImage(const std::string& app, const std::string& type, const std::string& name); - - void onAddLayer(); - - public: - deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deLayerGridPanel* _layerGridPanel); - ~deControlPanel(); - - void onChangeView(); - - void updateLayerGrid(); - - void onKey(int key); - - bool getAutoUI() const; - void setAutoUI(bool a); - -}; - - -#endif diff -Nru delaboratory-0.7/src/conversion_bw2hue_layer.cc delaboratory-0.8/src/conversion_bw2hue_layer.cc --- delaboratory-0.7/src/conversion_bw2hue_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_bw2hue_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "conversion_bw2hue_layer.h" -#include "layer_stack.h" -#include "layer_processor.h" -#include "convert_image.h" -#include "channel_manager.h" -#include "view_manager.h" -#include "frame_factory.h" -#include "blend_mode.h" -#include "layer_processor.h" -#include "logger.h" - -deConversionBW2HueLayer::deConversionBW2HueLayer(int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deColorSpace _colorSpace) -:deConversionLayer(_colorSpace, _index, _sourceLayer, _layerStack, _channelManager), -hue("hue"), saturation("saturation") -{ - reset(); -} - -deConversionBW2HueLayer::~deConversionBW2HueLayer() -{ -} - -void deConversionBW2HueLayer::reset() -{ - hue.set(0.0); - saturation.set(0.00); -} - -void deConversionBW2HueLayer::preset(deValue h) -{ - hue.set(h); - saturation.set(0.05); -} - -void fill(deValue* pixels, int n, deValue v) -{ - int i; - for (i = 0; i < n; i++) - { - pixels[i] = v; - } -} - -bool deConversionBW2HueLayer::updateImage() -{ - logMessage("conversion start"); - - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - - image.enableAllChannels(); - convertImage(sourceImage, image, channelManager); - - deChannel* dc0 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(2)); - - deValue* p0 = dc0->getPixels(); - deValue* p1 = dc1->getPixels(); - deValue* p2 = dc2->getPixels(); - - int n = channelManager.getChannelSize().getN(); - - switch (colorSpace) - { - case deColorSpaceHSL: - { - fill(p0, n, hue.get()); - fill(p1, n, saturation.get()); - break; - } - case deColorSpaceHSV: - { - fill(p0, n, hue.get()); - fill(p1, n, saturation.get()); - break; - } - case deColorSpaceLCH: - { - fill(p2, n, hue.get()); - fill(p1, n, saturation.get()); - break; - } - default: - break; - } - - logMessage("conversion end"); - - return true; -} - -void deConversionBW2HueLayer::save(xmlNodePtr root) -{ - saveCommon(root); - hue.save(root); - saturation.save(root); -} - -void deConversionBW2HueLayer::load(xmlNodePtr root) -{ - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - hue.load(child); - saturation.load(child); - - child = child->next; - } -} diff -Nru delaboratory-0.7/src/conversion_bw2hue_layer.h delaboratory-0.8/src/conversion_bw2hue_layer.h --- delaboratory-0.7/src/conversion_bw2hue_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_bw2hue_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERSION_BW2HUE_LAYER_H -#define _DE_CONVERSION_BW2HUE_LAYER_H - -#include "conversion_layer.h" -#include "mixer.h" -#include "property_value.h" -class deViewManager; - -class deConversionBW2HueLayer:public deConversionLayer -{ - private: - dePropertyValue hue; - dePropertyValue saturation; - - virtual bool hasAction() const {return true;}; - - virtual std::string getType() const {return "conversion_bw2hue";}; - public: - deConversionBW2HueLayer(int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deColorSpace _colorSpace); - virtual ~deConversionBW2HueLayer(); - - virtual bool updateImage(); - - dePropertyValue& getPropertyHue() {return hue;}; - dePropertyValue& getPropertySaturation() {return saturation;}; - - virtual std::string getActionName() {return "setup";}; - - void reset(); - void preset(deValue h); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - -}; - -#endif diff -Nru delaboratory-0.7/src/conversion_bw_layer.cc delaboratory-0.8/src/conversion_bw_layer.cc --- delaboratory-0.7/src/conversion_bw_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_bw_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,407 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "conversion_bw_layer.h" -#include "layer_stack.h" -#include "layer_processor.h" -#include "convert_image.h" -#include "channel_manager.h" -#include "view_manager.h" -#include "frame_factory.h" -#include "blend_mode.h" -#include "layer_processor.h" -#include "logger.h" - -deConversionBWLayer::deConversionBWLayer(int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, int n) -:deConversionLayer(deColorSpaceBW, _index, _sourceLayer, _layerStack, _channelManager), - add0("add_0"), - add1("add_1"), - add2("add_2"), - add3("add_3"), - overlay0("overlay_0"), - overlay1("overlay_1"), - overlay2("overlay_2"), - overlay3("overlay_3") -{ - add0.setMin(-1.0); - add0.setMax(3.0); - add1.setMin(-1.0); - add1.setMax(3.0); - add2.setMin(-1.0); - add2.setMax(3.0); - - deLayer* source = layerStack.getLayer(sourceLayer); - deColorSpace sourceColorSpace = source->getColorSpace(); - int cs = getColorSpaceSize(sourceColorSpace); - - resetM(); - - add0.setLabel(getChannelName(sourceColorSpace, 0)); - add1.setLabel(getChannelName(sourceColorSpace, 1)); - add2.setLabel(getChannelName(sourceColorSpace, 2)); - - overlay0.setLabel(getChannelName(sourceColorSpace, 0)); - overlay1.setLabel(getChannelName(sourceColorSpace, 1)); - overlay2.setLabel(getChannelName(sourceColorSpace, 2)); - - if (cs == 4) - { - add3.setMin(-1.0); - add3.setMax(3.0); - add3.setLabel(getChannelName(sourceColorSpace, 3)); - overlay3.setLabel(getChannelName(sourceColorSpace, 3)); - } - - if (sourceColorSpace == deColorSpaceRGB) - { - // http://www.markushartel.com/blog/learn-from-markus/channel-mixer-settings - // http://www.darktable.org/usermanual/ch03s04s36.html.php - // http://www.pbase.com/digitalrebel/bw_film_types - // http://www.flickr.com/groups/blackwhite/discuss/72157594354861228/ - // http://oxle.com/topic.asp?archive=true&tid=5243 - // http://keith_towers.webs.com/channelmixersettings.htm - films.push_back(deFilm("AGFA 200X", 18, 41, 41)); - films.push_back(deFilm("Agfapan 25", 25, 39, 36)); - films.push_back(deFilm("Agfapan 100", 21, 40, 39)); - films.push_back(deFilm("Agfapan 400", 20, 41, 39)); - films.push_back(deFilm("Ilford Delta 100", 21, 42, 37)); - films.push_back(deFilm("Ilford Delta 400", 22, 42, 36)); - films.push_back(deFilm("Ilford Delta 3200", 31, 36, 33)); - films.push_back(deFilm("Ilford FP4", 28, 41, 31)); - films.push_back(deFilm("Ilford HP5", 23, 37, 40)); - films.push_back(deFilm("Ilford Pan F", 33, 36, 31)); - films.push_back(deFilm("Ilford SFX", 36, 31, 33)); - films.push_back(deFilm("Ilford XP2 Super", 21, 42, 37)); - films.push_back(deFilm("Kodak T-Max 100", 24, 37, 39)); - films.push_back(deFilm("Kodak T-Max 400", 27, 36, 37)); - films.push_back(deFilm("Kodak Tri-X 400", 25, 35, 40)); - } -} - -deConversionBWLayer::~deConversionBWLayer() -{ -} - -void deConversionBWLayer::resetM() -{ - deLayer* source = layerStack.getLayer(sourceLayer); - deColorSpace sourceColorSpace = source->getColorSpace(); - switch (sourceColorSpace) - { - case deColorSpaceRGB: - case deColorSpaceProPhoto: - { - add0.set(0.3); - add1.set(0.6); - add2.set(0.1); - add3.set(0.0); - break; - } - case deColorSpaceCMYK: - { - add0.set(0.0); - add1.set(0.0); - add2.set(0.0); - add3.set(1.0); - break; - } - case deColorSpaceLAB: - case deColorSpaceLCH: - { - add0.set(1.0); - add1.set(0.0); - add2.set(0.0); - add3.set(0.0); - break; - } - case deColorSpaceHSV: - case deColorSpaceHSL: - { - add0.set(0.0); - add1.set(0.0); - add2.set(1.0); - add3.set(0.0); - break; - } - default: - { - add0.set(0.3); - add1.set(0.3); - add2.set(0.3); - add3.set(0.0); - break; - } - } - overlay0.set(0); - overlay1.set(0); - overlay2.set(0); - overlay3.set(0); -} - -void deConversionBWLayer::presetM(int c) -{ - add0.set(0); - add1.set(0); - add2.set(0); - add3.set(0); - if (c == 0) - { - add0.set(1.0); - } - if (c == 1) - { - add1.set(1.0); - } - if (c == 2) - { - add2.set(1.0); - } - if (c == 3) - { - add3.set(1.0); - } -} - -bool deConversionBWLayer::updateImage() -{ - logMessage("conversion BW start"); - - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - - deColorSpace sourceColorSpace = source->getColorSpace(); - int cs = getColorSpaceSize(sourceColorSpace); - - image.enableAllChannels(); - - int n = channelManager.getChannelSize().getN(); - - deChannel* sc0 = NULL; - deChannel* sc1 = NULL; - deChannel* sc2 = NULL; - deChannel* sc3 = NULL; - - sc0 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - sc1 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - sc2 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - - if (!sc0) - { - return false; - } - if (!sc1) - { - return false; - } - if (!sc2) - { - return false; - } - - if (cs == 4) - { - sc3 = channelManager.getChannel(sourceImage.getChannelIndex(3)); - if (!sc3) - { - return false; - } - } - - deChannel* dc = channelManager.getChannel(image.getChannelIndex(0)); - - if (!dc) - { - return false; - } - - dc->lockWrite(); - - deValue* d = dc->getPixels(); - - sc0->lockRead(); - sc1->lockRead(); - sc2->lockRead(); - if (sc3) - { - sc3->lockRead(); - } - - deValue* v0 = NULL; - deValue* v1 = NULL; - deValue* v2 = NULL; - deValue* v3 = NULL; - - if (sc0) - { - v0 = sc0->getPixels(); - } - if (sc1) - { - v1 = sc1->getPixels(); - } - if (sc2) - { - v2 = sc2->getPixels(); - } - if (sc3) - { - v3 = sc3->getPixels(); - } - - deValue a0 = add0.get(); - deValue a1 = add1.get(); - deValue a2 = add2.get(); - deValue a3 = add3.get(); - deValue o0 = overlay0.get(); - deValue o1 = overlay1.get(); - deValue o2 = overlay2.get(); - deValue o3 = overlay3.get(); - - int i; - for (i = 0; i < n; i++) - { - deValue result = 0.0; - - result += v0[i] * a0; - result += v1[i] * a1; - result += v2[i] * a2; - if (v3) - { - result += v3[i] * a3; - } - - if (result < 0) - { - result = 0; - } - - if (result > 1) - { - result = 1; - } - - deValue blend0 = calcBlendResult(result, v0[i], deBlendOverlay); - deValue blend1 = calcBlendResult(result, v1[i], deBlendOverlay); - deValue blend2 = calcBlendResult(result, v2[i], deBlendOverlay); - deValue blend3 = 0; - if (v3) - { - blend3 = calcBlendResult(result, v3[i], deBlendOverlay); - } - - result = result * (1 - o0) + blend0 * o0; - result = result * (1 - o1) + blend1 * o1; - result = result * (1 - o2) + blend2 * o2; - if (v3) - { - result = result * (1 - o3) + blend3 * o3; - } - - if (sourceColorSpace == deColorSpaceCMYK) - { - result = 1 - result; - } - - if (result < 0) - { - result = 0; - } - - if (result > 1) - { - result = 1; - } - - d[i] = result; - } - - sc0->unlockRead(); - sc1->unlockRead(); - sc2->unlockRead(); - if (sc3) - { - sc3->unlockRead(); - } - dc->unlockWrite(); - - logMessage("conversion BW end"); - - return true; -} - -deColorSpace deConversionBWLayer::getSourceColorSpace() const -{ - deLayer* source = layerStack.getLayer(sourceLayer); - return source->getColorSpace(); -} - -void deConversionBWLayer::save(xmlNodePtr root) -{ - saveCommon(root); - add0.save(root); - add1.save(root); - add2.save(root); - add3.save(root); - overlay0.save(root); - overlay1.save(root); - overlay2.save(root); - overlay3.save(root); -} - -void deConversionBWLayer::load(xmlNodePtr root) -{ - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - add0.load(child); - add1.load(child); - add2.load(child); - add3.load(child); - overlay0.load(child); - overlay1.load(child); - overlay2.load(child); - overlay3.load(child); - - child = child->next; - } -} - -void deConversionBWLayer::applyFilm(int f) -{ - if (f < 0) - { - return; - } - if ((unsigned int)f >= films.size()) - { - return; - } - deFilm& film = films[f]; - - add0.set(film.getR()); - add1.set(film.getG()); - add2.set(film.getB()); - - add3.set(0.0); - overlay0.set(0); - overlay1.set(0); - overlay2.set(0); - overlay3.set(0); - -} diff -Nru delaboratory-0.7/src/conversion_bw_layer.h delaboratory-0.8/src/conversion_bw_layer.h --- delaboratory-0.7/src/conversion_bw_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_bw_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERSION_BW_LAYER_H -#define _DE_CONVERSION_BW_LAYER_H - -#include "conversion_layer.h" -#include "mixer.h" -#include "property_value.h" -#include -class deViewManager; - -class deFilm -{ - private: - std::string name; - deValue r; - deValue g; - deValue b; - public: - deFilm(const std::string& _name, deValue _r, deValue _g, deValue _b) - :name(_name), r(_r), g(_g), b(_b) - { - } - virtual ~deFilm() - { - } - - deValue getR() {return r / 100.0;}; - deValue getG() {return g / 100.0;}; - deValue getB() {return b / 100.0;}; - - std::string getName() const {return name;}; -}; - - -class deConversionBWLayer:public deConversionLayer -{ - private: - dePropertyValue add0; - dePropertyValue add1; - dePropertyValue add2; - dePropertyValue add3; - dePropertyValue overlay0; - dePropertyValue overlay1; - dePropertyValue overlay2; - dePropertyValue overlay3; - std::vector films; - - virtual bool hasAction() const {return true;}; - - virtual std::string getType() const {return "conversion_bw";}; - public: - deConversionBWLayer(int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, int n); - virtual ~deConversionBWLayer(); - - virtual bool updateImage(); - - deColorSpace getSourceColorSpace() const; - - dePropertyValue& getAdd0() {return add0;}; - dePropertyValue& getAdd1() {return add1;}; - dePropertyValue& getAdd2() {return add2;}; - dePropertyValue& getAdd3() {return add3;}; - dePropertyValue& getOverlay0() {return overlay0;}; - dePropertyValue& getOverlay1() {return overlay1;}; - dePropertyValue& getOverlay2() {return overlay2;}; - dePropertyValue& getOverlay3() {return overlay3;}; - - virtual std::string getActionName() {return "mixer";}; - - void resetM(); - void presetM(int c); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - const std::vector& getFilms() const {return films;}; - - void applyFilm(int f); - -}; - -#endif diff -Nru delaboratory-0.7/src/conversion_functions.cc delaboratory-0.8/src/conversion_functions.cc --- delaboratory-0.7/src/conversion_functions.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_functions.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,916 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "conversion_functions.h" -#include "rgb2xyz2lab.h" -#include "hsl_hsv.h" -#include "cmyk.h" -#include "bw.h" - -void copy(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - d1 = s1; - d2 = s2; - d3 = s3; -} - -void rgb2lab(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue x; - deValue y; - deValue z; - - rgb2xyz(s1, s2, s3, x, y, z); - - xyz2lab(x, y, z, d1, d2, d3); -} - -void prophoto2lab(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue x; - deValue y; - deValue z; - - prophoto2xyz(s1, s2, s3, x, y, z); - - xyz2lab(x, y, z, d1, d2, d3); -} - -void prophoto2lch(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue x; - deValue y; - deValue z; - - prophoto2xyz(s1, s2, s3, x, y, z); - - deValue l; - deValue a; - deValue b; - - xyz2lab(x, y, z, l, a, b); - - lab2lch(l, a, b, d1, d2, d3); -} - - -void lab2rgb(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue x; - deValue y; - deValue z; - - lab2xyz(s1, s2, s3, x, y, z); - - xyz2rgb(x, y, z, d1, d2, d3); -} - -void lab2prophoto(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue x; - deValue y; - deValue z; - - lab2xyz(s1, s2, s3, x, y, z); - - xyz2prophoto(x, y, z, d1, d2, d3); -} - - -void cmyk2rgb(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1, deValue& d2, deValue& d3) -{ - deValue c; - deValue m; - deValue y; - - cmyk2cmy(s1, s2, s3, s4, c, m, y); - - cmy2rgb(c, m, y, d1, d2, d3); -} - -void cmyk2hsv(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1, deValue& d2, deValue& d3) -{ - deValue c; - deValue m; - deValue y; - - cmyk2cmy(s1, s2, s3, s4, c, m, y); - - deValue r; - deValue g; - deValue b; - - cmy2rgb(c, m, y, r, g, b); - - rgb2hsv(r, g, b, d1, d2, d3); -} - -void lab2hsl(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - lab2rgb(s1, s2, s3, r, g, b); - - rgb2hsl(r, g, b, d1, d2, d3); -} - -void lab2hsv(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - lab2rgb(s1, s2, s3, r, g, b); - - rgb2hsv(r, g, b, d1, d2, d3); -} - -void lch2hsv(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue l; - deValue a; - deValue b; - - lch2lab(s1, s2, s3, l, a, b); - - lab2hsv(l, a, b, d1, d2, d3); -} - -void lch2hsl(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue l; - deValue a; - deValue b; - - lch2lab(s1, s2, s3, l, a, b); - - lab2hsl(l, a, b, d1, d2, d3); -} - - -void cmyk2hsl(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1, deValue& d2, deValue& d3) -{ - deValue c; - deValue m; - deValue y; - - cmyk2cmy(s1, s2, s3, s4, c, m, y); - - deValue r; - deValue g; - deValue b; - - cmy2rgb(c, m, y, r, g, b); - - rgb2hsl(r, g, b, d1, d2, d3); -} - -void cmyk2lab(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1, deValue& d2, deValue& d3) -{ - deValue c; - deValue m; - deValue y; - - cmyk2cmy(s1, s2, s3, s4, c, m, y); - - deValue r; - deValue g; - deValue b; - - cmy2rgb(c, m, y, r, g, b); - - rgb2lab(r, g, b, d1, d2, d3); -} - -void cmyk2lch(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1, deValue& d2, deValue& d3) -{ - deValue l; - deValue a; - deValue b; - - cmyk2lab(s1, s2, s3, s4, l, a, b); - - lab2lch(l, a, b, d1, d2, d3); -} - -void rgb2lch(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue l; - deValue a; - deValue b; - - rgb2lab(s1, s2, s3, l, a, b); - - lab2lch(l, a, b, d1, d2, d3); -} - -void rgb2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue c; - deValue m; - deValue y; - - rgb2cmy(s1, s2, s3, c, m, y); - - cmy2cmyk(c, m, y, d1, d2, d3, d4); -} - -void hsv2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue r; - deValue g; - deValue b; - - hsv2rgb(s1, s2, s3, r, g, b); - - rgb2cmyk(r, g, b, d1, d2, d3, d4); -} - -void hsl2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue r; - deValue g; - deValue b; - - hsl2rgb(s1, s2, s3, r, g, b); - - rgb2cmyk(r, g, b, d1, d2, d3, d4); -} - -void prophoto2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue r; - deValue g; - deValue b; - - prophoto2rgb(s1, s2, s3, r, g, b); - - deValue c; - deValue m; - deValue y; - - rgb2cmy(r, g, b, c, m, y); - - cmy2cmyk(c, m, y, d1, d2, d3, d4); -} - -void prophoto2hsv(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - prophoto2rgb(s1, s2, s3, r, g, b); - - rgb2hsv(r, g, b, d1, d2, d3); -} - -void prophoto2hsl(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - prophoto2rgb(s1, s2, s3, r, g, b); - - rgb2hsl(r, g, b, d1, d2, d3); -} - - -void bw2cmyk(deValue s1, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue r; - deValue g; - deValue b; - - bw2rgb(s1, r, g, b); - - rgb2cmyk(r, g, b, d1, d2, d3, d4); -} - -void bw2lab(deValue s1, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - bw2rgb(s1, r, g, b); - - rgb2lab(r, g, b, d1, d2, d3); -} - -void lab2bw(deValue s1, deValue s2, deValue s3, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - lab2rgb(s1, s2, s3, r, g, b); - - rgb2bw(r, g, b, d); -} - -void cmyk2bw(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - cmyk2rgb(s1, s2, s3, s4, r, g, b); - - rgb2bw(r, g, b, d); -} - -void hsv2bw(deValue s1, deValue s2, deValue s3, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - hsv2rgb(s1, s2, s3, r, g, b); - - rgb2bw(r, g, b, d); -} - -void hsl2bw(deValue s1, deValue s2, deValue s3, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - hsl2rgb(s1, s2, s3, r, g, b); - - rgb2bw(r, g, b, d); -} - -void hsl2lab(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsl2rgb(s1, s2, s3, r, g, b); - - rgb2lab(r, g, b, d1, d2, d3); -} - -void hsv2lab(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsv2rgb(s1, s2, s3, r, g, b); - - rgb2lab(r, g, b, d1, d2, d3); -} - -void hsl2hsv(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsl2rgb(s1, s2, s3, r, g, b); - - rgb2hsv(r, g, b, d1, d2, d3); -} - -void hsv2hsl(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsv2rgb(s1, s2, s3, r, g, b); - - rgb2hsl(r, g, b, d1, d2, d3); -} - -void hsl2lch(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsl2rgb(s1, s2, s3, r, g, b); - - rgb2lch(r, g, b, d1, d2, d3); -} - -void hsv2lch(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - hsv2rgb(s1, s2, s3, r, g, b); - - rgb2lch(r, g, b, d1, d2, d3); -} - -void lch2rgb(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3) -{ - deValue l; - deValue a; - deValue b; - - lch2lab(s1, s2, s3, l, a, b); - - lab2rgb(l, a, b, d1, d2, d3); -} - -void lch2bw(deValue s1, deValue s2, deValue s3, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - lch2rgb(s1, s2, s3, r, g, b); - - rgb2bw(r, g, b, d); -} - - -void prophoto2bw(deValue s1, deValue s2, deValue s3, deValue& d) -{ - deValue r; - deValue g; - deValue b; - - prophoto2rgb(s1, s2, s3, r, g, b); - - rgb2bw(r, g, b, d); -} - -void bw2hsl(deValue s1, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - bw2rgb(s1, r, g, b); - - rgb2hsl(r, g, b, d1, d2, d3); -} - -void bw2hsv(deValue s1, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - bw2rgb(s1, r, g, b); - - rgb2hsv(r, g, b, d1, d2, d3); -} - -void bw2lch(deValue s1, deValue& d1, deValue& d2, deValue& d3) -{ - deValue r; - deValue g; - deValue b; - - bw2rgb(s1, r, g, b); - - rgb2lch(r, g, b, d1, d2, d3); -} - - -void lab2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue x; - deValue y; - deValue z; - - lab2xyz(s1, s2, s3, x, y, z); - - deValue r; - deValue g; - deValue b; - - xyz2rgb(x, y, z, r, g, b); - - deValue _c; - deValue _m; - deValue _y; - - rgb2cmy(r, g, b, _c, _m, _y); - - cmy2cmyk(_c, _m, _y, d1, d2, d3, d4); -} - -void lch2cmyk(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4) -{ - deValue l; - deValue a; - deValue b; - - lch2lab(s1, s2, s3, l, a, b); - - lab2cmyk(l, a, b, d1, d2, d3, d4); -} - - -deConversion4x3 getConversion4x3(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceCMYK) && (d == deColorSpaceRGB)) - { - return cmyk2rgb; - } - - if ((s == deColorSpaceCMYK) && (d == deColorSpaceCMY)) - { - return cmyk2cmy; - } - - if ((s == deColorSpaceCMYK) && (d == deColorSpaceHSV)) - { - return cmyk2hsv; - } - - if ((s == deColorSpaceCMYK) && (d == deColorSpaceHSL)) - { - return cmyk2hsl; - } - - if ((s == deColorSpaceCMYK) && (d == deColorSpaceLAB)) - { - return cmyk2lab; - } - - if ((s == deColorSpaceCMYK) && (d == deColorSpaceLCH)) - { - return cmyk2lch; - } - - return NULL; -} - -deConversion3x4 getConversion3x4(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceRGB) && (d == deColorSpaceCMYK)) - { - return rgb2cmyk; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceCMYK)) - { - return hsv2cmyk; - } - - if ((s == deColorSpaceHSL) && (d == deColorSpaceCMYK)) - { - return hsl2cmyk; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceCMYK)) - { - return prophoto2cmyk; - } - - if ((s == deColorSpaceCMY) && (d == deColorSpaceCMYK)) - { - return cmy2cmyk; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceCMYK)) - { - return lab2cmyk; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceCMYK)) - { - return lch2cmyk; - } - - return NULL; -} - -deConversion4x1 getConversion4x1(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceCMYK) && (d == deColorSpaceBW)) - { - return cmyk2bw; - } - - return false; -} - -deConversion3x1 getConversion3x1(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceRGB) && (d == deColorSpaceBW)) - { - return rgb2bw; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceBW)) - { - return hsv2bw; - } - - if ((s == deColorSpaceHSL) && (d == deColorSpaceBW)) - { - return hsl2bw; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceBW)) - { - return lab2bw; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceBW)) - { - return lch2bw; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceBW)) - { - return prophoto2bw; - } - - return NULL; -} - -deConversion1x3 getConversion1x3(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceBW) && (d == deColorSpaceRGB)) - { - return bw2rgb; - } - - if ((s == deColorSpaceBW) && (d == deColorSpaceLAB)) - { - return bw2lab; - } - - if ((s == deColorSpaceBW) && (d == deColorSpaceHSL)) - { - return bw2hsl; - } - - if ((s == deColorSpaceBW) && (d == deColorSpaceHSV)) - { - return bw2hsv; - } - - if ((s == deColorSpaceBW) && (d == deColorSpaceLCH)) - { - return bw2lch; - } - - return NULL; -} - -deConversion1x4 getConversion1x4(deColorSpace s, deColorSpace d) -{ - if ((s == deColorSpaceBW) && (d == deColorSpaceCMYK)) - { - return bw2cmyk; - } - - return NULL; -} - -deConversion3x3 getConversion3x3(deColorSpace s, deColorSpace d) -{ - if (s == d) - { - return copy; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceLAB)) - { - return rgb2lab; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceXYZ)) - { - return rgb2xyz; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceXYZ)) - { - return prophoto2xyz; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceLAB)) - { - return prophoto2lab; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceLCH)) - { - return prophoto2lch; - } - - if ((d == deColorSpaceProPhoto) && (s == deColorSpaceXYZ)) - { - return xyz2prophoto; - } - - if ((d == deColorSpaceProPhoto) && (s == deColorSpaceLAB)) - { - return lab2prophoto; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceProPhoto)) - { - return rgb2prophoto; - } - - if ((d == deColorSpaceRGB) && (s == deColorSpaceProPhoto)) - { - return prophoto2rgb; - } - - if ((s == deColorSpaceXYZ) && (d == deColorSpaceLAB)) - { - return xyz2lab; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceLCH)) - { - return rgb2lch; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceLCH)) - { - return lab2lch; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceLAB)) - { - return lch2lab; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceRGB)) - { - return lab2rgb; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceXYZ)) - { - return lab2xyz; - } - - if ((s == deColorSpaceXYZ) && (d == deColorSpaceRGB)) - { - return xyz2rgb; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceRGB)) - { - return lch2rgb; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceHSL)) - { - return rgb2hsl; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceHSL)) - { - return lab2hsl; - } - - if ((s == deColorSpaceLAB) && (d == deColorSpaceHSV)) - { - return lab2hsv; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceHSL)) - { - return lch2hsl; - } - - if ((s == deColorSpaceLCH) && (d == deColorSpaceHSV)) - { - return lch2hsv; - } - - if ((s == deColorSpaceHSL) && (d == deColorSpaceRGB)) - { - return hsl2rgb; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceHSV)) - { - return rgb2hsv; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceHSV)) - { - return prophoto2hsv; - } - - if ((s == deColorSpaceProPhoto) && (d == deColorSpaceHSL)) - { - return prophoto2hsl; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceRGB)) - { - return hsv2rgb; - } - - if ((s == deColorSpaceRGB) && (d == deColorSpaceCMY)) - { - return rgb2cmy; - } - - if ((s == deColorSpaceCMY) && (d == deColorSpaceRGB)) - { - return cmy2rgb; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceLAB)) - { - return hsv2lab; - } - - if ((s == deColorSpaceHSL) && (d == deColorSpaceLAB)) - { - return hsl2lab; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceLCH)) - { - return hsv2lch; - } - - if ((s == deColorSpaceHSL) && (d == deColorSpaceLCH)) - { - return hsl2lch; - } - - if ((s == deColorSpaceHSV) && (d == deColorSpaceHSL)) - { - return hsv2hsl; - } - - if ((d == deColorSpaceHSV) && (s == deColorSpaceHSL)) - { - return hsl2hsv; - } - - return NULL; -} - -bool checkConversion(deColorSpace currentColorSpace, deColorSpace colorSpace) -{ - if (getConversion3x3(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion1x4(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion4x3(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion3x4(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion1x3(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion3x1(currentColorSpace, colorSpace)) - { - return true; - } - - if (getConversion4x1(currentColorSpace, colorSpace)) - { - return true; - } - - return false; -} - diff -Nru delaboratory-0.7/src/conversion_functions.h delaboratory-0.8/src/conversion_functions.h --- delaboratory-0.7/src/conversion_functions.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_functions.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERSION_FUNCTIONS_H -#define _DE_CONVERSION_FUNCTIONS_H - -#include "value.h" -#include "color_space.h" - -typedef void (*deConversion3x1)(deValue s1, deValue s2, deValue s3, deValue& d1); -typedef void (*deConversion4x1)(deValue s1, deValue s2, deValue s3, deValue s4, deValue& d1); -typedef void (*deConversion1x3)(deValue s1, deValue& d1, deValue& d2, deValue& d3); -typedef void (*deConversion1x4)(deValue s1, deValue& d1, deValue& d2, deValue& d3, deValue& d4); -typedef void (*deConversion3x3)(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3); -typedef void (*deConversion4x3)(deValue s0, deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3); -typedef void (*deConversion3x4)(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3, deValue& d4); - -deConversion1x3 getConversion1x3(deColorSpace s, deColorSpace d); -deConversion1x4 getConversion1x4(deColorSpace s, deColorSpace d); -deConversion3x1 getConversion3x1(deColorSpace s, deColorSpace d); -deConversion4x1 getConversion4x1(deColorSpace s, deColorSpace d); -deConversion3x3 getConversion3x3(deColorSpace s, deColorSpace d); -deConversion3x4 getConversion3x4(deColorSpace s, deColorSpace d); -deConversion4x3 getConversion4x3(deColorSpace s, deColorSpace d); - -bool checkConversion(deColorSpace currentColorSpace, deColorSpace colorSpace); - -void lab2rgb(deValue s1, deValue s2, deValue s3, deValue& d1, deValue& d2, deValue& d3); - -#endif diff -Nru delaboratory-0.7/src/conversion_layer.cc delaboratory-0.8/src/conversion_layer.cc --- delaboratory-0.7/src/conversion_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "conversion_layer.h" -#include "project.h" -#include "convert_image.h" -#include "layer_processor.h" -#include "layer_stack.h" - -deConversionLayer::deConversionLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager) -:deLayer("conversion", _colorSpace, _index, _sourceLayer), - layerStack(_layerStack), - channelManager(_channelManager), - image(_colorSpace, _channelManager) -{ - -} - -deConversionLayer::~deConversionLayer() -{ -} - -const deImage& deConversionLayer::getImage() const -{ - return image; -} - -bool deConversionLayer::updateImage() -{ - logMessage("conversion start"); - - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - - image.enableAllChannels(); - convertImage(sourceImage, image, channelManager); - - logMessage("conversion end"); - - return true; -} - -void deConversionLayer::updateChannelUsage(std::map& channelUsage) const -{ - deLayer* source = layerStack.getLayer(sourceLayer); - const deImage& sourceImage = source->getImage(); - sourceImage.updateChannelUsage(channelUsage, index); - image.updateChannelUsage(channelUsage, index); -} - diff -Nru delaboratory-0.7/src/conversion_layer.h delaboratory-0.8/src/conversion_layer.h --- delaboratory-0.7/src/conversion_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/conversion_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERSION_LAYER_H -#define _DE_CONVERSION_LAYER_H - -#include "layer.h" -#include "image.h" -class deLayerStack; -class deChannelManager; - -class deConversionLayer:public deLayer -{ - private: - virtual std::string getType() const {return "conversion";}; - - protected: - deLayerStack& layerStack; - deChannelManager& channelManager; - deImage image; - - public: - deConversionLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager); - virtual ~deConversionLayer(); - - virtual const deImage& getImage() const; - virtual bool updateImage(); - - virtual void updateChannelUsage(std::map& channelUsage) const; - - virtual void load(xmlNodePtr root) {}; - virtual void save(xmlNodePtr root) {saveCommon(root);}; - - virtual bool randomize() {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/convert_image.cc delaboratory-0.8/src/convert_image.cc --- delaboratory-0.7/src/convert_image.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/convert_image.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,405 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "convert_image.h" -#include "copy_image.h" -#include "image.h" -#include "conversion_functions.h" -#include "channel_manager.h" - - -void convertImage3x3(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion3x3 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - deChannel* sc2 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - if (!sc2) - { - return; - } - deChannel* sc3 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - if (!sc3) - { - return; - } - - sc1->lockRead(); - sc2->lockRead(); - sc3->lockRead(); - - deValue* s1 = sc1->getPixels(); - deValue* s2 = sc2->getPixels(); - deValue* s3 = sc3->getPixels(); - - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(image.getChannelIndex(2)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - - deValue* d1 = dc1->getPixels(); - deValue* d2 = dc2->getPixels(); - deValue* d3 = dc3->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], s2[i], s3[i], d1[i], d2[i], d3[i]); - } - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - - sc1->unlockRead(); - sc2->unlockRead(); - sc3->unlockRead(); - -} - -void convertImage3x4(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion3x4 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - deChannel* sc2 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - if (!sc2) - { - return; - } - deChannel* sc3 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - if (!sc3) - { - return; - } - - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(image.getChannelIndex(2)); - deChannel* dc4 = channelManager.getChannel(image.getChannelIndex(3)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - dc4->lockWrite(); - - sc1->lockRead(); - sc2->lockRead(); - sc3->lockRead(); - - deValue* d1 = channelManager.getChannel(image.getChannelIndex(0))->getPixels(); - deValue* d2 = channelManager.getChannel(image.getChannelIndex(1))->getPixels(); - deValue* d3 = channelManager.getChannel(image.getChannelIndex(2))->getPixels(); - deValue* d4 = channelManager.getChannel(image.getChannelIndex(3))->getPixels(); - - deValue* s1 = sc1->getPixels(); - deValue* s2 = sc2->getPixels(); - deValue* s3 = sc3->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], s2[i], s3[i], d1[i], d2[i], d3[i], d4[i]); - } - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - dc4->unlockWrite(); - - sc1->unlockRead(); - sc2->unlockRead(); - sc3->unlockRead(); - -} - -void convertImage4x3(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion4x3 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - deChannel* sc2 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - if (!sc2) - { - return; - } - deChannel* sc3 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - if (!sc3) - { - return; - } - deChannel* sc4 = channelManager.getChannel(sourceImage.getChannelIndex(3)); - if (!sc4) - { - return; - } - - sc1->lockRead(); - sc2->lockRead(); - sc3->lockRead(); - sc4->lockRead(); - - deValue* s1 = sc1->getPixels(); - deValue* s2 = sc2->getPixels(); - deValue* s3 = sc3->getPixels(); - deValue* s4 = sc4->getPixels(); - - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(image.getChannelIndex(2)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - - deValue* d1 = channelManager.getChannel(image.getChannelIndex(0))->getPixels(); - deValue* d2 = channelManager.getChannel(image.getChannelIndex(1))->getPixels(); - deValue* d3 = channelManager.getChannel(image.getChannelIndex(2))->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], s2[i], s3[i], s4[i], d1[i], d2[i], d3[i]); - } - - sc1->unlockRead(); - sc2->unlockRead(); - sc3->unlockRead(); - sc4->unlockRead(); - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - -} - -void convertImage1x3(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion1x3 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - - sc1->lockRead(); - - deValue* s1 = sc1->getPixels(); - - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(image.getChannelIndex(2)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - - deValue* d1 = channelManager.getChannel(image.getChannelIndex(0))->getPixels(); - deValue* d2 = channelManager.getChannel(image.getChannelIndex(1))->getPixels(); - deValue* d3 = channelManager.getChannel(image.getChannelIndex(2))->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], d1[i], d2[i], d3[i]); - } - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - - sc1->unlockRead(); - -} - -void convertImage1x4(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion1x4 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - - sc1->lockRead(); - - deValue* s1 = sc1->getPixels(); - - deChannel* dc1 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* dc2 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* dc3 = channelManager.getChannel(image.getChannelIndex(2)); - deChannel* dc4 = channelManager.getChannel(image.getChannelIndex(3)); - - dc1->lockWrite(); - dc2->lockWrite(); - dc3->lockWrite(); - dc4->lockWrite(); - - deValue* d1 = channelManager.getChannel(image.getChannelIndex(0))->getPixels(); - deValue* d2 = channelManager.getChannel(image.getChannelIndex(1))->getPixels(); - deValue* d3 = channelManager.getChannel(image.getChannelIndex(2))->getPixels(); - deValue* d4 = channelManager.getChannel(image.getChannelIndex(3))->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], d1[i], d2[i], d3[i], d4[i]); - } - - dc1->unlockWrite(); - dc2->unlockWrite(); - dc3->unlockWrite(); - dc4->unlockWrite(); - - sc1->unlockRead(); - -} - -void convertImage3x1(const deImage& sourceImage, deImage& image, deChannelManager& channelManager, deConversion3x1 conversion) -{ - int n = channelManager.getChannelSize().getN(); - - deChannel* sc1 = channelManager.getChannel(sourceImage.getChannelIndex(0)); - if (!sc1) - { - return; - } - deChannel* sc2 = channelManager.getChannel(sourceImage.getChannelIndex(1)); - if (!sc2) - { - return; - } - deChannel* sc3 = channelManager.getChannel(sourceImage.getChannelIndex(2)); - if (!sc3) - { - return; - } - - deValue* s1 = sc1->getPixels(); - deValue* s2 = sc2->getPixels(); - deValue* s3 = sc3->getPixels(); - - deValue* d1 = channelManager.getChannel(image.getChannelIndex(0))->getPixels(); - - int i; - - for (i = 0; i < n; i++) - { - conversion(s1[i], s2[i], s3[i], d1[i]); - } - -} - - -void convertImage(const deImage& sourceImage, deImage& image, deChannelManager& channelManager) -{ - deColorSpace sourceColorSpace = sourceImage.getColorSpace(); - deColorSpace targetColorSpace = image.getColorSpace(); - - if (sourceColorSpace == targetColorSpace) - { - copyImage(sourceImage, image, channelManager); - return; - } - - int sn = getColorSpaceSize(sourceColorSpace); - int tn = getColorSpaceSize(targetColorSpace); - - if ((sn == 3) && (tn == 3)) - { - deConversion3x3 conversion = getConversion3x3(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage3x3(sourceImage, image, channelManager, conversion); - return; - } - } - - if ((sn == 3) && (tn == 4)) - { - deConversion3x4 conversion = getConversion3x4(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage3x4(sourceImage, image, channelManager, conversion); - return; - } - } - - if ((sn == 4) && (tn == 3)) - { - deConversion4x3 conversion = getConversion4x3(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage4x3(sourceImage, image, channelManager, conversion); - return; - } - } - - if ((sn == 1) && (tn == 3)) - { - deConversion1x3 conversion = getConversion1x3(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage1x3(sourceImage, image, channelManager, conversion); - return; - } - } - - if ((sn == 1) && (tn == 4)) - { - deConversion1x4 conversion = getConversion1x4(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage1x4(sourceImage, image, channelManager, conversion); - return; - } - } - - if ((sn == 3) && (tn == 1)) - { - deConversion3x1 conversion = getConversion3x1(sourceColorSpace, targetColorSpace); - if (conversion) - { - convertImage3x1(sourceImage, image, channelManager, conversion); - return; - } - } - -} diff -Nru delaboratory-0.7/src/convert_image.h delaboratory-0.8/src/convert_image.h --- delaboratory-0.7/src/convert_image.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/convert_image.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERT_IMAGE_H -#define _DE_CONVERT_IMAGE_H - -class deImage; -class deChannelManager; - -void convertImage(const deImage& sourceImage, deImage& image, deChannelManager& channelManager); - -#endif diff -Nru delaboratory-0.7/src/convert_pixel.cc delaboratory-0.8/src/convert_pixel.cc --- delaboratory-0.7/src/convert_pixel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/convert_pixel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "convert_pixel.h" -#include "image.h" -#include "conversion_functions.h" -#include "channel_manager.h" - - -bool convertPixel(const deImage& image, int p, deColorSpace colorSpace, deValue &v1, deValue& v2, deValue& v3, deValue& v4) -{ - deColorSpace sourceColorSpace = image.getColorSpace(); - int sn = getColorSpaceSize(sourceColorSpace); - int tn = getColorSpaceSize(colorSpace); - - if ((sn == 3) && (tn == 3)) - { - deConversion3x3 conversion = getConversion3x3(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - deValue s2; - if (!image.getPixel(1, p, s2)) - { - return false; - } - deValue s3; - if (!image.getPixel(2, p, s3)) - { - return false; - } - conversion(s1, s2, s3, v1, v2, v3); - v4 = -1; - return true; - } - } - - if ((sn == 3) && (tn == 1)) - { - deConversion3x1 conversion = getConversion3x1(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - deValue s2; - if (!image.getPixel(1, p, s2)) - { - return false; - } - deValue s3; - if (!image.getPixel(2, p, s3)) - { - return false; - } - conversion(s1, s2, s3, v1); - return true; - } - } - - if ((sn == 3) && (tn == 4)) - { - deConversion3x4 conversion = getConversion3x4(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - deValue s2; - if (!image.getPixel(1, p, s2)) - { - return false; - } - deValue s3; - if (!image.getPixel(2, p, s3)) - { - return false; - } - conversion(s1, s2, s3, v1, v2, v3, v4); - return true; - } - } - - if ((sn == 4) && (tn == 4)) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - deValue s2; - if (!image.getPixel(1, p, s2)) - { - return false; - } - deValue s3; - if (!image.getPixel(2, p, s3)) - { - return false; - } - deValue s4; - if (!image.getPixel(3, p, s4)) - { - return false; - } - v1 = s1; - v2 = s2; - v3 = s3; - v4 = s4; - return true; - } - - if ((sn == 4) && (tn == 3)) - { - deConversion4x3 conversion = getConversion4x3(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - deValue s2; - if (!image.getPixel(1, p, s2)) - { - return false; - } - deValue s3; - if (!image.getPixel(2, p, s3)) - { - return false; - } - deValue s4; - if (!image.getPixel(3, p, s4)) - { - return false; - } - conversion(s1, s2, s3, s4, v1, v2, v3); - return true; - } - } - - if ((sn == 1) && (tn == 3)) - { - deConversion1x3 conversion = getConversion1x3(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - conversion(s1, v1, v2, v3); - return true; - } - } - - if ((sn == 1) && (tn == 4)) - { - deConversion1x4 conversion = getConversion1x4(sourceColorSpace, colorSpace); - - if (conversion) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - conversion(s1, v1, v2, v3, v4); - return true; - } - } - - if ((sn == 1) && (tn == 1)) - { - deValue s1; - if (!image.getPixel(0, p, s1)) - { - return false; - } - v1 = s1; - return true; - } - - return false; -} - diff -Nru delaboratory-0.7/src/convert_pixel.h delaboratory-0.8/src/convert_pixel.h --- delaboratory-0.7/src/convert_pixel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/convert_pixel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CONVERT_PIXEL_H -#define _DE_CONVERT_PIXEL_H - - -class deImage; -#include "color_space.h" -#include "value.h" - -bool convertPixel(const deImage& image, int p, deColorSpace colorSpace, deValue &v1, deValue& v2, deValue& v3, deValue& v4); - -#endif diff -Nru delaboratory-0.7/src/copy_channel.cc delaboratory-0.8/src/copy_channel.cc --- delaboratory-0.7/src/copy_channel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/copy_channel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "copy_channel.h" -#include - -void copyChannel(const deValue* src, deValue* dst, const deSize& size) -{ - int n = size.getN(); - - int i; - for (i = 0; i < n; i++) - { - deValue v = src[i]; - dst[i] = v; - } -} - diff -Nru delaboratory-0.7/src/copy_channel.h delaboratory-0.8/src/copy_channel.h --- delaboratory-0.7/src/copy_channel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/copy_channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_COPY_CHANNEL_H -#define _DE_COPY_CHANNEL_H - -#include "size.h" -#include "value.h" - -void copyChannel(const deValue* src, deValue* dst, const deSize& size); - -#endif diff -Nru delaboratory-0.7/src/copy_image.cc delaboratory-0.8/src/copy_image.cc --- delaboratory-0.7/src/copy_image.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/copy_image.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "copy_image.h" -#include "copy_channel.h" -#include "image.h" -#include "channel_manager.h" - -void copyImage(const deImage& sourceImage, const deImage& image, deChannelManager& channelManager) -{ - //int channelSize = channelManager.getChannelSize().getN(); - int n = getColorSpaceSize(sourceImage.getColorSpace()); - int i; - - for (i = 0; i < n; i++) - { - - int s = sourceImage.getChannelIndex(i); - deChannel* sourceChannel = channelManager.getChannel(s); - - int c = image.getChannelIndex(i); - deChannel* channel = channelManager.getChannel(c); - - sourceChannel->lockRead(); - channel->lockWrite(); - - copyChannel(sourceChannel->getPixels(), channel->getPixels(), channelManager.getChannelSize()); - - sourceChannel->unlockRead(); - channel->unlockWrite(); - } -} diff -Nru delaboratory-0.7/src/copy_image.h delaboratory-0.8/src/copy_image.h --- delaboratory-0.7/src/copy_image.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/copy_image.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_COPY_IMAGE_H -#define _DE_COPY_IMAGE_H - -class deImage; -class deChannelManager; - -void copyImage(const deImage& sourceImage, const deImage& image, deChannelManager& channelManager); - -#endif diff -Nru delaboratory-0.7/src/curve.cc delaboratory-0.8/src/curve.cc --- delaboratory-0.7/src/curve.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,572 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curve.h" -#include "channel.h" -#include -#include -#include -#include -#include "str.h" -#include "xml.h" -#include "logger.h" - -#define CURVE_POINT_PICK_DISTANCE 0.03 -#define VERTICAL_STEP 0.01 - -deCurve::deCurve() -:shape(256), - mutex(wxMUTEX_RECURSIVE) -{ - reset(); -} - -deCurve::~deCurve() -{ -} - -void deCurve::reset() -{ - lock(); - - points.clear(); - fill(1, 1, 0); - shape.build(points); - - unlock(); -} - -void deCurve::invert() -{ - lock(); - - points.clear(); - fill(1, -1, 0); - - shape.build(points); - - unlock(); -} - -void deCurve::setConst(deValue v) -{ - lock(); - - points.clear(); - points.push_back(deCurvePoint(0,v)); - points.push_back(deCurvePoint(1,v)); - shape.build(points); - - unlock(); -} - -void deCurve::setAngle(int a) -{ - lock(); - - if (a < 4) - { - deValue p1 = a / 8.0; - deValue p2 = 1 - p1; - points.clear(); - points.push_back(deCurvePoint(0,0)); - points.push_back(deCurvePoint(p1,0)); - points.push_back(deCurvePoint(p2,1)); - points.push_back(deCurvePoint(1,1)); - } - else - { - deValue p1 = (a - 3) / 8.0; - deValue p2 = 1 - p1; - points.clear(); - points.push_back(deCurvePoint(0,p1)); - points.push_back(deCurvePoint(1,p2)); - } - shape.build(points); - - unlock(); -} - -void deCurve::setS(int a) -{ - lock(); - - deValue h = a / 16.0; - deValue p1 = 1.0 / 4.0; - deValue p2 = 1.0 - 1.0 / 4.0; - - points.clear(); - points.push_back(deCurvePoint(0, 0)); - - points.push_back(deCurvePoint(p1, p1 - h)); - points.push_back(deCurvePoint(p2, p2 + h)); - - points.push_back(deCurvePoint(1, 1)); - shape.build(points); - - unlock(); -} - -void deCurve::setContrastBrightness(deValue contrast, deValue brightness) -{ - lock(); - - deValue p1 = 1.0 / 4.0; - deValue p2 = 1.0 - 1.0 / 4.0; - - deValue h0 = brightness + 0.0 + (-0.5 * contrast); - deValue h1 = brightness + p1 + (p1 - 0.5) * contrast; - deValue h2 = brightness + p2 + (1.0 - p2) * contrast; - deValue h3 = brightness + 1.0 + 0.5 * contrast; - - points.clear(); - points.push_back(deCurvePoint(0, h0)); - - points.push_back(deCurvePoint(p1, h1)); - points.push_back(deCurvePoint(p2, h2)); - - points.push_back(deCurvePoint(1, h3)); - shape.build(points); - - unlock(); -} - - -void deCurve::fill(int n, deValue a, deValue r) -{ - lock(); - - points.clear(); - double step = 1.0 / n; - double p = 0.0; - - srand(time(0)); - - while (p <= 1.0) - { - double y = p; - if (a < 0) - { - y = 1.0 - y; - } - deValue rr = r * ( (double) rand() / RAND_MAX ); - rr = 2 * rr - r; - y+= rr; - if (y < 0) - { - y = 0; - } - if (y > 1) - { - y = 1; - } - - points.push_back(deCurvePoint(p,y)); - p+=step; - } - shape.build(points); - - unlock(); -} - -deValue deCurve::calcValue(deValue value) -{ - lock(); - unlock(); - - return shape.calc(value); -} - -void deCurve::process(const deChannel& source, deChannel& destination, int n) -{ - lock(); - - const deValue* pixels = source.getPixels(); - deValue* p = destination.getPixels(); - - int i; - for (i = 0; i < n; i++) - { - deValue value = pixels[i]; - deValue result = shape.calc(value); - - if (result < 0) - { - p[i] = 0; - } - else if (result > 1) - { - p[i] = 1; - } - else - { - p[i] = result; - } - } - - unlock(); -} - -int deCurve::findPoint(deValue x, deValue y) const -{ - lock(); - - deCurvePoints::const_iterator j; - int i = 0; - - for (j = points.begin(); j != points.end(); j++) - { - const deCurvePoint& point = *j; - deValue xx = x - point.getX(); - float yy = y - point.getY(); - if (sqrt (xx * xx + yy * yy) < CURVE_POINT_PICK_DISTANCE) - { - unlock(); - return i; - } - i++; - } - - unlock(); - return -1; -} - -int deCurve::addPoint(deValue x, deValue y) -{ -// std::cout << "addPoint x = " << x << " y = " << y << std::endl; - if ((x <= 0) || (x >= 1)) - { - return -1; - } - if ((y < 0) || (y > 1)) - { - return -1; - } - - lock(); - - points.push_back(deCurvePoint(x,y)); - -// std::cout << "after addPoint, points.size() = " << points.size() << std::endl; - - shape.build(points); - - unlock(); - - return points.size() - 1; -} - -void deCurve::deletePoint(int p) -{ -// std::cout << "deletePoint p = " << p << std::endl; - lock(); - - deCurvePoints::iterator i = points.begin(); - while (p > 0) - { - i++; - p--; - } - - deValue xx = (*i).getX(); - - points.erase(i); - - if (xx == 0) - { - points.push_back(deCurvePoint(0,0)); - } - if (xx == 1) - { - points.push_back(deCurvePoint(1,1)); - } - -// std::cout << "after deletePoint, points.size() = " << points.size() << std::endl; - - shape.build(points); - - unlock(); -} - -void deCurve::movePoint(int p, deValue x, deValue y) -{ - if (p < 0) - { - std::cout << "ERROR p = " << p << std::endl; - return; - } - - if ((unsigned int)p >= points.size()) - { - std::cout << "ERROR p = " << p << " points.size() = " << points.size() << std::endl; - return; - } - - if ((x < 0) || (x > 1)) - { - return; - } - if ((y < 0) || (y > 1)) - { - return; - } - - lock(); - - deCurvePoints::iterator i = points.begin(); - while (p > 0) - { - i++; - p--; - } - - deValue xx = (*i).getX(); - - if (xx == 0) - { - x = 0; - } - else - { - if (x == 0) - { - unlock(); - return; - } - } - - if (xx == 1) - { - x = 1; - } - else - { - if (x == 1) - { - unlock(); - return; - } - } - - (*i).move(x, y); - shape.build(points); - - unlock(); -} - -void deCurve::movePointVertically(int p, deValue delta) -{ - if (p < 0) - { - std::cout << "ERROR p = " << p << std::endl; - return; - } - - if ((unsigned int)p >= points.size()) - { - std::cout << "ERROR p = " << p << " points.size() = " << points.size() << std::endl; - return; - } - - lock(); - - deCurvePoints::iterator i = points.begin(); - while (p > 0) - { - i++; - p--; - } - - deValue xx = (*i).getX(); - deValue yy = (*i).getY(); - - yy += delta; - - if (yy < 0.0) - { - yy = 0.0; - } - if (yy > 1.0) - { - yy = 1.0; - } - - (*i).move(xx, yy); - shape.build(points); - - unlock(); -} - -const deCurvePoints& deCurve::getPoints() const -{ - lock(); - unlock(); - - return points; -} - -const deCurvePoint& deCurve::getPoint(int n) const -{ - lock(); - - deCurvePoints::const_iterator i = points.begin(); - while (n > 0) - { - i++; - n--; - } - - unlock(); - return *i; -} - -void deCurve::getControlPoints(deCurvePoints& points) const -{ - lock(); - unlock(); - - shape.getControlPoints(points); -} - -void deCurve::getCurvePoints(deCurvePoints& points) const -{ - lock(); - unlock(); - - shape.getCurvePoints(points); -} - -void deCurve::save(xmlNodePtr node) const -{ - deCurvePoints::const_iterator i; - - for (i = points.begin(); i != points.end(); i++) - { - xmlNodePtr child = xmlNewChild(node, NULL, BAD_CAST("point"), NULL); - const deCurvePoint& point = *i; - - saveChild(child, "x", str(point.getX())); - saveChild(child, "y", str(point.getY())); - - } -} - -void deCurve::loadPoint(xmlNodePtr node) -{ - xmlNodePtr child = node->xmlChildrenNode; - - std::string xStr = ""; - std::string yStr = ""; - - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("x")))) - { - xStr = getContent(child); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("y")))) - { - yStr = getContent(child); - } - - child = child->next; - } - - deValue x = 0; - deValue y = 0; - - { - x = getValue(xStr); - } - - { - y = getValue(yStr); - } - - points.push_back(deCurvePoint(x,y)); -} - -void deCurve::load(xmlNodePtr node) -{ - points.clear(); - - xmlNodePtr child = node->xmlChildrenNode; - - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("point")))) - { - loadPoint(child); - } - - child = child->next; - } - - shape.build(points); -} - -bool deCurve::isNeutral() const -{ - lock(); - unlock(); - - if (points.size() != 2) - { - return false; - } - deCurvePoints::const_iterator i = points.begin(); - deCurvePoint a = *i; - if (a.getY() != 0) - { - return false; - } - i++; - deCurvePoint b = *i; - if (b.getY() != 1) - { - return false; - } - return true; -} - -void deCurve::lock() const -{ - lockWithLog(mutex, "curve mutex"); -} - -void deCurve::unlock() const -{ - mutex.Unlock(); -} - -void deCurve::addRandom() -{ - deValue x = (deValue) rand() / RAND_MAX; - - deValue v = calcValue(x); - - deValue y = (deValue) rand() / RAND_MAX; - - y *= 0.4; - y -= 0.2; - - y += v; - - addPoint(x, y); -} diff -Nru delaboratory-0.7/src/curve_function_bezier.cc delaboratory-0.8/src/curve_function_bezier.cc --- delaboratory-0.7/src/curve_function_bezier.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_function_bezier.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curve_function_bezier.h" - -deCurveFunctionBezier::deCurveFunctionBezier(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3) -:x0(_x0), - x3(_x3), - y0(_y0), - y1(_y1), - y2(_y2), - y3(_y3) -{ -} - -deCurveFunctionBezier::~deCurveFunctionBezier() -{ -} - - -deValue deCurveFunctionBezier::calc(deValue value) const -{ - deValue d = x3 - x0; - if (d == 0.0) - { - return y0; - } - - deValue t = (value - x0) / d; - deValue t1 = 1.0 - t; - - return (y0 * t1 * t1 * t1) + 3 * (y1 * t1 * t1 * t) + 3 * (y2 * t1 * t * t) + (y3 * t * t * t); -} - diff -Nru delaboratory-0.7/src/curve_function_bezier.h delaboratory-0.8/src/curve_function_bezier.h --- delaboratory-0.7/src/curve_function_bezier.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_function_bezier.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVE_FUNCTION_BEZIER_H -#define _DE_CURVE_FUNCTION_BEZIER_H - -#include "value.h" - -class deCurveFunctionBezier -{ - private: - deValue x0; - deValue x3; - deValue y0; - deValue y1; - deValue y2; - deValue y3; - - public: - deCurveFunctionBezier(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3); - virtual ~deCurveFunctionBezier(); - - virtual deValue calc(deValue value) const; -}; - -#endif diff -Nru delaboratory-0.7/src/curve.h delaboratory-0.8/src/curve.h --- delaboratory-0.7/src/curve.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVE_H -#define _DE_CURVE_H - -#include -#include "curve_point.h" -#include "curve_shape.h" -#include -#include - -class deChannel; - - -class deCurve -{ - private: - deCurvePoints points; - deCurveShape shape; - - mutable wxMutex mutex; - - void loadPoint(xmlNodePtr node); - - deCurve(const deCurve& c); - deCurve& operator=(const deCurve& c); - - void lock() const; - void unlock() const; - - public: - deCurve(); - virtual ~deCurve(); - - int findPoint(deValue x, deValue y) const; - int addPoint(deValue x, deValue y); - void deletePoint(int p); - void movePoint(int p, deValue x, deValue y); - - void process(const deChannel& source, deChannel& destination, int n); - - const deCurvePoints& getPoints() const; - void getControlPoints(deCurvePoints& points) const; - void getCurvePoints(deCurvePoints& points) const; - const deCurvePoint& getPoint(int n) const; - - void save(xmlNodePtr node) const; - void load(xmlNodePtr node); - - void reset(); - void setConst(deValue v); - void setAngle(int a); - void setS(int a); - void invert(); - void fill(int n, deValue a, deValue r); - - void setContrastBrightness(deValue contrast, deValue brightness); - - bool isNeutral() const; - - deValue calcValue(deValue value); - - void movePointVertically(int p, deValue delta); - - void addRandom(); - - - -}; - -#endif diff -Nru delaboratory-0.7/src/curve_point.cc delaboratory-0.8/src/curve_point.cc --- delaboratory-0.7/src/curve_point.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_point.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curve_point.h" - -deCurvePoint::deCurvePoint(deValue _x, deValue _y) -:x(_x), y(_y) -{ -} - -deCurvePoint::~deCurvePoint() -{ -} - -void deCurvePoint::move(deValue _x, deValue _y) -{ - x = _x; - y = _y; -} diff -Nru delaboratory-0.7/src/curve_point.h delaboratory-0.8/src/curve_point.h --- delaboratory-0.7/src/curve_point.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_point.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVE_POINT_H -#define _DE_CURVE_POINT_H - -#include "value.h" -#include - -class deCurvePoint -{ - private: - deValue x; - deValue y; - - deCurvePoint(); - public: - deCurvePoint(deValue _x, deValue _y); - virtual ~deCurvePoint(); - - deValue getX() const {return x;}; - deValue getY() const {return y;}; - - void move(deValue _x, deValue _y); - -}; - -typedef std::list deCurvePoints; - -#endif diff -Nru delaboratory-0.7/src/curves.cc delaboratory-0.8/src/curves.cc --- delaboratory-0.7/src/curves.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curves.h" diff -Nru delaboratory-0.7/src/curves_editor.cc delaboratory-0.8/src/curves_editor.cc --- delaboratory-0.7/src/curves_editor.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_editor.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curves_editor.h" -#include "color_space.h" -#include "curves_layer.h" -#include "curves_panel.h" -#include "gradient_panel.h" - -deCurvesEditor::deCurvesEditor(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager) -{ - deCurvesLayer& curvesLayer = dynamic_cast(_layer); - - deColorSpace colorSpace = layer.getColorSpace(); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - int n = getColorSpaceSize(colorSpace); - wxString* channelStrings = new wxString [n]; - int i; - for (i = 0; i < n; i++) - { - channelStrings[i] = wxString::FromAscii(getChannelName(colorSpace,i).c_str()); - } - - channelChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), n, channelStrings); - channelChoice->SetSelection(0); - - delete [] channelStrings; - - sizer->Add(channelChoice); - - wxSizer* sizerSB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerSB); - - wxSizer* sizerC = new wxFlexGridSizer(2, 8, 8); - sizerSB->Add(sizerC); - - curvesPanel = new deCurvesPanel(this, curvesLayer, _layerProcessor); - - int barSize = 16; - - leftBar = new deGradientPanel1(this, wxSize(barSize, CURVES_PANEL_SIZE_Y), colorSpace, 0, -1, -1, -1, -1); - bottomBar = new deGradientPanel1(this, wxSize(CURVES_PANEL_SIZE_X, barSize), colorSpace, 0, -1, -1, -1, -1); - - sizerC->Add(leftBar, 0, wxCENTER); - sizerC->Add(curvesPanel, 0, wxCENTER); - sizerC->Add(-1, 0, wxCENTER); - sizerC->Add(bottomBar, 0, wxCENTER); - - wxSizer* sizerB = new wxGridSizer(5); - sizer->Add(sizerB, 0, wxCENTER); - - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(reset, 0); - - invert = new wxButton(this, wxID_ANY, _T("invert"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(invert, 0); - - const0 = new wxButton(this, wxID_ANY, _T("0"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(const0, 0); - - const05 = new wxButton(this, wxID_ANY, _T("0.5"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(const05, 0); - - const1 = new wxButton(this, wxID_ANY, _T("1"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(const1, 0); - - angle1 = new wxButton(this, wxID_ANY, _T("+ 1/4"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(angle1, 0); - angle2 = new wxButton(this, wxID_ANY, _T("+ 2/4"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(angle2, 0); - angle3 = new wxButton(this, wxID_ANY, _T("+ 3/4"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(angle3, 0); - angle4 = new wxButton(this, wxID_ANY, _T("- 1/4"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(angle4, 0); - angle5 = new wxButton(this, wxID_ANY, _T("- 2/4"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(angle5, 0); - - s1 = new wxButton(this, wxID_ANY, _T("S 1"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(s1, 0); - s2 = new wxButton(this, wxID_ANY, _T("S 2"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(s2, 0); - s3 = new wxButton(this, wxID_ANY, _T("S 3"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(s3, 0); - is1 = new wxButton(this, wxID_ANY, _T("invS 1"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(is1, 0); - is2 = new wxButton(this, wxID_ANY, _T("invS 2"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(is2, 0); - - random1 = new wxButton(this, wxID_ANY, _T("rnd 1"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(random1, 0); - random2 = new wxButton(this, wxID_ANY, _T("rnd 2"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(random2, 0); - random3 = new wxButton(this, wxID_ANY, _T("rnd 3"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(random3, 0); - random4 = new wxButton(this, wxID_ANY, _T("rnd 5"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(random4, 0); - random5 = new wxButton(this, wxID_ANY, _T("rnd 9"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(random5, 0); - - sizer->Layout(); - Fit(); - - int b = 0; - curvesPanel->changeChannel(b); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deCurvesEditor::click)); - Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deCurvesEditor::choose)); -} - -deCurvesEditor::~deCurvesEditor() -{ -} - -void deCurvesEditor::choose(wxCommandEvent &event) -{ - int b = channelChoice->GetCurrentSelection(); - curvesPanel->changeChannel(b); - leftBar->changeChannel(b); - bottomBar->changeChannel(b); -} - -void deCurvesEditor::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - if (reset->GetId() == id) - { - curvesPanel->reset(); - } - - if (invert->GetId() == id) - { - curvesPanel->invert(); - } - - if (const0->GetId() == id) - { - curvesPanel->setConst(0.0); - } - - if (const05->GetId() == id) - { - curvesPanel->setConst(0.5); - } - - if (const1->GetId() == id) - { - curvesPanel->setConst(1); - } - - if (angle1->GetId() == id) - { - curvesPanel->setAngle(1); - } - if (angle2->GetId() == id) - { - curvesPanel->setAngle(2); - } - if (angle3->GetId() == id) - { - curvesPanel->setAngle(3); - } - if (angle4->GetId() == id) - { - curvesPanel->setAngle(4); - } - if (angle5->GetId() == id) - { - curvesPanel->setAngle(5); - } - - if (s1->GetId() == id) - { - curvesPanel->setS(1); - } - if (s2->GetId() == id) - { - curvesPanel->setS(2); - } - if (s3->GetId() == id) - { - curvesPanel->setS(3); - } - if (is1->GetId() == id) - { - curvesPanel->setS(-1); - } - if (is2->GetId() == id) - { - curvesPanel->setS(-2); - } - - if (random1->GetId() == id) - { - curvesPanel->addRandom(1); - } - if (random2->GetId() == id) - { - curvesPanel->addRandom(2); - } - if (random3->GetId() == id) - { - curvesPanel->addRandom(3); - } - if (random4->GetId() == id) - { - curvesPanel->addRandom(5); - } - if (random5->GetId() == id) - { - curvesPanel->addRandom(9); - } -} - -bool deCurvesEditor::onImageClick(deValue x, deValue y) -{ - curvesPanel->onImageClick(x, y); - return true; -} - -void deCurvesEditor::onKey(int key) -{ - curvesPanel->onKey(key); -} diff -Nru delaboratory-0.7/src/curves_editor.h delaboratory-0.8/src/curves_editor.h --- delaboratory-0.7/src/curves_editor.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_editor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVES_EDITOR_H -#define _DE_CURVES_EDITOR_H - -#include "action_frame.h" -class deCurvesPanel; -class deGradientPanel1; -class deLayerProcessor; - -class deCurvesEditor:public deActionFrame -{ - private: - deCurvesPanel* curvesPanel; - - void choose(wxCommandEvent &event); - void click(wxCommandEvent &event); - - deGradientPanel1* leftBar; - deGradientPanel1* bottomBar; - - wxChoice* channelChoice; - wxButton* reset; - wxButton* invert; - wxButton* const0; - wxButton* const05; - wxButton* const1; - wxButton* angle1; - wxButton* angle2; - wxButton* angle3; - wxButton* angle4; - wxButton* angle5; - wxButton* random1; - wxButton* random2; - wxButton* random3; - wxButton* random4; - wxButton* random5; - wxButton* s1; - wxButton* s2; - wxButton* s3; - wxButton* is1; - wxButton* is2; - - public: - deCurvesEditor(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deCurvesEditor(); - - virtual bool onImageClick(deValue x, deValue y); - virtual void onKey(int key); - -}; - - -#endif diff -Nru delaboratory-0.7/src/curves.h delaboratory-0.8/src/curves.h --- delaboratory-0.7/src/curves.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVES_H -#define _DE_CURVES_H - -#include -#include "curve.h" - -typedef std::vector deCurves; - -#endif diff -Nru delaboratory-0.7/src/curve_shape.cc delaboratory-0.8/src/curve_shape.cc --- delaboratory-0.7/src/curve_shape.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_shape.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,217 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curve_shape.h" -#include -#include "curve_function_bezier.h" -#include - -deCurveShape::deCurveShape(int _size) -:size(_size) -{ - functions.reserve(size); - int i; - for (i = 0; i < size; i++) - { - functions[i] = NULL; - } -} - -deCurveShape::~deCurveShape() -{ - clearFunctions(); -} - -void deCurveShape::clearFunctions() -{ - int i; - for (i = 0; i < size; i++) - { - if (functions[i] != NULL) - { - delete functions[i]; - functions[i] = NULL; - } - } -} - -/* -void deCurveShape::storeValues(deValue x1, deValue y1, deValue x2, deValue y2) -{ - int p1 = x1 * (size - 1); - int p2 = x2 * (size - 1); - - int i; - for (i = p1; i <= p2; i++) - { - functions[i] = new deCurveFunctionLinear(x1, y1, x2, y2); - } - -} -*/ - -deValue deCurveShape::calc(deValue value) -{ - if ( value <= 0 ) - { - return functions[0]->calc(0); - } - else if (value >= 1) - { - return functions[size-1]->calc(1); - } - else - { - deValue s = size - 1; - int p = s * value; - - return functions[p]->calc(value); - } -} - -void deCurveShape::build(const deCurvePoints& points) -{ - nodes.clear(); - clearFunctions(); - deCurvePoints::const_iterator j; - - for (j = points.begin(); j != points.end(); j++) - { - const deCurvePoint& point = *j; - deValue x = point.getX(); - deValue y = point.getY(); - nodes.insert(std::pair(x, y)); - } - - generateBezier(); -} - -void deCurveShape::getControlPoints(deCurvePoints& points) const -{ - points.clear(); - - deNodes::const_iterator i; - for (i = nodes.begin(); i != nodes.end(); i++) - { - deValue x = i->first; - deValue y = i->second; - points.push_back(deCurvePoint(x,y)); - } - -} - -void deCurveShape::getCurvePoints(deCurvePoints& points) const -{ - points.clear(); - int i; - - deValue s = 1.0 / (size - 1); - for (i = 0; i < size; i++) - { - deValue x = i * s; - deValue y = functions[i]->calc(x); - points.push_back(deCurvePoint(x,y)); - } - -} - -void deCurveShape::generateBezier() -{ - /* math formulas from GIMP - gimp_curve_plot from gimpcurve.c */ - - deNodes::const_iterator i; - - for (i = nodes.begin(); i != nodes.end(); i++) - { - bool left = false; - bool right = false; - - deValue x0 = (*i).first; - deValue y0 = (*i).second; - deNodes::const_iterator j = i; - deNodes::const_iterator k = i; - j++; - k++; - deValue x3 = x0; - deValue y3 = y0; - if (j != nodes.end()) - { - x3 = (*j).first; - y3 = (*j).second; - k++; - if (k != nodes.end()) - { - right = true; - } - } - - deNodes::const_iterator h = i; - if (h != nodes.begin()) - { - h--; - left = true; - } - - deValue dx = x3 - x0; - deValue dy = y3 - y0; - - deValue y1; - deValue y2; - - if ((!left) && (!right)) - { - y1 = y0 + dy / 3.0; - y2 = y0 + dy * 2.0 / 3.0; - } - - if ((!left) && (right)) - { - deValue s = ((*k).second - y0) / ((*k).first - x0); - y2 = y3 - s * dx / 3.0; - y1 = y0 + (y2 - y0) / 2.0; - } - - if ((left) && (!right)) - { - deValue s = (y3 - (*h).second) / (x3 - (*h).first); - - y1 = y0 + s * dx / 3.0; - y2 = y3 + (y1 - y3) / 2.0; - } - - if ((left) && (right)) - { - deValue s1 = (y3 - (*h).second) / (x3 - (*h).first); - deValue s2 = ((*k).second - y0) / ((*k).first - x0); - - y1 = y0 + s1 * dx / 3.0; - y2 = y3 - s2 * dx / 3.0; - } - - - int p1 = x0 * (size - 1); - int p2 = x3 * (size - 1); - int iii; - for (iii = p1; iii <= p2; iii++) - { - functions[iii] = new deCurveFunctionBezier(x0, x3, y0, y1, y2, y3); - } - } - -} diff -Nru delaboratory-0.7/src/curve_shape.h delaboratory-0.8/src/curve_shape.h --- delaboratory-0.7/src/curve_shape.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curve_shape.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVE_SHAPE_H -#define _DE_CURVE_SHAPE_H - -#include -#include "value.h" -#include "curve_point.h" -#include - -typedef std::map deNodes; -class deCurveFunctionBezier; - -class deCurveShape -{ - private: - deNodes nodes; - std::vector functions; - int size; - -// void storeValues(deValue x1, deValue y1, deValue x2, deValue y2); - void clearFunctions(); - void generateSpline(); - void generateBezier(); - public: - deCurveShape(int _size); - ~deCurveShape(); - - void build(const deCurvePoints& points); - void getControlPoints(deCurvePoints& points) const; - void getCurvePoints(deCurvePoints& points) const; - - deValue calc(deValue value); -}; - -#endif diff -Nru delaboratory-0.7/src/curves_layer.cc delaboratory-0.8/src/curves_layer.cc --- delaboratory-0.7/src/curves_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curves_layer.h" -#include "project.h" -#include -#include - -#include "frame_factory.h" -#include "curves_editor.h" - -#include "str.h" - -deCurvesLayer::deCurvesLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - int n = getColorSpaceSize(colorSpace); - curves = new deCurve[n]; -} - -deCurvesLayer::~deCurvesLayer() -{ - delete [] curves; -} - -bool deCurvesLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("deCurvesLayer::processAction " + str(i)); - curves[i].process(sourceChannel, channel, size.getN()); - return true; -} - -deCurve* deCurvesLayer::getCurve(int index) -{ - int n = getColorSpaceSize(colorSpace); - if ((index < 0) || (index >= n)) - { - return NULL; - } - return &(curves[index]); -} - -bool deCurvesLayer::isChannelNeutral(int index) -{ - return curves[index].isNeutral(); -} - -void deCurvesLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - deCurve& curve = curves[i]; - xmlNodePtr child = xmlNewChild(root, NULL, BAD_CAST("curve"), NULL); - curve.save(child); - } -} - -void deCurvesLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - int i = 0; - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("curve")))) - { - //assert(i < n); - deCurve& curve = curves[i]; - curve.load(child); - i++; - } - - child = child->next; - } -} - -bool deCurvesLayer::randomize() -{ - int n = getColorSpaceSize(colorSpace); - - int c = rand() % n; - - curves[c].addRandom(); - - return true; -} diff -Nru delaboratory-0.7/src/curves_layer.h delaboratory-0.8/src/curves_layer.h --- delaboratory-0.7/src/curves_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVES_LAYER_H -#define _DE_CURVES_LAYER_H - -#include "action_layer.h" -#include "curve.h" - -class deCurvesLayer:public deActionLayer -{ - private: - deCurve* curves; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "curves";}; - - public: - deCurvesLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deCurvesLayer(); - - deCurve* getCurve(int index); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "curves";}; - - - virtual bool randomize(); - -}; - -#endif diff -Nru delaboratory-0.7/src/curves_panel.cc delaboratory-0.8/src/curves_panel.cc --- delaboratory-0.7/src/curves_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,534 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "curves_panel.h" -#include -#include "curves_layer.h" -#include "layer_processor.h" -#include "logger.h" - -BEGIN_EVENT_TABLE(deCurvesPanel, wxPanel) -EVT_PAINT(deCurvesPanel::paintEvent) -END_EVENT_TABLE() - -deCurvesPanel::deCurvesPanel(wxWindow* parent, deCurvesLayer& _layer, deLayerProcessor& _layerProcessor) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(CURVES_PANEL_SIZE_X, CURVES_PANEL_SIZE_Y)), -sizeX(CURVES_PANEL_SIZE_X), sizeY(CURVES_PANEL_SIZE_Y), layer(_layer), histogram(CURVES_PANEL_SIZE_X), -layerProcessor(_layerProcessor) -{ - SetFocus(); - Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deCurvesPanel::click)); - Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deCurvesPanel::release)); - Connect(wxEVT_MOTION, wxMouseEventHandler(deCurvesPanel::move)); - channel = 0; - selectedPoint = -1; - lastSelectedPoint = -1; - marker = -1; - - backgroundBitmap = NULL; - clickPosition = -1; - - generateBackground(); -} - -deCurvesPanel::~deCurvesPanel() -{ - delete backgroundBitmap; -} - -void deCurvesPanel::generateBackground() -{ - if (backgroundBitmap) - { - delete backgroundBitmap; - } - - deChannel* c = layer.getSourceChannel(channel); - int n = layer.getChannelSize().getN(); - - histogram.clear(); - histogram.calc(c, n); - - wxImage* image = new wxImage(sizeX, sizeY); - unsigned char* data = image->GetData(); - - unsigned char g1 = 220; - unsigned char g2 = 120; - - histogram.render(data, sizeX, sizeY, g1, g2); - - backgroundBitmap = new wxBitmap(*image); - delete image; -} - - -void deCurvesPanel::paintEvent(wxPaintEvent & evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void deCurvesPanel::render(wxDC& dc_orig) -{ - wxBufferedDC dc(&dc_orig, bitmap, wxBUFFER_CLIENT_AREA); - - int g = 50; - wxColour colourB(g, g, g); - wxBrush brush(colourB); - - dc.DrawBitmap(*backgroundBitmap, 0, 0, false); - - drawLines(dc); - - wxColour colour = getChannelwxColour(layer.getColorSpace(), channel); - wxPen pen(colour); - dc.SetPen(pen); - - drawCurve(dc); -} - -void deCurvesPanel::drawPoint(wxDC& dc, deValue x, deValue y) -{ - int xx = (sizeX - 1) * x; - int yy = (sizeY - 1) * (1 - y); - dc.DrawCircle(xx, yy, 5); -} - - -void deCurvesPanel::drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2) -{ - int xx1 = (sizeX - 1) * x1; - int xx2 = (sizeX - 1) * x2; - int yy1 = (sizeY - 1) * (1 - y1); - int yy2 = (sizeY - 1) * (1 - y2); - dc.DrawLine(xx1, yy1, xx2, yy2); -} - -void deCurvesPanel::drawLines(wxDC& dc) -{ - int g1 = 180; - int g2 = 80; - - wxPen pen1(wxColour(g1, g1, g1)); - wxPen pen2(wxColour(g2, g2, g2)); - - dc.SetPen(pen1); - - float y; - for (y = 0.0; y <= 1.0; y += (1/8.0)) - { - drawLine(dc, 0.0, y, 1.0, y); - } - - float x; - for (x = 0.0; x <= 1.0; x += (1/8.0)) - { - drawLine(dc, x, 0.0, x, 1.0); - } - - dc.SetPen(pen2); - - if (marker >= 0) - { - drawLine(dc, 0.0, marker, 1.0, marker); - drawLine(dc, marker, 0.0, marker, 1.0); - } -} - -void deCurvesPanel::drawCurve(wxDC& dc) -{ - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - - deCurvePoints::const_iterator i; - - deCurvePoints curvePoints; - curve->getCurvePoints(curvePoints); - - deValue xp = -1; - deValue yp = -1; - - for (i = curvePoints.begin(); i != curvePoints.end(); i++) - { - const deCurvePoint& point = *i; - deValue x = point.getX(); - deValue y = point.getY(); - if (xp >= 0) - { - drawLine(dc, xp, yp, x, y); - } - xp = x; - yp = y; - } - - deCurvePoints controlPoints; - curve->getControlPoints(controlPoints); - - - int index = 0; - for (i = controlPoints.begin(); i != controlPoints.end(); i++) - { - const deCurvePoint& point = *i; - deValue x = point.getX(); - deValue y = point.getY(); - drawPoint(dc, x, y); - index++; - } -} - -void deCurvesPanel::click(wxMouseEvent &event) -{ - logMessage("deCurvesPanel::click"); - - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - - selectedPoint = -1; - - deValue x; - deValue y; - getPosition(event, x, y); - int n = curve->findPoint(x, y); - - if (n >= 0) - { - selectedPoint = n; - } - else - { - selectedPoint = curve->addPoint(x, y); - } - - lastSelectedPoint = selectedPoint; - - const deCurvePoint& point = curve->getPoint(selectedPoint); - grabX = point.getX() - x; - grabY = point.getY() - y; - - update(false); -} - -void deCurvesPanel::reset() -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - curve->reset(); - update(true); -} - -void deCurvesPanel::invert() -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - curve->invert(); - update(true); -} - -void deCurvesPanel::setConst(deValue v) -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - curve->setConst(v); - update(true); -} - -void deCurvesPanel::addRandom(int n) -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - - curve->reset(); - - int i; - for (i = 0; i < n; i++) - { - curve->addRandom(); - } - - update(true); -} - -void deCurvesPanel::setAngle(int a) -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - curve->setAngle(a); - update(true); -} - -void deCurvesPanel::setS(int a) -{ - lastSelectedPoint = -1; - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - curve->setS(a); - update(true); -} - - -void deCurvesPanel::update(bool finished) -{ -// std::cout << "curves update" << std::endl; - logMessage("deCurvesPanel::update"); - paint(); - if ((finished) || (layerProcessor.isRealtime())) - { - int index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(index, channel); - } -} - -void deCurvesPanel::release(wxMouseEvent &event) -{ - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - - if (selectedPoint) - { - deValue x; - deValue y; - getPosition(event, x, y); - if ((x < -0.1) || (y < -0.1) || (x>1.1) || (y>1.1)) - { - curve->deletePoint(selectedPoint); - lastSelectedPoint = -1; - selectedPoint = -1; - update(true); - return; - } - } - - selectedPoint = -1; - - update(true); - -} - -void deCurvesPanel::move(wxMouseEvent &event) -{ - if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT)) - { - selectedPoint = -1; - return; - } - - deCurve* curve = layer.getCurve(channel); - - if (!curve) - { - return; - } - - if (selectedPoint >= 0) - { - deValue x; - deValue y; - getPosition(event, x, y); - - x+= grabX; - y+= grabY; - - if (x < 0) - { - x = 0; - } - if (y < 0) - { - y = 0; - } - if (x > 1) - { - x = 1; - } - if (y > 1) - { - y = 1; - } - - curve->movePoint(selectedPoint, x, y); - update(false); - } -} - -void deCurvesPanel::getPosition(wxMouseEvent &event, deValue& x, deValue &y) -{ - deValue dX = 1.0 / (sizeX - 1); - deValue dY = 1.0 / (sizeY - 1); - x = event.GetX() * dX; - y = 1 - (event.GetY() * dY); -} - -void deCurvesPanel::paint() -{ - wxClientDC dc(this); - render(dc); -} - -void deCurvesPanel::changeChannel(int _channel) -{ - layerProcessor.lock(); - - channel = _channel; - generateBackground(); - setMarker(); - layer.setHistogramChannel(channel); - paint(); - - layerProcessor.unlock(); -} - -void deCurvesPanel::onImageClick(deValue x, deValue y) -{ - if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) - { - return; - } - deSize size = layer.getChannelSize(); - clickPosition = (y * size.getH() ) * size.getW() + (x * size.getW()); - setMarker(); - paint(); -} - -void deCurvesPanel::setMarker() -{ - if (clickPosition < 0) - { - marker = -1; - } - else - { - deChannel* c = layer.getSourceChannel(channel); - c->lockRead(); - marker = c->getValue(clickPosition); - c->unlockRead(); - } -} - -void deCurvesPanel::onKey(int key) -{ - deColorSpace colorSpace = layer.getColorSpace(); - int s = getColorSpaceSize(colorSpace); - - if (key == WXK_CONTROL) - { - if (clickPosition >= 0) - { - int i; - for (i = 0; i < s; i++) - { - deChannel* c = layer.getSourceChannel(i); - - if (c) - { - c->lockRead(); - - deValue m = c->getValue(clickPosition); - - c->unlockRead(); - - deCurve* curve = layer.getCurve(i); - - int selectedPoint = curve->addPoint(m, curve->calcValue(m)); - - if (i == channel) - { - lastSelectedPoint = selectedPoint; - } - - } - } - update(true); - } - return; - } - deValue delta = 0.0; - - if (key == 'A') - { - delta = 1.0; - } - - if (key == 'Z') - { - delta = -1.0; - } - - if (delta != 0.0) - { - deValue dY = delta / (sizeY - 1); - if (lastSelectedPoint >= 0) - { - deCurve* curve = layer.getCurve(channel); - curve->movePointVertically(lastSelectedPoint, dY); - update(true); - } - } - - if (key == 'X') - { - if (lastSelectedPoint >= 0) - { - deCurve* curve = layer.getCurve(channel); - curve->deletePoint(lastSelectedPoint); - lastSelectedPoint = -1; - update(true); - } - } - -} diff -Nru delaboratory-0.7/src/curves_panel.h delaboratory-0.8/src/curves_panel.h --- delaboratory-0.7/src/curves_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/curves_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CURVES_PANEL_H -#define _DE_CURVES_PANEL_H - -#define CURVES_PANEL_SIZE_X 384 -#define CURVES_PANEL_SIZE_Y 256 - -#include "wx/wx.h" -class deCurvesLayer; -class deLayerProcessor; -#include "value.h" -#include "histogram.h" - -class deCurvesPanel:public wxPanel -{ -private: - wxBitmap bitmap; - wxBitmap* backgroundBitmap; - int sizeX; - int sizeY; - deCurvesLayer& layer; - deHistogram histogram; - int channel; - - bool realtime; - - void drawPoint(wxDC& dc, deValue x, deValue y); - void drawCurve(wxDC& dc); - - void click(wxMouseEvent &event); - void release(wxMouseEvent &event); - void move(wxMouseEvent &event); - void update(bool finished); - - int selectedPoint; - int lastSelectedPoint; - - deValue grabX; - deValue grabY; - - void getPosition(wxMouseEvent &event, deValue& x, deValue &y); - - deValue marker; - - int clickPosition; - - deLayerProcessor& layerProcessor; - - void drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2); - void drawLines(wxDC& dc); - - void generateBackground(); -public: - deCurvesPanel(wxWindow* parent, deCurvesLayer& layer, deLayerProcessor& _layerProcessor); - ~deCurvesPanel(); - - void paintEvent(wxPaintEvent & evt); - void render(wxDC& dc); - void paint(); - - void changeChannel(int _channel); - void onImageClick(deValue x, deValue y); - - void reset(); - void invert(); - void setConst(deValue v); - void setAngle(int a); - void setS(int a); - - void onKey(int key); - - void setMarker(); - - void addRandom(int n); - - DECLARE_EVENT_TABLE() - -}; - -#endif diff -Nru delaboratory-0.7/src/dcraw_support.cc delaboratory-0.8/src/dcraw_support.cc --- delaboratory-0.7/src/dcraw_support.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dcraw_support.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,447 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "dcraw_support.h" -#include -#include -#include -#include "logger.h" -#include "str.h" -#include "channel.h" -#include "size.h" -#include "static_image.h" -#include "rgb2xyz2lab.h" - -#define DCRAW_EXECUTABLE "dcraw" - -std::string getDcrawVersion() -{ - const char* com = DCRAW_EXECUTABLE; - wxString s(com, wxConvUTF8); - - wxProcess* process = wxProcess::Open(s); - - wxInputStream* input = process->GetInputStream(); - - std::string vs = ""; - - int counter = 0; - - char c = ' '; - char c2 = ' '; - - do - { - c2 = c; - c = input->GetC(); - counter++; - if (counter > 40) - { - return ""; - } - } - while ((c2 != ' ') || (c != 'v')); - - do - { - c = input->GetC(); - if (c != '\n') - { - vs += c; - } - } - while (c != '\n'); - - return vs; -} - -deRawLoader::deRawLoader(const std::string& f, deStaticImage& _image, deColorSpace _colorSpace, bool _half) -:filename(f), image(_image), colorSpace(_colorSpace), half(_half) -{ - std::string options = "-w -c -6 -o 4 -W"; - if (half) - { - options += " -h"; - } - else - { - options += " -q 3"; - } - - std::string command = std::string(DCRAW_EXECUTABLE) + " " + options + " \"" + f + "\" >abc "; - logMessage("calling: " + command); - - const char* c = command.c_str(); - wxString s(c, wxConvUTF8); - - process = wxProcess::Open(s); - - input = process->GetInputStream(); -} - -deRawLoader::~deRawLoader() -{ -} - - -bool deRawLoader::load(bool& failure) -{ - if (!input->CanRead()) - { - return false; - } - - logMessage("deRawLoader::load() - CanRead"); - - char c1 = input->GetC(); - char c2 = input->GetC(); - - if (c1 != 'P') - { - logMessage("first character not P"); - failure = true; - return false; - } - if (c2 != '6') - { - logMessage("second character not 6"); - failure = true; - return false; - } - - logMessage("P6 loaded"); - - char c; - - std::string ws = ""; - do - { - c = input->GetC(); - if (c != ' ') - ws += c; - } - while (c != ' '); - - int w = getInt(ws); - if (w <= 0) - { - failure = true; - return false; - } - - std::string hs = ""; - do - { - c = input->GetC(); - if (c != '\n') - hs += c; - } - while (c != '\n'); - - int h = getInt(hs); - if (h <= 0) - { - failure = true; - return false; - } - - std::string ms = ""; - do - { - c = input->GetC(); - if (c != '\n') - ms += c; - } - while (c != '\n'); - - - int max = getInt(ms); - if (max <= 256) - { - failure = true; - return false; - } - - logMessage("w: " + str(w) + " h: " + str(h) + " max: " + str(max)); - - if (half) - { - w *= 2; - h *= 2; - logMessage("after half w: " + str(w) + " h: " + str(h) + " max: " + str(max)); - } - - image.lock(); - - - deSize size(w, h); - image.setSize(size); - - deChannel* channelRR = image.getChannel(0); - if (!channelRR) - { - image.unlock(); - failure = true; - return false; - } - deChannel& channelR = *channelRR; - - deChannel* channelGG = image.getChannel(1); - if (!channelGG) - { - image.unlock(); - failure = true; - return false; - } - deChannel& channelG = *channelGG; - - deChannel* channelBB = image.getChannel(2); - if (!channelBB) - { - image.unlock(); - failure = true; - return false; - } - deChannel& channelB = *channelBB; - - channelR.lockWrite(); - channelG.lockWrite(); - channelB.lockWrite(); - - deValue* pixels0 = channelR.getPixels(); - deValue* pixels1 = channelG.getPixels(); - deValue* pixels2 = channelB.getPixels(); - - deValue scale = 1.0 / max; - - int pos = 0; - - unsigned char cc1; - unsigned char cc2; - - char* buffer; - - int bufsize=500000; - - logMessage("allocating buffer of size " + str(bufsize)); - - buffer = new char[bufsize]; - - logMessage("buffer allocated"); - - bool error = false; - - int n = w * h; - - if (half) - { - n /= 4; - } - - int offset = 0; - - int steps = 0; - - int maxRead = 0; - - bool lab = false; - - if (colorSpace == deColorSpaceLAB) - { - lab = true; - } - - image.setColorSpace(colorSpace); - - int tx = 0; - int ty = 0; - - logMessage("start loading PPM data"); - - while ((pos < n) && (!input->Eof())) - { - steps++; - - input->Read(buffer + offset, bufsize - offset); - - int r = input->LastRead(); - if (r > maxRead) - { - maxRead = r; - } - - r += offset; - - int p = 0; - while (p + 6 <= r) - { - deValue r; - deValue g; - deValue b; - - c = buffer[p]; - p++; - cc1 = (unsigned char)(c); - c = buffer[p]; - p++; - cc2 = (unsigned char)(c); - r = (256 * cc1 + cc2) * scale; - - c = buffer[p]; - p++; - cc1 = (unsigned char)(c); - c = buffer[p]; - p++; - cc2 = (unsigned char)(c); - g = (256 * cc1 + cc2) * scale; - - c = buffer[p]; - p++; - cc1 = (unsigned char)(c); - c = buffer[p]; - p++; - cc2 = (unsigned char)(c); - b = (256 * cc1 + cc2) * scale; - - if (lab) - { - deValue v1; - deValue v2; - deValue v3; - deValue vv1; - deValue vv2; - deValue vv3; - prophoto2xyz(r, g, b, vv1, vv2, vv3); - xyz2lab(vv1, vv2, vv3, v1, v2, v3); - - if (half) - { - pixels0[(2 * ty + 0) * w + 2 * tx + 0] = v1; - pixels0[(2 * ty + 1) * w + 2 * tx + 0] = v1; - pixels0[(2 * ty + 0) * w + 2 * tx + 1] = v1; - pixels0[(2 * ty + 1) * w + 2 * tx + 1] = v1; - - pixels1[(2 * ty + 0) * w + 2 * tx + 0] = v2; - pixels1[(2 * ty + 1) * w + 2 * tx + 0] = v2; - pixels1[(2 * ty + 0) * w + 2 * tx + 1] = v2; - pixels1[(2 * ty + 1) * w + 2 * tx + 1] = v2; - - pixels2[(2 * ty + 0) * w + 2 * tx + 0] = v3; - pixels2[(2 * ty + 1) * w + 2 * tx + 0] = v3; - pixels2[(2 * ty + 0) * w + 2 * tx + 1] = v3; - pixels2[(2 * ty + 1) * w + 2 * tx + 1] = v3; - - tx++; - if (tx >= w/2) - { - tx = 0; - ty++; - } - } - - else - { - pixels0[pos] = v1; - pixels1[pos] = v2; - pixels2[pos] = v3; - } - } - else - { - if (half) - { - pixels0[(2 * ty + 0) * w + 2 * tx + 0] = r; - pixels0[(2 * ty + 1) * w + 2 * tx + 0] = r; - pixels0[(2 * ty + 0) * w + 2 * tx + 1] = r; - pixels0[(2 * ty + 1) * w + 2 * tx + 1] = r; - - pixels1[(2 * ty + 0) * w + 2 * tx + 0] = g; - pixels1[(2 * ty + 1) * w + 2 * tx + 0] = g; - pixels1[(2 * ty + 0) * w + 2 * tx + 1] = g; - pixels1[(2 * ty + 1) * w + 2 * tx + 1] = g; - - pixels2[(2 * ty + 0) * w + 2 * tx + 0] = b; - pixels2[(2 * ty + 1) * w + 2 * tx + 0] = b; - pixels2[(2 * ty + 0) * w + 2 * tx + 1] = b; - pixels2[(2 * ty + 1) * w + 2 * tx + 1] = b; - - tx++; - if (tx >= w / 2) - { - tx = 0; - ty++; - } - } - else - { - pixels0[pos] = r; - pixels1[pos] = g; - pixels2[pos] = b; - } - } - - pos++; - } - - int left = r - p; - int i; - for (i = 0; i < left; i++) - { - buffer[i] = buffer[p + i]; - } - offset = left; - - } - - logMessage("pos: " + str(pos) + " n: " + str(n) + " steps: " + str(steps) + " maxRead: " + str(maxRead)); - if (input->Eof()) - { - logMessage("input stream EOF"); - } - - logMessage("deallocating buffer"); - delete [] buffer; - - channelR.unlockWrite(); - channelG.unlockWrite(); - channelB.unlockWrite(); - - image.unlock(); - - if (error) - { - failure = true; - return false; - } - - logMessage("loading ppm done"); - return true; -} - -bool deRawLoader::getStatus() -{ - if (!process) - { - return false; - } - if (!input) - { - return false; - } - return true; -} diff -Nru delaboratory-0.7/src/dcraw_support.h delaboratory-0.8/src/dcraw_support.h --- delaboratory-0.7/src/dcraw_support.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dcraw_support.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_DCRAW_SUPPORT_H -#define _DE_DCRAW_SUPPORT_H - -#include -class deStaticImage; -#include "color_space.h" - -std::string getDcrawVersion(); - -class deRawLoader -{ - private: - wxProcess* process; - wxInputStream* input; - const std::string& filename; - deStaticImage& image; - deColorSpace colorSpace; - bool half; - public: - - deRawLoader(const std::string& f, deStaticImage& image, deColorSpace colorSpace, bool half); - virtual ~deRawLoader(); - - bool load(bool& failure); - bool getStatus(); - -}; - -#endif diff -Nru delaboratory-0.7/src/delaboratory.cc delaboratory-0.8/src/delaboratory.cc --- delaboratory-0.7/src/delaboratory.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/delaboratory.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - - -#include "wx/wx.h" -#include "project.h" -#include "main_frame.h" -#include "str.h" -#include "rgb2xyz2lab.h" -#include "layer_processor.h" -#include "logger.h" -#include "channel_manager.h" -#include "layer_stack.h" -#include "layer_frame_manager.h" -#include "static_image.h" -#include "raw_module.h" -#include "zoom_manager.h" - -const std::string LOG_FILE_NAME = "debug.log"; -const std::string LOG_LOCKS_FILE_NAME = "locks.log"; - - -class deLaboratory: public wxApp -{ - public: - deLaboratory() - :wxApp(), - sourceImage(), - processor(previewChannelManager, layerStack, layerFrameManager), - project(processor, previewChannelManager, layerStack, layerFrameManager, sourceImage, rawModule, zoomManager) - { - frame = NULL; - deLogger::getLogger().setFile(LOG_FILE_NAME); - deLogger::getLogger().setLocksFile(LOG_LOCKS_FILE_NAME); - - } - - ~deLaboratory() - { - } - - private: - virtual bool OnInit(); - virtual int OnExit(); - deMainFrame* frame; - deSamplerManager samplerManager; - deLayerStack layerStack; - deLayerFrameManager layerFrameManager; - deChannelManager previewChannelManager; - deStaticImage sourceImage; - deLayerProcessor processor; - deProject project; - deRawModule rawModule; - deZoomManager zoomManager; - - virtual int FilterEvent(wxEvent& event); - -}; - - -IMPLEMENT_APP(deLaboratory) - -int deLaboratory::FilterEvent(wxEvent& event) -{ - if (project.shouldReceiveKeys()) - { - if (event.GetEventType()==wxEVT_KEY_DOWN ) - { - int key = ((wxKeyEvent&)event).GetKeyCode(); - if (key == WXK_RETURN) - { - logMessage("WXK_RETURN detected"); - return true; - } - - project.onKey(key); - if (frame) - { - frame->onKey(key); - } - return true; - } - } - - return -1; -} - - -int deLaboratory::OnExit() -{ - project.log("OnExit"); - return 0; -} - -bool deLaboratory::OnInit() -{ - logMessage("deLaboratory::OnInit"); - - rawModule.onInit(); - - std::string dcraw_version = rawModule.getVersion(); - - if (dcraw_version == "") - { - dcraw_version = "dcraw not found"; - } - else - { - dcraw_version = "dcraw version " + dcraw_version; - } - - wxInitAllImageHandlers(); - - int width = 1200; - int height = 960; - - frame = new deMainFrame( wxSize(width,height), project, processor, samplerManager, zoomManager, dcraw_version); - - logMessage("show main frame"); - - frame->Show(TRUE); - - logMessage("set top level"); - - SetTopWindow(frame); - - logMessage("initLAB"); - - initLAB(); - - logMessage("setMainFrame..."); - - processor.setMainFrame(frame); - - logMessage("startWorkerThread..."); - - processor.startWorkerThread(); - - logMessage("process argc/argv..."); - - if (argc > 1) - { - wxString a = argv[1]; - project.init(str(a)); - } - - logMessage("OnInit done"); - - - return TRUE; -} - - - diff -Nru delaboratory-0.7/src/delaboratory.h delaboratory-0.8/src/delaboratory.h --- delaboratory-0.7/src/delaboratory.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/delaboratory.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - - -#include - -std::string getApplicationName() -{ - return "delaboratory"; -} - -std::string getVersion() -{ - return "0.7"; -} - -std::string getCopyright() -{ - return "(c) 2012 Jacek Poplawski"; -} - diff -Nru delaboratory-0.7/src/dodge_burn_frame.cc delaboratory-0.8/src/dodge_burn_frame.cc --- delaboratory-0.7/src/dodge_burn_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dodge_burn_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "dodge_burn_frame.h" -#include "dodge_burn_layer.h" -#include -#include "property_value_slider.h" -#include "property_boolean_ui.h" -#include "layer_processor.h" - -deDodgeBurnFrame::deDodgeBurnFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deDodgeBurnLayer& dodgeBurnLayer = dynamic_cast(_layer); - - int range = 400; - - int n = dodgeBurnLayer.getNumberOfValueProperties(); - - int i; - - for (i = 0; i < n; i++) - { - dePropertyValue* p = dodgeBurnLayer.getPropertyValue(i); - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, dodgeBurnLayer, layerProcessor); - valueSliders.push_back(s); - sizer->Add(s); - } - } - - alternate = new dePropertyBooleanUI(this, dodgeBurnLayer.getPropertyAlternate(), dodgeBurnLayer, layerProcessor); - sizer->Add(alternate); - - wxSizer* sizerB = new wxFlexGridSizer(5); - sizer->Add(sizerB, 0); - - std::vector presets; - dodgeBurnLayer.getPresets(presets); - - std::vector::iterator j; - for (j = presets.begin(); j != presets.end(); j++) - { - wxButton* b = new wxButton(this, wxID_ANY, wxString::FromAscii(j->c_str()), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(b, 0); - buttons[*j] = b; - } - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deDodgeBurnFrame::click)); -} - -deDodgeBurnFrame::~deDodgeBurnFrame() -{ -} - -void deDodgeBurnFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deDodgeBurnLayer& dodgeBurnLayer = dynamic_cast(layer); - - std::map::iterator i; - - for (i = buttons.begin(); i != buttons.end(); i++) - { - if (i->second->GetId() == id) - { - dodgeBurnLayer.applyPreset(i->first); - } - } - - std::vector::iterator j; - for (j = valueSliders.begin(); j != valueSliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/dodge_burn_frame.h delaboratory-0.8/src/dodge_burn_frame.h --- delaboratory-0.7/src/dodge_burn_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dodge_burn_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_DODGE_BURN_FRAME_H -#define _DE_DODGE_BURN_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include -#include - -class dePropertyValueSlider; -class dePropertyBooleanUI; -class deLayerProcessor; - -class deDodgeBurnFrame:public deActionFrame -{ - private: - std::vector valueSliders; - - dePropertyBooleanUI* alternate; - - std::map buttons; - - deLayerProcessor& layerProcessor; - - void click(wxCommandEvent &event); - - public: - deDodgeBurnFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deDodgeBurnFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/dodge_burn_layer.cc delaboratory-0.8/src/dodge_burn_layer.cc --- delaboratory-0.7/src/dodge_burn_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dodge_burn_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "dodge_burn_layer.h" -#include "project.h" -#include -#include "blur.h" -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "copy_channel.h" -#include "blend_channel.h" -#include "process_linear.h" -#include "layer_processor.h" -#include "preset.h" - -deDodgeBurnLayer::deDodgeBurnLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager), - alternate("alternate") -{ - blurRadiusIndex = registerPropertyValue("blur_radius"); - dodgeAmountIndex = registerPropertyValue("dodge_amount"); - dodgeMinIndex = registerPropertyValue("dodge_min"); - dodgeMaxIndex = registerPropertyValue("dodge_max"); - burnAmountIndex = registerPropertyValue("burn_amount"); - burnMinIndex = registerPropertyValue("burn_min"); - burnMaxIndex = registerPropertyValue("burn_max"); - - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - dePropertyValue* dodgeAmount = valueProperties[dodgeAmountIndex]; - dePropertyValue* dodgeMin = valueProperties[dodgeMinIndex]; - dePropertyValue* dodgeMax = valueProperties[dodgeMaxIndex]; - dePropertyValue* burnAmount = valueProperties[burnAmountIndex]; - dePropertyValue* burnMin = valueProperties[burnMinIndex]; - dePropertyValue* burnMax = valueProperties[burnMaxIndex]; - - blurRadius->setLabel("radius"); - blurRadius->setMin(1); - blurRadius->setMax(50); - - dodgeAmount->setLabel("dodge amount"); - dodgeMin->setLabel("dodge min"); - dodgeMax->setLabel("dodge max"); - - burnAmount->setLabel("burn amount"); - burnMin->setLabel("burn min"); - burnMax->setLabel("burn max"); - - alternate.setLabel("use screen / multiply instead dodge / burn"); - alternate.set(false); - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 5.0)); - p->addPresetValue(new dePresetValue("dodge_amount", 0.4)); - p->addPresetValue(new dePresetValue("dodge_min", 0.6)); - p->addPresetValue(new dePresetValue("dodge_max", 0.95)); - p->addPresetValue(new dePresetValue("burn_amount", 0.4)); - p->addPresetValue(new dePresetValue("burn_min", 0.05)); - p->addPresetValue(new dePresetValue("burn_max", 0.4)); - presets["reset"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 20.0)); - presets["radius big"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 5.0)); - presets["radius small"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("dodge_amount", 0.0)); - presets["dodge off"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("dodge_amount", 0.4)); - p->addPresetValue(new dePresetValue("dodge_min", 0.6)); - p->addPresetValue(new dePresetValue("dodge_max", 0.95)); - presets["dodge small"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("dodge_amount", 0.5)); - p->addPresetValue(new dePresetValue("dodge_min", 0.5)); - p->addPresetValue(new dePresetValue("dodge_max", 0.95)); - presets["dodge medium"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("dodge_amount", 0.6)); - p->addPresetValue(new dePresetValue("dodge_min", 0.3)); - p->addPresetValue(new dePresetValue("dodge_max", 0.95)); - presets["dodge big"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("burn_amount", 0.0)); - presets["burn off"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("burn_amount", 0.4)); - p->addPresetValue(new dePresetValue("burn_min", 0.05)); - p->addPresetValue(new dePresetValue("burn_max", 0.4)); - presets["burn small"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("burn_amount", 0.5)); - p->addPresetValue(new dePresetValue("burn_min", 0.05)); - p->addPresetValue(new dePresetValue("burn_max", 0.5)); - presets["burn medium"] = p; - } - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("burn_amount", 0.6)); - p->addPresetValue(new dePresetValue("burn_min", 0.05)); - p->addPresetValue(new dePresetValue("burn_max", 0.7)); - presets["burn big"] = p; - } - - applyPreset("reset"); - - disableNotLuminance(); -} - -deDodgeBurnLayer::~deDodgeBurnLayer() -{ -} - -bool deDodgeBurnLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("dodge/burn start"); - - deBlendMode mode1 = deBlendDodge; - deBlendMode mode2 = deBlendBurn; - - if (alternate.get()) - { - mode1 = deBlendScreen; - mode2 = deBlendMultiply; - } - - const deValue* source = sourceChannel.getPixels(); - deValue* destination = channel.getPixels(); - - deValue* blurMap = NULL; - deValue* dodgeMap = NULL; - deValue* burnMap = NULL; - deValue* firstStage = NULL; - - try - { - blurMap = new deValue [size.getN()]; - dodgeMap = new deValue [size.getN()]; - burnMap = new deValue [size.getN()]; - firstStage = new deValue [size.getN()]; - } - catch (std::bad_alloc) - { - logError("ERROR allocating memory in dodge/burn"); - if (blurMap) - { - delete [] blurMap; - } - if (dodgeMap) - { - delete [] dodgeMap; - } - if (burnMap) - { - delete [] burnMap; - } - if (firstStage) - { - delete [] firstStage; - } - return false; - } - - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - dePropertyValue* dodgeAmount = valueProperties[dodgeAmountIndex]; - dePropertyValue* dodgeMin = valueProperties[dodgeMinIndex]; - dePropertyValue* dodgeMax = valueProperties[dodgeMaxIndex]; - dePropertyValue* burnAmount = valueProperties[burnAmountIndex]; - dePropertyValue* burnMin = valueProperties[burnMinIndex]; - dePropertyValue* burnMax = valueProperties[burnMaxIndex]; - - deValue r = viewManager.getRealScale() * blurRadius->get(); - deBlurType type = deGaussianBlur; - bool result = blurChannel(source, blurMap, size, r, r, type, 0.0); - - deValue dmin = dodgeMin->get(); - deValue dmax = dodgeMax->get(); - - processLinear(blurMap, dodgeMap, size.getN(), dmin, dmax, false); - - deValue da = dodgeAmount->get(); - blendChannel(source, source, firstStage, dodgeMap, mode1, da, size.getN()); - - deValue bmin = burnMin->get(); - deValue bmax = burnMax->get(); - processLinear(blurMap, burnMap, size.getN(), bmin, bmax, true); - - deValue ba = burnAmount->get(); - blendChannel(firstStage, firstStage, destination, burnMap, mode2, ba, size.getN()); - - delete [] blurMap; - delete [] dodgeMap; - delete [] burnMap; - delete [] firstStage; - - logMessage("dodge/burn end"); - - return result; -} - - -bool deDodgeBurnLayer::isChannelNeutral(int index) -{ - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - return (blurRadius->get() == 0); -} - -void deDodgeBurnLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - saveValueProperties(root); - - alternate.save(root); -} - -void deDodgeBurnLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - loadValueProperties(child); - alternate.load(child); - - child = child->next; - } -} - diff -Nru delaboratory-0.7/src/dodge_burn_layer.h delaboratory-0.8/src/dodge_burn_layer.h --- delaboratory-0.7/src/dodge_burn_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/dodge_burn_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_DODGE_BURN_LAYER_H -#define _DE_DODGE_BURN_LAYER_H - -#include "action_layer.h" -#include "property_value.h" -#include "property_boolean.h" - -class dePresetLayer; - -class deDodgeBurnLayer:public deActionLayer -{ - private: - dePropertyBoolean alternate; - int blurRadiusIndex; - int dodgeAmountIndex; - int dodgeMinIndex; - int dodgeMaxIndex; - int burnAmountIndex; - int burnMinIndex; - int burnMaxIndex; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "dodge_burn";}; - virtual std::string getLabel() const {return "dodge / burn";}; - - public: - deDodgeBurnLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deDodgeBurnLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "d/b";}; - - dePropertyBoolean& getPropertyAlternate() {return alternate;}; - - virtual bool randomize() {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/equalizer.cc delaboratory-0.8/src/equalizer.cc --- delaboratory-0.7/src/equalizer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "equalizer.h" -#include "channel.h" -#include "str.h" -#include "xml.h" -#include -#include -#include "logger.h" - -deEqualizer::deEqualizer(int _size) -:bands(_size), - mutex(wxMUTEX_RECURSIVE) -{ - values = new deValue [bands]; - - reset(); -} - -deEqualizer::~deEqualizer() -{ - delete [] values; -} - -void deEqualizer::reset() -{ - lock(); - - int i; - for (i = 0; i < bands; i++) - { - values[i] = 0.0; - } - - unlock(); -} - -deValue deEqualizer::getValue(int c) const -{ - lock(); - - deValue v = 0.0; - - if ((c >= 0) && (c < bands)) - { - v = values[c]; - } - - unlock(); - - return v; -} - -void deEqualizer::setValue(int c, deValue value) -{ - if ((c < 0) || (c >= bands)) - { - return; - } - - lock(); - - values[c] = value; - - unlock(); -} - -void deEqualizer::process(const deChannel& s, const deChannel& e, deChannel& destination, int n, bool wrap) -{ - lock(); - - deValue limitScale = 3.0; - - const deValue *ps = s.getPixels(); - const deValue *pe = e.getPixels(); - - deValue bandSize = 1.0 / bands; - - deValue limit = bandSize * limitScale; - deValue scale = 1.0 / limit; - - int i; - for (i = 0; i < n; i++) - { - deValue ve = pe[i]; - deValue vs = ps[i]; - - deValue delta = 0.0; - int n = 0; - - deValue center = bandSize * 0.5; - int j; - for (j = 0; j < bands; j++) - { - deValue d = fabs(center - ve); - deValue r = scale * (limit - d); - if (r > 0) - { - deValue v = r * values[j]; - delta += v; - n++; - } - else - if (wrap) - { - if (ve < 0.5) - { - ve += 1.0; - } - else - { - ve -= 1.0; - } - deValue d = fabs(center - ve); - deValue r = scale * (limit - d); - if (r > 0) - { - deValue v = r * values[j]; - delta += v; - n++; - } - } - center += bandSize; - } - - if (n > 0) - { - delta /= n; - } - - deValue result = vs + delta; - - destination.setValueClip(i, result); - } - - unlock(); -} - -void deEqualizer::save(xmlNodePtr node) -{ -} - -void deEqualizer::load(xmlNodePtr node) -{ - xmlNodePtr child = node->xmlChildrenNode; - - while (child) - { - - child = child->next; - } -} - -void deEqualizer::lock() const -{ - lockWithLog(mutex, "mixer mutex"); -} - -void deEqualizer::unlock() const -{ - mutex.Unlock(); -} diff -Nru delaboratory-0.7/src/equalizer_frame.cc delaboratory-0.8/src/equalizer_frame.cc --- delaboratory-0.7/src/equalizer_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "equalizer_frame.h" -#include "equalizer_layer.h" -#include "equalizer.h" -#include "layer_processor.h" -#include -#include "property_value_slider.h" -#include "property_choice_ui.h" -#include "gradient_panel.h" -#include "wx/notebook.h" - -class deEqualizerSlider:public deSlider -{ - private: - deEqualizerLayer& layer; - deEqualizer& equalizer; - int index; - int channel; - deLayerProcessor& layerProcessor; - - public: - deEqualizerSlider(wxWindow *parent, int range, deEqualizerLayer& _layer, deEqualizer& _equalizer, int _index, int _channel, const std::string& name, deLayerProcessor& _layerProcessor) - :deSlider(parent, name, range, -1.0, 1.0, 0.0), layer(_layer), equalizer(_equalizer), index(_index), channel(_channel), - layerProcessor(_layerProcessor) - { - setFromProperty(); - } - - virtual ~deEqualizerSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - if ((finished) || (layerProcessor.isRealtime())) - { - equalizer.setValue(index, value); - layer.setHistogramChannel(index); - - int ind = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(ind, channel); - } - } - - void setFromProperty() - { - setValue(equalizer.getValue(index)); - } -}; - - -deEqualizerFrame::deEqualizerFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deEqualizerLayer& equalizerLayer = dynamic_cast(_layer); - deColorSpace colorSpace = equalizerLayer.getColorSpace(); - - int range = 300; - - int bands = equalizerLayer.getBands(); - int i; - - int n = getColorSpaceSize(equalizerLayer.getColorSpace()); - - wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); - sizer->Add(notebook, 1, wxEXPAND); - - int c = getEqualizerChannel(colorSpace); - int j; - for (j = 0; j < n; j++) - { - const std::string n = getChannelName(equalizerLayer.getColorSpace(), j); - wxPanel* slidersPanel = new wxPanel(notebook); - notebook->AddPage(slidersPanel, wxString::FromAscii(n.c_str())); - wxSizer* sSizer = new wxFlexGridSizer(2); - slidersPanel->SetSizer(sSizer); - - deEqualizer* equalizer = equalizerLayer.getEqualizer(j); - - if (equalizer) - { - for (i = 0; i < bands; i++) - { - int w = 100; - int h = 30; - deValue l = (deValue) i / bands; - - deColorPanel* gradient = new deColorPanel(slidersPanel, wxSize(w, h), NULL, 0); - gradient->setColor(colorSpace, c, l); - sSizer->Add(gradient); - - deEqualizerSlider* s = new deEqualizerSlider(slidersPanel, range, equalizerLayer, *equalizer, i, j, "", layerProcessor); - sSizer->Add(s); - sliders.push_back(s); - } - } - } - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(100,25)); - sizer->Add(reset, 0); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deEqualizerFrame::click)); - - Fit(); - -} - -deEqualizerFrame::~deEqualizerFrame() -{ -} - -void deEqualizerFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deEqualizerLayer& equalizerLayer = dynamic_cast(layer); - - if (id == reset->GetId()) - { - equalizerLayer.reset(); - } - - std::vector::iterator j; - for (j = sliders.begin(); j != sliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/equalizer_frame.h delaboratory-0.8/src/equalizer_frame.h --- delaboratory-0.7/src/equalizer_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_EQUALIZER_FRAME_H -#define _DE_EQUALIZER_FRAME_H - -#include "action_frame.h" -#include -#include "blur_type.h" -class dePropertyValueSlider; -class dePropertyChoiceUI; -class deLayerProcessor; -class deEqualizerSlider; - -class deEqualizerFrame:public deActionFrame -{ - private: - dePropertyValueSlider* radius; - dePropertyValueSlider* threshold; - dePropertyChoiceUI* blurType; - deLayerProcessor& layerProcessor; - - std::vector sliders; - - wxButton* reset; - - public: - deEqualizerFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deEqualizerFrame(); - - void click(wxCommandEvent &event); - -}; - - -#endif diff -Nru delaboratory-0.7/src/equalizer.h delaboratory-0.8/src/equalizer.h --- delaboratory-0.7/src/equalizer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_EQUALIZER_H -#define _DE_EQUALIZER_H - -#include -#include "value.h" -#include -class deChannel; - -class deEqualizer -{ - private: - int bands; - deValue* values; - - mutable wxMutex mutex; - - deEqualizer(const deEqualizer& mixer); - deEqualizer operator=(const deEqualizer& mixer); - - void lock() const; - void unlock() const; - - public: - deEqualizer(int _size); - virtual ~deEqualizer(); - - deValue getValue(int c) const; - void setValue(int c, deValue value); - - void process(const deChannel& s, const deChannel& e, deChannel& destination, int n, bool wrap); - - void reset(); - - void save(xmlNodePtr node); - void load(xmlNodePtr node); - -}; - -#endif diff -Nru delaboratory-0.7/src/equalizer_layer.cc delaboratory-0.8/src/equalizer_layer.cc --- delaboratory-0.7/src/equalizer_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "equalizer_layer.h" -#include "project.h" -#include -#include "frame_factory.h" -#include "equalizer.h" - -deEqualizerLayer8::deEqualizerLayer8(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deEqualizerLayer(_colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager, _name, 8) -{ -} - -deEqualizerLayer8::~deEqualizerLayer8() -{ -} - -deEqualizerLayer16::deEqualizerLayer16(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deEqualizerLayer(_colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager, _name, 16) -{ -} - -deEqualizerLayer16::~deEqualizerLayer16() -{ -} - -deEqualizerLayer::deEqualizerLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name, int _bands) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager), - bands(_bands) -{ - int n = getColorSpaceSize(colorSpace); - int i; - - for (i = 0; i < n; i++) - { - equalizers.push_back( new deEqualizer(bands)); - } - -} - -deEqualizerLayer::~deEqualizerLayer() -{ - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - delete equalizers[i]; - } -} - -bool deEqualizerLayer::processAction4(int i, const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& channel, int channelSize) -{ - int e = getEqualizerChannel(colorSpace); - - const deChannel* eChannel = NULL; - const deChannel* sChannel = NULL; - - switch (e) - { - case 0: - eChannel = s1; - break; - case 1: - eChannel = s2; - break; - case 2: - eChannel = s3; - break; - case 3: - eChannel = s4; - break; - } - - switch (i) - { - case 0: - sChannel = s1; - break; - case 1: - sChannel = s2; - break; - case 2: - sChannel = s3; - break; - case 3: - sChannel = s4; - break; - } - - bool wrap = isChannelWrapped(colorSpace, e); - - if ((eChannel) && (sChannel)) - { - equalizers[i]->process(*sChannel, *eChannel, channel, channelSize, wrap); - } - - return true; -} - -bool deEqualizerLayer::isChannelNeutral(int index) -{ - return false; -} - - -void deEqualizerLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - xmlNodePtr child = xmlNewChild(root, NULL, BAD_CAST("mixer"), NULL); - } -} - -void deEqualizerLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - - child = child->next; - } -} - -bool deEqualizerLayer::randomize() -{ - return true; -} - -void deEqualizerLayer::reset() -{ - std::vector::iterator i; - for (i = equalizers.begin(); i != equalizers.end(); i++) - { - (*i)->reset(); - } -} - -deEqualizer* deEqualizerLayer::getEqualizer(int index) -{ - int n = getColorSpaceSize(colorSpace); - if ((index >= 0) && ( index < n)) - { - return equalizers[index]; - } - return NULL; -} - - diff -Nru delaboratory-0.7/src/equalizer_layer.h delaboratory-0.8/src/equalizer_layer.h --- delaboratory-0.7/src/equalizer_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/equalizer_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_EQUALIZER_LAYER_H -#define _DE_EQUALIZER_LAYER_H - -#include "action_layer.h" -class deEqualizer; - -class deEqualizerLayer:public deActionLayer -{ - private: - std::vector equalizers; - int bands; - - protected: - virtual bool singleChannelProcessing() const {return false;}; - - public: - deEqualizerLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name, int _bands); - virtual ~deEqualizerLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction4(int i, const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& channel, int channelSize); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual bool randomize(); - - int getBands() const {return bands;}; - deEqualizer* getEqualizer(int index); - - void reset(); -}; - -class deEqualizerLayer8:public deEqualizerLayer -{ - public: - deEqualizerLayer8(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deEqualizerLayer8(); - - virtual std::string getActionName() {return "eq8";}; - virtual std::string getType() const {return "equalizer8";}; - virtual std::string getLabel() const {return "equalizer8";}; -}; - -class deEqualizerLayer16:public deEqualizerLayer -{ - public: - deEqualizerLayer16(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deEqualizerLayer16(); - - virtual std::string getActionName() {return "eq16";}; - virtual std::string getType() const {return "equalizer16";}; - virtual std::string getLabel() const {return "equalizer16";}; -}; - - -#endif diff -Nru delaboratory-0.7/src/external_editor.cc delaboratory-0.8/src/external_editor.cc --- delaboratory-0.7/src/external_editor.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/external_editor.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "external_editor.h" -#include - -#define WINDOWS_GIMP_EXE "gimp-2.7.exe" - -void executeExternalEditor(const std::string& fileName, const std::string& app) -{ - const char* c = fileName.c_str(); - wxString s(c, wxConvUTF8); - - std::string executable; - -#ifdef _WIN32 - executable = WINDOWS_GIMP_EXE; -#else - executable = app; -#endif - - - const wxString command = wxString::FromAscii(executable.c_str()) + _T(" ") + s; - wxExecute(command); - -} - diff -Nru delaboratory-0.7/src/external_editor.h delaboratory-0.8/src/external_editor.h --- delaboratory-0.7/src/external_editor.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/external_editor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_EXTERNAL_EDITOR_H -#define _DE_EXTERNAL_EDITOR_H - -#include - -void executeExternalEditor(const std::string& fileName, const std::string& app); - -#endif diff -Nru delaboratory-0.7/src/file_dialogs.cc delaboratory-0.8/src/file_dialogs.cc --- delaboratory-0.7/src/file_dialogs.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/file_dialogs.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "file_dialogs.h" -#include "str.h" - -wxString getFileType(const std::string& t) -{ - if (t == "image") - { - return _T("TIFF / JPEG (*.tiff;*.tif;*.jpeg;*.jpg) | ;*.tiff;*.tif;*.jpeg;*.jpg"); - } - if (t == "raw") - { - return _T("RAW (*.*) | ;*.*;"); - } - if (t == "tiff") - { - return _T("TIFF (*.tiff;*.tif) | ;*.tiff;*.tif"); - } - if (t == "jpeg") - { - return _T("JPEG (*.jpeg;*.jpg) | ;*.jpeg;*.jpg"); - } - if (t == "delab") - { - return _T("delab (*.delab) | ;*.delab"); - } - - return _T(""); -} - - -std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t) -{ - wxString type = getFileType(t); - - wxFileDialog saveFileDialog(parent, wxString::FromAscii(info.c_str()), _T(""), _T(""), type, wxFD_SAVE); - - if (saveFileDialog.ShowModal() == wxID_CANCEL) - { - return ""; - } - - wxString path = saveFileDialog.GetPath(); - return str(path); -} - -std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t) -{ - - wxString type = getFileType(t); - - wxFileDialog openFileDialog(parent, wxString::FromAscii(info.c_str()), _T(""), _T(""), type, wxFD_OPEN); - - if (openFileDialog.ShowModal() == wxID_CANCEL) - { - return ""; - } - - wxString path = openFileDialog.GetPath(); - return str(path); -} - - diff -Nru delaboratory-0.7/src/file_dialogs.h delaboratory-0.8/src/file_dialogs.h --- delaboratory-0.7/src/file_dialogs.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/file_dialogs.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_FILE_DIALOGS_H -#define _DE_FILE_DIALOGS_H - -#include -#include - -std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t); -std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t); - -#endif diff -Nru delaboratory-0.7/src/fractal.cc delaboratory-0.8/src/fractal.cc --- delaboratory-0.7/src/fractal.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/fractal.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "fractal.h" -#include -#include -#include "blur.h" -#include "copy_channel.h" - -void generateFractalColor(deValue v, deValue& r, deValue& g, deValue& b) -{ - deValue v1 = sin(v * M_PI); - assert(v1 <= 1.0); - assert(v1 >= 0.0); - r = v1; - g = v1; - b = v1; -} - -void generateMandelbrot(deValue* r, deValue* g, deValue* b, deSize size, deValue x1, deValue y1, deValue x2, deValue y2) -{ - deValue w = size.getW(); - deValue h = size.getH(); - - int p = 0; - - deValue maxI = 400.0; - - deValue marg = 4.0; - - deValue zoomX = x2 - x1; - deValue zoomY = y2 - y1; - deValue offX = x1; - deValue offY = y1; - - deValue y; - for (y = 0; y < h; y++) - { - deValue x; - deValue cy = (y / h) * zoomY + offY; - for (x = 0; x < w; x++) - { - deValue cx = (x / w) * zoomX + offX; - - deValue zx = 0; - deValue zy = 0; - - deValue zx2 = 0; - deValue zy2 = 0; - - int i; - for (i = 0; i < maxI && (zx2 + zy2 < marg); i++) - { - zy = 2 * zx * zy + cy; - zx = zx2 - zy2 + cx; - zx2 = zx * zx; - zy2 = zy * zy; - } - - deValue v = i / maxI; - deValue v1; - deValue v2; - deValue v3; - generateFractalColor(v, v1, v2, v3); - r[p] = v1; - g[p] = v2; - b[p] = v3; - - p++; - } - } -} - -void generateFractal(deValue* r, deValue* g, deValue* b, deSize size) -{ - generateMandelbrot(r, g, b, size, -0.42, -0.69, -0.32, -0.59); - - deValue r1 = 20; - deValue r2 = 50; - - deValue* tmp = new deValue[size.getN()]; - - blurChannel(r, tmp, size, r1, r1, deGaussianBlur, 0); - copyChannel(tmp, r, size); - - blurChannel(b, tmp, size, r2, r2, deGaussianBlur, 0); - copyChannel(tmp, b, size); - - delete [] tmp; -} diff -Nru delaboratory-0.7/src/fractal.h delaboratory-0.8/src/fractal.h --- delaboratory-0.7/src/fractal.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/fractal.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_FRACTAL_H -#define _DE_FRACTAL_H - -#include "value.h" -#include "size.h" - -void generateFractal(deValue* r, deValue* g, deValue* b, deSize size); - -#endif diff -Nru delaboratory-0.7/src/frame.cc delaboratory-0.8/src/frame.cc --- delaboratory-0.7/src/frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "frame.h" - -deFrame::deFrame(wxWindow *parent, const std::string& name) -:wxFrame(parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT) -{ -} - -deFrame::~deFrame() -{ -} - diff -Nru delaboratory-0.7/src/frame_factory.cc delaboratory-0.8/src/frame_factory.cc --- delaboratory-0.7/src/frame_factory.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/frame_factory.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "frame_factory.h" - -#include "curves_editor.h" -#include "mixer_editor.h" -#include "apply_image_frame.h" -#include "blur_frame.h" -#include "equalizer_frame.h" -#include "usm_frame.h" -#include "basic_frame.h" -#include "mixer_bw_editor.h" -#include "conversion_bw_layer.h" -#include "dodge_burn_frame.h" -#include "vignette_frame.h" -#include "high_pass_frame.h" -#include "shadows_highlights_frame.h" -#include "hue_saturation_frame.h" - -#include "action_layer.h" -#include "conversion_bw2hue_layer.h" - -deFrame* createFrame(wxWindow *parent, deLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& frameManager) -{ - const std::string type = layer.getType(); - - if (type == "curves") - { - deActionLayer& al = dynamic_cast(layer); - return new deCurvesEditor(parent, al, layerProcessor, frameManager); - } - - if (type == "mixer") - { - deActionLayer& al = dynamic_cast(layer); - return new deMixerEditor(parent, al, layerProcessor, frameManager); - } - - if (type == "apply_image") - { - deActionLayer& al = dynamic_cast(layer); - return new deApplyImageFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "blur") - { - deActionLayer& al = dynamic_cast(layer); - return new deBlurFrame(parent, al, layerProcessor, frameManager); - } - - if ((type == "equalizer8") || (type == "equalizer16")) - { - deActionLayer& al = dynamic_cast(layer); - return new deEqualizerFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "usm") - { - deActionLayer& al = dynamic_cast(layer); - return new deUSMFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "basic") - { - deActionLayer& al = dynamic_cast(layer); - return new deBasicFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "dodge_burn") - { - deActionLayer& al = dynamic_cast(layer); - return new deDodgeBurnFrame(parent, al, layerProcessor, frameManager); - } - - if ((type == "vignette1") || (type == "vignette2")) - { - deActionLayer& al = dynamic_cast(layer); - return new deVignetteFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "high_pass") - { - deActionLayer& al = dynamic_cast(layer); - return new deHighPassFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "shadows_highlights") - { - deActionLayer& al = dynamic_cast(layer); - return new deShadowsHighlightsFrame(parent, al, layerProcessor, frameManager); - } - - if (type == "conversion_bw") - { - deConversionBWLayer& bwl = dynamic_cast(layer); - return new deMixerBWEditor(parent, bwl, layerProcessor, frameManager); - } - - if (type == "conversion_bw2hue") - { - deConversionBW2HueLayer& bwl = dynamic_cast(layer); - return new deHueSaturationFrame(parent, bwl, layerProcessor, frameManager); - } - - - return NULL; -} diff -Nru delaboratory-0.7/src/frame_factory.h delaboratory-0.8/src/frame_factory.h --- delaboratory-0.7/src/frame_factory.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/frame_factory.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_FRAME_FACTORY_H -#define _DE_FRAME_FACTORY_H - -#include -class deLayer; -class deFrame; -class deLayerProcessor; -class deLayerFrameManager; - -deFrame* createFrame(wxWindow *parent, deLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& frameManager); - -#endif diff -Nru delaboratory-0.7/src/frame.h delaboratory-0.8/src/frame.h --- delaboratory-0.7/src/frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_FRAME_H -#define _DE_FRAME_H - -#include - -class deFrame:public wxFrame -{ - protected: - public: - deFrame(wxWindow *parent, const std::string& name); - virtual ~deFrame(); - - virtual void onKey(int key) {}; - - virtual void onUpdateProperties() {}; - -}; - -#endif diff -Nru delaboratory-0.7/src/gradient_panel.cc delaboratory-0.8/src/gradient_panel.cc --- delaboratory-0.7/src/gradient_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/gradient_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,459 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "gradient_panel.h" -#include "conversion_functions.h" - -deColorPanel::deColorPanel(wxWindow* parent, wxSize _size, dePalette3* _palette, int style) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, _size, style), palette(_palette) -{ - Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deColorPanel::click)); -} - -deColorPanel::~deColorPanel() -{ -} - -void deColorPanel::click(wxMouseEvent &event) -{ - -} - -void deColorPanel::setRGB(deValue rr, deValue gg, deValue bb) -{ - r = rr; - g = gg; - b = bb; - - SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); -} - -void deColorPanel::setColor(deColorSpace colorSpace, int channel, deValue value) -{ - deValue rr = 0; - deValue gg = 0; - deValue bb = 0; - - deValue v1 = 0; - deValue v2 = 0; - deValue v3 = 0; - deValue v4 = 0; - - if (colorSpace == deColorSpaceHSV) - { - v2 = 0.8; - v3 = 1.0; - } - - if (colorSpace == deColorSpaceHSL) - { - v2 = 0.8; - v3 = 0.5; - } - - if (colorSpace == deColorSpaceLCH) - { - v1 = 0.7; - v2 = 0.9; - } - - if (colorSpace == deColorSpaceLAB) - { - v2 = 0.5; - v3 = 0.5; - } - - switch (channel) - { - case 0: - v1 = value; - break; - case 1: - v2 = value; - break; - case 2: - v3 = value; - break; - case 3: - v4 = value; - break; - } - - deConversion1x3 f1x3 = getConversion1x3(colorSpace, deColorSpaceRGB); - deConversion3x3 f3x3 = getConversion3x3(colorSpace, deColorSpaceRGB); - deConversion4x3 f4x3 = getConversion4x3(colorSpace, deColorSpaceRGB); - if (f3x3) - { - f3x3(v1, v2, v3, rr, gg, bb); - } else if (f4x3) - { - f4x3(v1, v2, v3, v4, rr, gg, bb); - } else if (f1x3) - { - f1x3(v1, rr, gg, bb); - } - - SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); -} - -deGradientPanel::deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, _size), - colorSpace(_colorSpace) -{ - bitmap = NULL; - Connect(wxEVT_PAINT, wxPaintEventHandler(deGradientPanel::paintEvent)); -} - -deGradientPanel::~deGradientPanel() -{ - if (bitmap) - { - delete bitmap; - } -} - -void deGradientPanel::paintEvent(wxPaintEvent & evt) -{ - wxPaintDC dc(this); - dc.DrawBitmap(*bitmap, 0, 0, false); -} - - -deGradientPanel1::deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3) -:deGradientPanel(parent, _size, _colorSpace), -channel1(_channel1), channel2(_channel2), c1(_c1), c2(_c2), c3(_c3) -{ - bitmap = NULL; - generateBitmap(); -} - -deGradientPanel1::~deGradientPanel1() -{ -} - -void deGradientPanel1::changeChannel(int _channel) -{ - channel1 = _channel; - generateBitmap(); - Update(); - Refresh(); -} - -void setValues(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, int channel1, int channel2, deValue u, deValue v, deValue c1, deValue c2, deValue c3) -{ - v1 = 0; - v2 = 0; - v3 = 0; - v4 = 0; - - if (colorSpace == deColorSpaceLAB) - { - v1 = 0.9; - v2 = 0.5; - v3 = 0.5; - } - - if (colorSpace == deColorSpaceLCH) - { - v1 = 0.8; - v2 = 0.7; - v3 = 0.0; - } - - if (colorSpace == deColorSpaceHSL) - { - v1 = 0.0; - v2 = 0.8; - v3 = 0.6; - } - - if (colorSpace == deColorSpaceHSV) - { - v1 = 0.0; - v2 = 0.8; - v3 = 0.8; - } - - if (colorSpace == deColorSpaceXYZ) - { - v1 = 0.1; - v2 = 0.1; - v3 = 0.1; - } - - switch (channel2) - { - case 0: - v1 = u; - break; - case 1: - v2 = u; - break; - case 2: - v3 = u; - break; - case 3: - v4 = u; - break; - }; - - switch (channel1) - { - case 0: - v1 = v; - if ((colorSpace == deColorSpaceLCH) && (channel2 < 0)) - { - v2 = 0; - } - break; - case 1: - v2 = v; - break; - case 2: - v3 = v; - break; - case 3: - v4 = v; - break; - }; - - if (c1 >= 0) - { - if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) - { - v1 = c1; - } - if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) - { - v3 = c1; - } - } - - if (c2 >= 0) - { - if (colorSpace == deColorSpaceLCH) - { - v3 = c2; - } - if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) - { - v1 = c2; - } - } - - if (colorSpace == deColorSpaceCMYK) - { - if (c1 >= 0) - { - v1 = c1; - } - if (c2 >= 0) - { - v2 = c2; - } - if (c3 >= 0) - { - v3 = c3; - } - } -} - -void deGradientPanel1::generateBitmap() -{ - if (bitmap) - { - delete bitmap; - } - - deConversion1x3 f1x3 = getConversion1x3(colorSpace, deColorSpaceRGB); - deConversion3x3 f3x3 = getConversion3x3(colorSpace, deColorSpaceRGB); - deConversion4x3 f4x3 = getConversion4x3(colorSpace, deColorSpaceRGB); - - int w = GetSize().GetWidth(); - int h = GetSize().GetHeight(); - wxImage* image = new wxImage(w, h); - unsigned char* data = image->GetData(); - - int x; - int y; - for (x = 0; x < w; x++) - { - for (y = 0; y < h; y++) - { - float v = 0; - float u = 0; - if (h > w) - { - v = 1.0 - (float) y / h; - u = (float) x / w; - } - else - { - v = (float) x / w; - u = 1.0 - (float) y / h; - } - - deValue v1 = v; - deValue v2 = v; - deValue v3 = v; - deValue v4 = v; - - setValues(v1, v2, v3, v4, colorSpace, channel1, channel2, u, v, c1, c2, c3); - - deValue rr = 0; - deValue gg = 0; - deValue bb = 0; - if (f3x3) - { - f3x3(v1, v2, v3, rr, gg, bb); - } else if (f4x3) - { - f4x3(v1, v2, v3, v4, rr, gg, bb); - } else if (f1x3) - { - f1x3(v1, rr, gg, bb); - } - - unsigned char r = 255 * rr; - unsigned char g = 255 * gg; - unsigned char b = 255 * bb; - - data[3*(y*w+x) + 0] = r; - data[3*(y*w+x) + 1] = g; - data[3*(y*w+x) + 2] = b; - - } - } - bitmap = new wxBitmap(*image); - delete image; -} - -deGradientPanel2::deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4) -:deGradientPanel(parent, _size, _colorSpace), - c1(_c1), c2(_c2), c3(_c3), c4(_c4) -{ - bitmap = NULL; - generateBitmap(); -} - -deGradientPanel2::~deGradientPanel2() -{ -} - -void setValues2(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, deValue c1, deValue c2, deValue c3, deValue c4, deValue u, deValue v) -{ - if (colorSpace == deColorSpaceCMYK) - { - v1 = c1; - v2 = c2; - v3 = c3; - v4 = c4 + v * 0.2; - } - if (colorSpace == deColorSpaceLAB) - { - deValue uu = u + 0.2; - deValue vv = v + 0.2; - deValue s = sqrt(vv * vv + uu * uu) - 0.2; - if (s < 0) - { - s = 0; - } - v1 = 1.0 - 0.2 * s; - v2 = c1; - v3 = c2; - v4 = 0; - } -} - -void deGradientPanel2::generateBitmap() -{ - if (bitmap) - { - delete bitmap; - } - - deConversion1x3 f1x3 = getConversion1x3(colorSpace, deColorSpaceRGB); - deConversion3x3 f3x3 = getConversion3x3(colorSpace, deColorSpaceRGB); - deConversion4x3 f4x3 = getConversion4x3(colorSpace, deColorSpaceRGB); - - int w = GetSize().GetWidth(); - int h = GetSize().GetHeight(); - wxImage* image = new wxImage(w, h); - unsigned char* data = image->GetData(); - - int x; - int y; - - for (x = 0; x < w; x++) - { - for (y = 0; y < h; y++) - { - float v = 0; - float u = 0; - - deValue d = 2; - - deValue xx = fabs(x - w / d) / (w / d); - deValue yy = fabs(y - h / d) / (h / d); - - if (h > w) - { - v = yy; - u = xx; - } - else - { - v = xx; - u = yy; - } - - deValue v1 = v; - deValue v2 = v; - deValue v3 = v; - deValue v4 = v; - - setValues2(v1, v2, v3, v4, colorSpace, c1, c2, c3, c4, u, v); - - deValue rr; - deValue gg; - deValue bb; - if (f3x3) - { - f3x3(v1, v2, v3, rr, gg, bb); - } else if (f4x3) - { - f4x3(v1, v2, v3, v4, rr, gg, bb); - } else if (f1x3) - { - f1x3(v1, rr, gg, bb); - } - - unsigned char r = 255 * rr; - unsigned char g = 255 * gg; - unsigned char b = 255 * bb; - - data[3*(y*w+x) + 0] = r; - data[3*(y*w+x) + 1] = g; - data[3*(y*w+x) + 2] = b; - - } - } - bitmap = new wxBitmap(*image); - delete image; -} - diff -Nru delaboratory-0.7/src/gradient_panel.h delaboratory-0.8/src/gradient_panel.h --- delaboratory-0.7/src/gradient_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/gradient_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_GRADIENT_PANEL_H -#define _DE_GRADIENT_PANEL_H - -#include -#include "color_space.h" -class dePalette3; - -class deColorPanel:public wxPanel -{ -private: - deValue r; - deValue g; - deValue b; - dePalette3* palette; - -protected: - void click(wxMouseEvent &event); - -public: - deColorPanel(wxWindow* parent, wxSize _size, dePalette3* _palette, int style); - virtual ~deColorPanel(); - - void setRGB(deValue rr, deValue gg, deValue bb); - void setColor(deColorSpace colorSpace, int channel, deValue value); -}; - -class deGradientPanel:public wxPanel -{ -protected: - wxBitmap* bitmap; - deColorSpace colorSpace; - -public: - deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace); - virtual ~deGradientPanel(); - - void paintEvent(wxPaintEvent & evt); -}; - - -class deGradientPanel1:public deGradientPanel -{ -private: - - void generateBitmap(); - - int channel1; - int channel2; - - deValue c1; - deValue c2; - deValue c3; - -public: - deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3); - ~deGradientPanel1(); - - void changeChannel(int _channel); - - -}; - -class deGradientPanel2:public deGradientPanel -{ -private: - - void generateBitmap(); - - deValue c1; - deValue c2; - deValue c3; - deValue c4; - -public: - deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4); - ~deGradientPanel2(); - - -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame2.cc delaboratory-0.8/src/help_color_spaces_frame2.cc --- delaboratory-0.7/src/help_color_spaces_frame2.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame2.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame2.h" -#include "color_space.h" -#include "gradient_panel.h" - -deHelpColorSpacesFrame2::deHelpColorSpacesFrame2(wxWindow *parent) -:deHelpFrame(parent, "mix of channels") -{ - wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - - wxSizer* sizer1 = new wxGridSizer(2); - mainSizer->Add(sizer1); - - std::vector colorSpaces; - getSupportedColorSpaces(colorSpaces); - - int width = 140; - int barSize = 140; - - std::vector::iterator i; - - for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) - { - deColorSpace c = *i; - - int n = getColorSpaceSize(c); - - if (n == 3) - { - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); - sizer1->Add(sizerB); - - int j; - for (j = 0; j < n; j++) - { - int k = j + 1; - if (k >= n) - { - k = 0; - } - - std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); - wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); - sizerB->Add(sizerBC); - - deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); - sizerBC->Add(gradient, 0, wxCENTER); - } - - } - } - - wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); - mainSizer->Add(sizer2); - - for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) - { - deColorSpace c = *i; - - int n = getColorSpaceSize(c); - - if (n == 4) - { - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); - sizer2->Add(sizerB); - - int j; - for (j = 0; j < n; j++) - { - int k; - for (k = j + 1; k < n; k++) - { - std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); - wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); - sizerB->Add(sizerBC); - - deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); - sizerBC->Add(gradient, 0, wxCENTER); - } - } - - } - } - - Fit(); - -} - -deHelpColorSpacesFrame2::~deHelpColorSpacesFrame2() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame2.h delaboratory-0.8/src/help_color_spaces_frame2.h --- delaboratory-0.7/src/help_color_spaces_frame2.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame2.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME2_H -#define _DE_HELP_COLOR_SPACES_FRAME2_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame2:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame2(wxWindow *parent); - virtual ~deHelpColorSpacesFrame2(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame3.cc delaboratory-0.8/src/help_color_spaces_frame3.cc --- delaboratory-0.7/src/help_color_spaces_frame3.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame3.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame3.h" -#include "color_space.h" -#include "gradient_panel.h" -#include - -void add(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) -{ - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); - sizer->Add(sizerB); - - int w = 160; - int h = 160; - - deValue max = 1.0; - int n = 6; - deValue min = max - n * (0.25/2.0); - deValue step = (max-min) / (n ); - - deValue light; - - for (light = min; light <= max; light+= step) - { - deValue l = light * 100; - - std::ostringstream oss; - oss << l; - wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); - sizerB->Add(sizerBC); - - int c1; - int c2; - if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) - { - c1 = 1; - c2 = 2; - } - else - { - c1 = 1; - c2 = 0; - } - - deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, light, -1, -1); - sizerBC->Add(gradient, 0, wxCENTER); - - } - -} - -deHelpColorSpacesFrame3::deHelpColorSpacesFrame3(wxWindow *parent) -:deHelpFrame(parent, "lightness / value") -{ - wxSizer* sizer = new wxGridSizer(1); - SetSizer(sizer); - - add(deColorSpaceLAB, this, sizer); - add(deColorSpaceLCH, this, sizer); - add(deColorSpaceHSL, this, sizer); - add(deColorSpaceHSV, this, sizer); - - Fit(); - -} - -deHelpColorSpacesFrame3::~deHelpColorSpacesFrame3() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame3.h delaboratory-0.8/src/help_color_spaces_frame3.h --- delaboratory-0.7/src/help_color_spaces_frame3.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame3.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME3_H -#define _DE_HELP_COLOR_SPACES_FRAME3_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame3:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame3(wxWindow *parent); - virtual ~deHelpColorSpacesFrame3(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame4.cc delaboratory-0.8/src/help_color_spaces_frame4.cc --- delaboratory-0.7/src/help_color_spaces_frame4.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame4.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame4.h" -#include "color_space.h" -#include "gradient_panel.h" -#include - -void add2(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) -{ - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); - sizer->Add(sizerB); - - wxSizer* sizerG = new wxGridSizer(6); - sizerB->Add(sizerG); - - int w = 120; - int h = 50; - - int n = 18; - deValue step = 1.0 / n; - deValue l = 0; - - int i; - for (i = 0; i < n; i++) - { - std::ostringstream oss; - - int hue; - - hue = 360 * l; - - oss << hue; - wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); - sizerG->Add(sizerBC); - - int c1; - int c2; - if (colorSpace == deColorSpaceLCH) - { - c1 = 0; - c2 = 1; - } - else - { - c1 = 1; - c2 = 2; - } - - deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, -1, l, -1); - sizerBC->Add(gradient, 0, wxCENTER); - - l += step; - - } - - -} - -deHelpColorSpacesFrame4::deHelpColorSpacesFrame4(wxWindow *parent) -:deHelpFrame(parent, "hue") -{ - wxSizer* sizer = new wxGridSizer(1); - SetSizer(sizer); - - add2(deColorSpaceLCH, this, sizer); - add2(deColorSpaceHSL, this, sizer); - add2(deColorSpaceHSV, this, sizer); - - Fit(); - -} - -deHelpColorSpacesFrame4::~deHelpColorSpacesFrame4() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame4.h delaboratory-0.8/src/help_color_spaces_frame4.h --- delaboratory-0.7/src/help_color_spaces_frame4.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame4.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME4_H -#define _DE_HELP_COLOR_SPACES_FRAME4_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame4:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame4(wxWindow *parent); - virtual ~deHelpColorSpacesFrame4(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame5.cc delaboratory-0.8/src/help_color_spaces_frame5.cc --- delaboratory-0.7/src/help_color_spaces_frame5.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame5.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame5.h" -#include "color_space.h" -#include "gradient_panel.h" -#include -#include "conversion_functions.h" -#include -#include - -#include "skin_color_chart.h" - -void generateFelixVonLuschan(wxWindow* window, wxSizer* sizer) -{ - int w = 240; - int h = 30; - - std::vector skins; - getFelixVonLuschan(skins); - - std::vector ranges; - - getSkinRanges(ranges); - - deConversion3x4 f = getConversion3x4(deColorSpaceRGB, deColorSpaceCMYK); - - std::vector::iterator r; - for (r = ranges.begin(); r != ranges.end(); r++) - { - deSkinRange range = *r; - - std::ostringstream oss; - oss << range.description; - wxSizer* sizer_B = new wxStaticBoxSizer(wxVERTICAL, window, wxString::FromAscii(oss.str().c_str())); - sizer->Add(sizer_B); - - int i; - - for (i = range.first - 1; i <= range.last - 1; i++) - { - deSkinRGB& skin = skins[i]; - deValue cc; - deValue mm; - deValue yy; - deValue kk; - - f(skin.r / 255.0, skin.g / 255.0, skin.b / 255.0, cc, mm, yy, kk); - - int c = 100 * cc; - int m = 100 * mm; - int y = 100 * yy; - int k = 100 * kk; - - std::ostringstream oss; - oss << "C: " << c << " M: " << m << " Y: " << y << " K: " << k; - wxSizer* sizer_S = new wxStaticBoxSizer(wxHORIZONTAL, window, wxString::FromAscii(oss.str().c_str())); - sizer_B->Add(sizer_S); - - deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceCMYK, cc, mm, yy, kk); - sizer_S->Add(gradient, 0, wxCENTER); - } - - } - -} - -deHelpColorSpacesFrame5::deHelpColorSpacesFrame5(wxWindow *parent) -:deHelpFrame(parent, "skin colors in CMYK (based on Felix Von Lunshan scale)") -{ - wxSizer* sizer = new wxFlexGridSizer(3); - SetSizer(sizer); - - generateFelixVonLuschan(this, sizer); - - Fit(); - -} - -deHelpColorSpacesFrame5::~deHelpColorSpacesFrame5() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame5.h delaboratory-0.8/src/help_color_spaces_frame5.h --- delaboratory-0.7/src/help_color_spaces_frame5.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame5.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME5_H -#define _DE_HELP_COLOR_SPACES_FRAME5_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame5:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame5(wxWindow *parent); - virtual ~deHelpColorSpacesFrame5(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame6.cc delaboratory-0.8/src/help_color_spaces_frame6.cc --- delaboratory-0.7/src/help_color_spaces_frame6.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame6.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame6.h" -#include "color_space.h" -#include "gradient_panel.h" -#include -#include "conversion_functions.h" -#include -#include - -const int LAB_COLORS_COUNT=10; -const int LAB_COLORS_ELEMENTS = (2 * LAB_COLORS_COUNT + 1); - -void generateAB(wxWindow* window, wxSizer* sizer, int scale) -{ - int w = 40; - int h = 40; - - int b; - int a; - - sizer->Add(-1, 0, wxCENTER); - - for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) - { - int sa = scale * a; - std::ostringstream oss; - oss << sa; - wxStaticText* la = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); - sizer->Add(la, 1, wxCENTER); - } - - for (b = LAB_COLORS_COUNT; b >= -LAB_COLORS_COUNT; b--) - { - int sb = scale * b; - - std::ostringstream oss; - oss << sb; - wxStaticText* lb = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); - sizer->Add(lb, 0, wxCENTER); - - deValue bb = (sb + 100.0) / 200.0; - for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) - { - int sa = scale * a; - deValue aa = (sa + 100.0) / 200.0; - - deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceLAB, aa, bb, -1, -1); - sizer->Add(gradient, 0, wxCENTER); - } - } - - sizer->Layout(); -} - -deHelpColorSpacesFrame6::deHelpColorSpacesFrame6(wxWindow *parent, int scale) -:deHelpFrame(parent, "LAB") -{ - wxSizer* sizer = new wxFlexGridSizer(1 + LAB_COLORS_ELEMENTS, 0, 0); - SetSizer(sizer); - - generateAB(this, sizer, scale); - - Fit(); - -} - -deHelpColorSpacesFrame6::~deHelpColorSpacesFrame6() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame6.h delaboratory-0.8/src/help_color_spaces_frame6.h --- delaboratory-0.7/src/help_color_spaces_frame6.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame6.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME6_H -#define _DE_HELP_COLOR_SPACES_FRAME6_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame6:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame6(wxWindow *parent, int scale); - virtual ~deHelpColorSpacesFrame6(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_color_spaces_frame.cc delaboratory-0.8/src/help_color_spaces_frame.cc --- delaboratory-0.7/src/help_color_spaces_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_color_spaces_frame.h" -#include "color_space.h" -#include "gradient_panel.h" - -deHelpColorSpacesFrame::deHelpColorSpacesFrame(wxWindow *parent) -:deHelpFrame(parent, "channels") -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - std::vector colorSpaces; - getSupportedColorSpaces(colorSpaces); - - int width = 256; - int barSize = 40; - - std::vector::iterator i; - for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) - { - deColorSpace c = *i; - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); - sizer->Add(sizerB); - - int n = getColorSpaceSize(c); - int j; - for (j = 0; j < n; j++) - { - wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getChannelName(c, j).c_str())); - sizerB->Add(sizerBC); - - deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, -1, -1, -1, -1); - sizerBC->Add(gradient, 0, wxCENTER); - } - } - - Fit(); - -} - -deHelpColorSpacesFrame::~deHelpColorSpacesFrame() -{ -} - diff -Nru delaboratory-0.7/src/help_color_spaces_frame.h delaboratory-0.8/src/help_color_spaces_frame.h --- delaboratory-0.7/src/help_color_spaces_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_color_spaces_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_COLOR_SPACES_FRAME_H -#define _DE_HELP_COLOR_SPACES_FRAME_H - -#include "help_frame.h" - -class deHelpColorSpacesFrame:public deHelpFrame -{ - private: - public: - deHelpColorSpacesFrame(wxWindow *parent); - virtual ~deHelpColorSpacesFrame(); -}; - -#endif diff -Nru delaboratory-0.7/src/help_frame.cc delaboratory-0.8/src/help_frame.cc --- delaboratory-0.7/src/help_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "help_frame.h" - -deHelpFrame::deHelpFrame(wxWindow *parent, const std::string& name) -:wxFrame(parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT) -{ -} - -deHelpFrame::~deHelpFrame() -{ -} - diff -Nru delaboratory-0.7/src/help_frame.h delaboratory-0.8/src/help_frame.h --- delaboratory-0.7/src/help_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/help_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HELP_FRAME_H -#define _DE_HELP_FRAME_H - -#include - -class deHelpFrame:public wxFrame -{ - private: - public: - deHelpFrame(wxWindow *parent, const std::string& _name); - virtual ~deHelpFrame(); -}; - -#endif diff -Nru delaboratory-0.7/src/high_pass_frame.cc delaboratory-0.8/src/high_pass_frame.cc --- delaboratory-0.7/src/high_pass_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/high_pass_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "high_pass_frame.h" -#include "high_pass_layer.h" -#include -#include "property_value_slider.h" -#include "layer_processor.h" - -deHighPassFrame::deHighPassFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deHighPassLayer& highPassLayer = dynamic_cast(_layer); - - int range = 400; - - int n = highPassLayer.getNumberOfValueProperties(); - - int i; - - for (i = 0; i < n; i++) - { - dePropertyValue* p = highPassLayer.getPropertyValue(i); - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, highPassLayer, layerProcessor); - valueSliders.push_back(s); - sizer->Add(s); - } - } - -/* - radius = new dePropertyValueSlider(this, range, highPassLayer.getPropertyRadius(), highPassLayer, layerProcessor); - sizer->Add(radius); - */ - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(reset, 0); - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deHighPassFrame::click)); -} - -deHighPassFrame::~deHighPassFrame() -{ -} - -void deHighPassFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deHighPassLayer& highPassLayer = dynamic_cast(layer); - - if (reset->GetId() == id) - { - highPassLayer.reset(); - } - - //radius->setFromProperty(); - std::vector::iterator j; - for (j = valueSliders.begin(); j != valueSliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/high_pass_frame.h delaboratory-0.8/src/high_pass_frame.h --- delaboratory-0.7/src/high_pass_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/high_pass_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HIGH_PASS_FRAME_H -#define _DE_HIGH_PASS_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include - -class dePropertyValueSlider; -class deLayerProcessor; - -class deHighPassFrame:public deActionFrame -{ - private: - std::vector valueSliders; - //dePropertyValueSlider* radius; - deLayerProcessor& layerProcessor; - - wxButton* reset; - - void click(wxCommandEvent &event); - - public: - deHighPassFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deHighPassFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/high_pass_layer.cc delaboratory-0.8/src/high_pass_layer.cc --- delaboratory-0.7/src/high_pass_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/high_pass_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "high_pass_layer.h" -#include "project.h" -#include -#include "blur.h" -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "copy_channel.h" -#include "blend_channel.h" -#include "process_linear.h" -#include "layer_processor.h" - -deHighPassLayer::deHighPassLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - blurRadiusIndex = registerPropertyValue("blur_radius"); - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - - blurRadius->setLabel("radius"); - blurRadius->setMin(1); - blurRadius->setMax(50); - reset(); -} - -void deHighPassLayer::reset() -{ - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - blurRadius->set(5); -} - -deHighPassLayer::~deHighPassLayer() -{ -} - -bool deHighPassLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("high pass start"); - - const deValue* source = sourceChannel.getPixels(); - deValue* destination = channel.getPixels(); - - deValue* blurMap = NULL; - try - { - blurMap = new deValue [size.getN()]; - } - catch (std::bad_alloc) - { - logMessage("ERROR allocating memory in high pass"); - if (blurMap) - { - delete [] blurMap; - } - return false; - } - - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - - deValue r = viewManager.getRealScale() * blurRadius->get(); - deBlurType type = deGaussianBlur; - bool result = blurChannel(source, blurMap, size, r, r, type, 0.0); - - blendChannel(source, blurMap, destination, NULL, deBlendGrainExtract, 1.0, size.getN()); - - delete [] blurMap; - - logMessage("high pass end"); - - return result; -} - - -bool deHighPassLayer::isChannelNeutral(int index) -{ - return false; -} - -void deHighPassLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - saveValueProperties(root); -} - -void deHighPassLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - loadValueProperties(child); - - child = child->next; - } -} - diff -Nru delaboratory-0.7/src/high_pass_layer.h delaboratory-0.8/src/high_pass_layer.h --- delaboratory-0.7/src/high_pass_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/high_pass_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HIGH_PASS_LAYER_H -#define _DE_HIGH_PASS_LAYER_H - -#include "action_layer.h" -#include "property_value.h" - -class deHighPassLayer:public deActionLayer -{ - private: - int blurRadiusIndex; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "high_pass";}; - virtual std::string getLabel() const {return "high pass";}; - - public: - deHighPassLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deHighPassLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "hp";}; - - void reset(); - - virtual bool randomize() {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/histogram.cc delaboratory-0.8/src/histogram.cc --- delaboratory-0.7/src/histogram.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "histogram.h" -#include -#include "channel.h" -#include "logger.h" - -deHistogram::deHistogram(int _size) -:size(_size) -{ - bars.reserve(size); - clear(); -} - -deHistogram::~deHistogram() -{ -} - -void deHistogram::clear() -{ - int i; - for (i = 0; i < size; i++) - { - bars[i] = 0 ; - } -} - -void deHistogram::put(deValue value) -{ - if ((value < 0) || (value > 1)) - { - return; - } - - int bar = (size-1) * value; - - bars[bar] ++; -} - - -int deHistogram::getMax() const -{ - int i; - int m = 0; - for (i = 0; i < size; i++) - { - if (bars[i] > m) - { - m = bars[i]; - } - } - return m; -} - -int deHistogram::get(int bar) const -{ - return bars[bar]; -} - -int deHistogram::getSize() const -{ - return size; -} - -void deHistogram::calc(const deChannel* channel, int n) -{ - if (!channel) - { - return; - } - - logMessage("histogram calc start"); - - static int counter = 0; - - channel->lockRead(); - - const deValue* pixels = channel->getPixels(); - - int j; - int scale = size - 1; - for (j = 0; j < n; j++) - { - deValue value = pixels[j]; - counter++; - int bar = scale * value; - if ((bar >=0) && (bar < size)) - { - bars[bar] ++; - } - } - - channel->unlockRead(); - - logMessage("histogram calc end"); - - -} - -bool deHistogram::render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2) -{ - int mm = getMax(); - if (mm <= 0) - { - return false; - } - - int x; - int y; - for (x = 0; x < sizeW; x++) - { - int hh = get(x); - - int h = sizeH * hh / mm; - - for (y = 0; y < sizeH - h; y++) - { - data[3*(y*sizeW+x)] = g1; - data[3*(y*sizeW+x)+1] = g1; - data[3*(y*sizeW+x)+2] = g1; - } - for (y = sizeH - h; y < sizeH; y++) - { - data[3*(y*sizeW+x)] = g2; - data[3*(y*sizeW+x)+1] = g2; - data[3*(y*sizeW+x)+2] = g2; - } - } - - return true; -} - diff -Nru delaboratory-0.7/src/histogram.h delaboratory-0.8/src/histogram.h --- delaboratory-0.7/src/histogram.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HISTOGRAM_H -#define _DE_HISTOGRAM_H - -#include -#include -#include "value.h" - -class deChannel; - -class deHistogram -{ - private: - std::vector bars; - int size; - public: - deHistogram(int _size); - virtual ~deHistogram(); - - void put(deValue value); - void calc(const deChannel* channel, int n); - int get(int bar) const; - void clear(); - - int getMax() const; - int getSize() const; - - bool render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2); - -}; - -#endif diff -Nru delaboratory-0.7/src/histogram_mode_panel.cc delaboratory-0.8/src/histogram_mode_panel.cc --- delaboratory-0.7/src/histogram_mode_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram_mode_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "histogram_mode_panel.h" -#include -#include "color_space.h" -#include "project.h" -#include -#include "histogram_panel.h" -#include "layer_processor.h" - -void deHistogramModePanel::select(wxCommandEvent &event) -{ - int i = event.GetId(); - - int j; - for (j = 0; j < 4; j++) - { - if (buttons[j]->GetId() == i) - { - histogramPanel->setChannel(j); - project.getLayerProcessor().generateHistogram(); - } - } - -} - -deHistogramModePanel::deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel) -:wxPanel(parent), project(_project), histogramPanel(_histogramPanel) -{ - project.setHistogramModePanel(this); - - wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(sizer); - - int i; - for (i = 0; i < 4; i++) - { - int style = 0; - if (i == 0) - { - style = wxRB_GROUP; - } - wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); - sizer->Add(b); - buttons.push_back(b); - - } - - updateNames(); - updateMode(0); - - Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deHistogramModePanel::select)); -} - -deHistogramModePanel::~deHistogramModePanel() -{ - -} - -void deHistogramModePanel::updateNames() -{ - deViewManager& viewManager = project.getViewManager(); - deColorSpace colorSpace = viewManager.getColorSpace(); - - int i; - int n = getColorSpaceSize(colorSpace); - for (i = 0; i < 4; i++) - { - wxRadioButton* b = buttons[i]; - if (i < n) - { - std::string name = getChannelName(colorSpace, i); - b->SetLabel(wxString::FromAscii(name.c_str())); - b->Show(); - } - else - { - b->Hide(); - } - } - - Layout(); - Fit(); - SetFocus(); -} - -void deHistogramModePanel::updateMode(int c) -{ - if ((c < 0) || (c >= 4)) - { - return; - } - - histogramPanel->setChannel(c); - buttons[c]->SetValue(1); -} - diff -Nru delaboratory-0.7/src/histogram_mode_panel.h delaboratory-0.8/src/histogram_mode_panel.h --- delaboratory-0.7/src/histogram_mode_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram_mode_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HISTOGRAM_MODE_PANEL_H -#define _DE_HISTOGRAM_MODE_PANEL_H - -#include -#include - -class deProject; -class deHistogramPanel; - -class deHistogramModePanel:public wxPanel -{ - private: - std::vector buttons; - deProject& project; - deHistogramPanel* histogramPanel; - - void select(wxCommandEvent &event); - public: - deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel); - virtual ~deHistogramModePanel(); - - void updateNames(); - void updateMode(int c); - -}; - -#endif diff -Nru delaboratory-0.7/src/histogram_panel.cc delaboratory-0.8/src/histogram_panel.cc --- delaboratory-0.7/src/histogram_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "histogram_panel.h" -#include "project.h" -#include "color_space.h" -#include "channel.h" -#include -#include "layer.h" -#include "image.h" -#include "layer_processor.h" -#include -#include "channel_manager.h" -#include "layer_stack.h" -#include "str.h" - -BEGIN_EVENT_TABLE(deHistogramPanel, wxPanel) -EVT_PAINT(deHistogramPanel::paintEvent) -END_EVENT_TABLE() - -deHistogramPanel::deHistogramPanel(wxWindow* parent, deProject* _project) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(256, 200)), project(_project), histogram(256) -{ - channel = 0; - generated = false; - renderedImage.setSize(deSize(256, 256)); -} - -deHistogramPanel::~deHistogramPanel() -{ -} - -void deHistogramPanel::paintEvent(wxPaintEvent & evt) -{ - logMessage("paintEvent in deHistogramPanel"); - wxBufferedPaintDC dc(this); - render(dc); -} - -void deHistogramPanel::paintHistogram() -{ - wxClientDC dc(this); - wxBufferedDC bufferedDC(&dc); - render(bufferedDC); -} - -void deHistogramPanel::render(wxDC& dc) -{ - if (generated) - { - renderedImage.render(dc); - } - else - { - dc.Clear(); - } -} - -void deHistogramPanel::generateHistogram() -{ - project->getLayerProcessor().lock(); - - generated = false; - deLayerStack& layerStack = project->getLayerStack(); - deViewManager& viewManager = project->getViewManager(); - deChannelManager& channelManager = project->getPreviewChannelManager(); - - int viewV = viewManager.getView(); - int view = project->getLayerProcessor().getLastValidLayer(); - if (view > viewV) - { - view = viewV; - } - - deLayer* layer = layerStack.getLayer(view); - if (layer) - { - const deImage& image = layer->getImage(); - int channelIndex = image.getChannelIndex(channel); - - logMessage("generate histogram for channel " + str(channelIndex)); - - deChannel* c = channelManager.getChannel(channelIndex); - - if (!c) - { - logMessage("generate histogram - NULL channel"); - } - - int n = channelManager.getChannelSize().getN(); - - if (n <= 0) - { - logMessage("generate histogram - n: " + str(n)); - } - - if ((c) && (n > 0)) - { - histogram.clear(); - histogram.calc(c, n); - } - } - - project->getLayerProcessor().unlock(); - - if (layer) - { - int sizeW = 256; - int sizeH = 200; - unsigned char g1 = 50; - unsigned char g2 = 120; - - generated = histogram.render(renderedImage.getCurrentImageData(), sizeW, sizeH, g1, g2); - } -} - -void deHistogramPanel::setChannel(int _channel) -{ - channel = _channel; -} - -int deHistogramPanel::getChannel() const -{ - return channel; -} diff -Nru delaboratory-0.7/src/histogram_panel.h delaboratory-0.8/src/histogram_panel.h --- delaboratory-0.7/src/histogram_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/histogram_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HISTOGRAM_PANEL_H -#define _DE_HISTOGRAM_PANEL_H - -#include -#include "histogram.h" -class deProject; -#include "rendered_image.h" - -class deHistogramPanel:public wxPanel -{ - private: - deProject* project; - deHistogram histogram; - deRenderedImage renderedImage; - int channel; - bool generated; - - void paintEvent(wxPaintEvent & evt); - void render(wxDC& dc); - - DECLARE_EVENT_TABLE() - - public: - deHistogramPanel(wxWindow* parent, deProject* _project); - virtual ~deHistogramPanel(); - - void generateHistogram(); - void paintHistogram(); - - void setChannel(int _channel); - - int getChannel() const; -}; - -#endif diff -Nru delaboratory-0.7/src/hsl_hsv.cc delaboratory-0.8/src/hsl_hsv.cc --- delaboratory-0.7/src/hsl_hsv.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/hsl_hsv.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "hsl_hsv.h" - -deValue min(deValue a, deValue b, deValue c) -{ - if (a < b) - { - if (a < c) - { - return a; - } - else - { - return c; - } - } - else - { - if (b < c) - { - return b; - } - else - { - return c; - } - } -} - -deValue max(deValue a, deValue b, deValue c) -{ - if (a > b) - { - if (a > c) - { - return a; - } - else - { - return c; - } - } - else - { - if (b > c) - { - return b; - } - else - { - return c; - } - } -} - -void rgb2hsl(deValue r, deValue g, deValue b, deValue &h, deValue &s, deValue& l) -{ - deValue minVal = min( r, g, b ); - deValue maxVal = max( r, g, b ); - deValue delta = maxVal - minVal; - deValue sum = minVal + maxVal; - - l = sum / 2.0; - - if (delta == 0) - { - h = 0; - s = 0; - } - else - { - if ( l < 0.5 ) - { - s = delta / sum; - } - else - { - s = delta / ( 2.0 - sum ); - } - - deValue deltaR = ( ( ( maxVal - r ) / 6 ) + ( delta / 2 ) ) / delta; - deValue deltaG = ( ( ( maxVal - g ) / 6 ) + ( delta / 2 ) ) / delta; - deValue deltaB = ( ( ( maxVal - b ) / 6 ) + ( delta / 2 ) ) / delta; - - if ( r == maxVal ) - { - h = deltaB - deltaG; - } - else if ( g == maxVal ) - { - h = ( 1.0 / 3.0 ) + deltaR - deltaB; - } - else if ( b == maxVal ) - { - h = ( 2.0 / 3.0 ) + deltaG - deltaR; - } - - if ( h < 0 ) - h += 1; - if ( h > 1 ) - h -= 1; - } -} - -deValue hue2rgb( deValue v1, deValue v2, deValue vH ) -{ - if ( vH < 0 ) - vH += 1; - if ( vH > 1 ) - vH -= 1; - if ( ( 6.0 * vH ) < 1.0 ) - return ( v1 + ( v2 - v1 ) * 6.0 * vH ); - if ( ( 2.0 * vH ) < 1.0 ) - return ( v2 ); - if ( ( 3.0 * vH ) < 2.0 ) - return ( v1 + ( v2 - v1 ) * ( ( 2.0 / 3.0 ) - vH ) * 6.0 ); - return ( v1 ); -} - -void hsl2rgb(deValue h, deValue s, deValue l, deValue& r, deValue& g, deValue& b) -{ - if ( s == 0 ) - { - r = l; - g = l; - b = l; - } - else - { - deValue v1; - deValue v2; - - if ( l < 0.5 ) - { - v2 = l * ( 1 + s ); - } - else - { - v2 = ( l + s ) - ( s * l ); - } - - v1 = 2.0 * l - v2; - - r = hue2rgb( v1, v2, h + ( 1.0 / 3.0 ) ); - g = hue2rgb( v1, v2, h ); - b = hue2rgb( v1, v2, h - ( 1.0 / 3.0 ) ); - } -} - -void rgb2hsv(deValue r, deValue g, deValue b, deValue &h, deValue &s, deValue& v) -{ - v = max( r, g, b ); - - deValue minVal = min( r, g, b ); - deValue delta = v - minVal; - - if (delta == 0) - { - h = 0; - s = 0; - } - else - { - s = delta / v; - - deValue deltaR = ( ( ( v - r ) / 6.0 ) + ( delta / 2.0 ) ) / delta; - deValue deltaG = ( ( ( v - g ) / 6.0 ) + ( delta / 2.0 ) ) / delta; - deValue deltaB = ( ( ( v - b ) / 6.0 ) + ( delta / 2.0 ) ) / delta; - - if ( r == v ) - { - h = deltaB - deltaG; - } - else if ( g == v ) - { - h = ( 1.0 / 3.0 ) + deltaR - deltaB; - } - else if ( b == v ) - { - h = ( 2.0 / 3.0 ) + deltaG - deltaR; - } - - if ( h < 0 ) - h += 1.0; - if ( h > 1 ) - h -= 1.0; - } -} - -void hsv2rgb(deValue h, deValue s, deValue v, deValue& r, deValue& g, deValue& b) -{ - if ( s == 0 ) - { - r = v; - g = v; - b = v; - } - else - { - deValue var_h = h * 6.0; - - if ( var_h == 6.0 ) - { - var_h = 0; - } - - deValue var_i = int( var_h); - deValue var_1 = v * ( 1.0 - s ); - deValue var_2 = v * ( 1.0 - s * ( var_h - var_i ) ); - deValue var_3 = v * ( 1.0 - s * ( 1.0 - ( var_h - var_i ) ) ); - - if ( var_i == 0 ) - { - r = v; - g = var_3; - b = var_1; - } - else if ( var_i == 1 ) - { - r = var_2; - g = v; - b = var_1; - } - else if ( var_i == 2 ) - { - r = var_1; - g = v; - b = var_3; - } - else if ( var_i == 3 ) - { - r = var_1; - g = var_2; - b = v; - } - else if ( var_i == 4 ) - { - r = var_3; - g = var_1; - b = v; - } - else - { - r = v; - g = var_1; - b = var_2; - } - } -} diff -Nru delaboratory-0.7/src/hsl_hsv.h delaboratory-0.8/src/hsl_hsv.h --- delaboratory-0.7/src/hsl_hsv.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/hsl_hsv.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HSL_HSV_H -#define _DE_HSL_HSV_H - -#include "value.h" - -void rgb2hsl(deValue r, deValue g, deValue b, deValue& h, deValue& s, deValue& l); -void hsl2rgb(deValue h, deValue s, deValue l, deValue& r, deValue& g, deValue& b); -void rgb2hsv(deValue r, deValue g, deValue b, deValue& h, deValue& s, deValue& v); -void hsv2rgb(deValue h, deValue s, deValue v, deValue& r, deValue& g, deValue& b); - -#endif diff -Nru delaboratory-0.7/src/hue_saturation_frame.cc delaboratory-0.8/src/hue_saturation_frame.cc --- delaboratory-0.7/src/hue_saturation_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/hue_saturation_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "hue_saturation_frame.h" -#include "conversion_bw2hue_layer.h" -#include -#include "property_value_slider.h" -#include "layer_processor.h" -#include "layer_frame_manager.h" - -deHueSaturationFrame::deHueSaturationFrame(wxWindow *parent, deConversionBW2HueLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deLayerFrame(parent, _layer, "BW -> hue/saturation", _frameManager), layerProcessor(_layerProcessor), layer(_layer) -{ - frameManager.addActionFrame(this); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deConversionBW2HueLayer& hsLayer = dynamic_cast(_layer); - - int range = 400; - - hue = new dePropertyValueSlider(this, range, hsLayer.getPropertyHue(), hsLayer, layerProcessor); - sizer->Add(hue); - - saturation = new dePropertyValueSlider(this, range, hsLayer.getPropertySaturation(), hsLayer, layerProcessor); - sizer->Add(saturation); - - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(reset, 0); - - preset1 = new wxButton(this, wxID_ANY, _T("sepia"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(preset1, 0); - - preset2 = new wxButton(this, wxID_ANY, _T("platine"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(preset2, 0); - - preset3 = new wxButton(this, wxID_ANY, _T("silver"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(preset3, 0); - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deHueSaturationFrame::click)); -} - -deHueSaturationFrame::~deHueSaturationFrame() -{ - frameManager.removeActionFrame(this); -} - -void deHueSaturationFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deConversionBW2HueLayer& hsLayer = dynamic_cast(layer); - - if (reset->GetId() == id) - { - hsLayer.reset(); - } - - if (preset1->GetId() == id) - { - hsLayer.preset(0.075); - } - - if (preset2->GetId() == id) - { - hsLayer.preset(0.16); - } - - if (preset3->GetId() == id) - { - hsLayer.preset(0.6); - } - - hue->setFromProperty(); - saturation->setFromProperty(); - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/hue_saturation_frame.h delaboratory-0.8/src/hue_saturation_frame.h --- delaboratory-0.7/src/hue_saturation_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/hue_saturation_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_HUE_SATURATION_FRAME_H -#define _DE_HUE_SATURATION_FRAME_H - -#include "layer_frame.h" -#include "slider.h" - -class dePropertyValueSlider; -class deLayerProcessor; -class deConversionBW2HueLayer; - -class deHueSaturationFrame:public deLayerFrame -{ - private: - dePropertyValueSlider* hue; - dePropertyValueSlider* saturation; - deLayerProcessor& layerProcessor; - deConversionBW2HueLayer& layer; - - wxButton* reset; - wxButton* preset1; - wxButton* preset2; - wxButton* preset3; - - void click(wxCommandEvent &event); - - public: - deHueSaturationFrame(wxWindow *parent, deConversionBW2HueLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deHueSaturationFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/image_area_panel.cc delaboratory-0.8/src/image_area_panel.cc --- delaboratory-0.7/src/image_area_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_area_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "image_area_panel.h" -#include "size.h" -#include "project.h" -#include "image_panel.h" -#include "channel_manager.h" -#include "layer_processor.h" -#include "zoom_panel.h" -#include "str.h" - -void deImageAreaPanel::paint(wxPaintEvent& event) -{ -} - -void deImageAreaPanel::resize(wxSizeEvent& event) -{ - updateSize(true); - Refresh(); -} - -void deImageAreaPanel::updateSize(bool calcHistogram) -{ - wxSize s = GetSize(); - logMessage("image area panel update size " + str(s.GetWidth()) + "x" + str(s.GetHeight())); - - const deSize ps(s.GetWidth(), s.GetHeight()); - - const deSize& ss = project.getSourceImageSize(); - - if (ss.getN() <= 0) - { - return; - } - - deSize fit = fitInside(ps, ss, 1.0); - - project.getLayerProcessor().setPreviewSize(fit); - - logMessage("set image panel size " + str(fit.getW()) + "x" + str(fit.getH())); - imagePanel->SetSize(wxSize(fit.getW(), fit.getH())); - imagePanel->SetMinSize(wxSize(fit.getW(), fit.getH())); - - Layout(); -} - - -deImageAreaPanel::deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel) -:wxPanel(parent), project(_project) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - imagePanel = new deImagePanel(this, project, _samplerManager, _zoomManager, zoomPanel); - sizer->Add(imagePanel, 0, wxCENTER); - - project.setImageAreaPanel(this); - - zoomPanel->setImageAreaPanel(this); - - Connect(wxEVT_SIZE, wxSizeEventHandler(deImageAreaPanel::resize)); -} - -deImageAreaPanel::~deImageAreaPanel() -{ -} - - -deImagePanel* deImageAreaPanel::getImagePanel() -{ - return imagePanel; -} diff -Nru delaboratory-0.7/src/image_area_panel.h delaboratory-0.8/src/image_area_panel.h --- delaboratory-0.7/src/image_area_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_area_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_CENTER_PANEL_H -#define _DE_CENTER_PANEL_H - -#include -class deProject; -class deImagePanel; -class deSamplerManager; -class deZoomManager; -class deZoomPanel; - -class deImageAreaPanel:public wxPanel -{ - private: - void resize(wxSizeEvent &event); - void paint(wxPaintEvent& event); - deProject& project; - - deImagePanel* imagePanel; - - public: - deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel); - virtual ~deImageAreaPanel(); - - void updateSize(bool calcHistogram); - - deImagePanel* getImagePanel(); - -}; - -#endif diff -Nru delaboratory-0.7/src/image.cc delaboratory-0.8/src/image.cc --- delaboratory-0.7/src/image.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "image.h" -#include "channel_manager.h" -#include "logger.h" -#include "str.h" - -deImage::deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager) -:colorSpace(_colorSpace), channelManager(_channelManager) -{ - logMessage("create new image"); - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < 4; i++) - { - if (i < s) - { - channelsAllocated[i] = channelManager.allocateNewChannel(); - } - else - { - channelsAllocated[i] = -1; - } - channelsVisible[i] = -1; - } -} - -deImage::~deImage() -{ - logMessage("destroy image"); - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - assert (channelsAllocated[i] >= 0); - channelManager.freeChannel(channelsAllocated[i]); - } -} - -void deImage::enableChannel(int n) -{ - logMessage("enable channel " + str(n) + " in image"); - assert(n >= 0); - assert(n < 4); - assert (channelsAllocated[n] >= 0); - channelManager.tryAllocateChannel(channelsAllocated[n]); - channelsVisible[n] = channelsAllocated[n]; -} - -void deImage::disableChannel(int n, int c) -{ - logMessage("disable channel " + str(n) + " in image, replace with " +str(c)); - assert(n >= 0); - assert(n < 4); - channelsVisible[n] = c; - channelManager.tryDeallocateChannel(channelsAllocated[n]); -} - -int deImage::getChannelIndex(int n) const -{ - assert(n >= 0); - assert(n < 4); - return channelsVisible[n]; -} - -deColorSpace deImage::getColorSpace() const -{ - return colorSpace; -} - -void deImage::disableAllChannels() -{ - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - disableChannel(i, -1); - } - -} - -void deImage::enableAllChannels() -{ - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - enableChannel(i); - } -} - -void deImage::updateChannelUsage(std::map& channelUsage, int index) const -{ - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - int c = channelsVisible[i]; - channelUsage[c] = index; - } -} - -bool deImage::getPixel(int channel, int p, deValue& result) const -{ - deChannel* c = channelManager.getChannel(channelsVisible[channel]); - if (!c) - { - return false; - } - result = c->getValue(p); - return true; - -} - -const deValue* deImage::getValues(int channel) const -{ - deChannel* c = channelManager.getChannel(channelsVisible[channel]); - if (!c) - { - return NULL; - } - return c->getPixels(); -} - -void deImage::lockRead() const -{ - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - deChannel* c = channelManager.getChannel(channelsVisible[i]); - if (c) - { - c->lockRead(); - } - } -} - -void deImage::unlockRead() const -{ - int i; - int s = getColorSpaceSize(colorSpace); - for (i = 0; i < s; i++) - { - deChannel* c = channelManager.getChannel(channelsVisible[i]); - if (c) - { - c->unlockRead(); - } - } -} diff -Nru delaboratory-0.7/src/image.h delaboratory-0.8/src/image.h --- delaboratory-0.7/src/image.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_IMAGE_H -#define _DE_IMAGE_H - -#include "color_space.h" -#include -class deChannelManager; - -class deImage -{ - private: - const deColorSpace colorSpace; - int channelsVisible[4]; - int channelsAllocated[4]; - deChannelManager& channelManager; - - deImage(const deImage& i); - deImage& operator = (const deImage& i); - - - public: - deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager); - - virtual ~deImage(); - - deColorSpace getColorSpace() const; - - int getChannelIndex(int n) const; - - void enableChannel(int n); - void disableChannel(int n, int c); - - void disableAllChannels(); - void enableAllChannels(); - - void updateChannelUsage(std::map& channelUsage, int index) const; - - bool getPixel(int channel, int p, deValue& result) const; - - void lockRead() const; - void unlockRead() const; - - const deValue* getValues(int channel) const; - - -}; - -#endif diff -Nru delaboratory-0.7/src/image_io.cc delaboratory-0.8/src/image_io.cc --- delaboratory-0.7/src/image_io.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_io.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,346 +0,0 @@ -/* - - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "image_io.h" -#include -#include -#include "channel.h" -#include "conversion_functions.h" -#include "logger.h" -#include "static_image.h" -#include "str.h" -#include "dcraw_support.h" -#include "rgb2xyz2lab.h" -#include "conversion_functions.h" - -void saveJPEG(const std::string& fileName, const deChannel& channelR, const deChannel& channelG, const deChannel& channelB, deSize size) -{ - - wxImage* image; - int w = size.getW(); - int h = size.getH(); - - image = new wxImage(w, h); - - image->SetOption(wxIMAGE_OPTION_QUALITY,98); - - channelR.lockRead(); - channelG.lockRead(); - channelB.lockRead(); - - int pos = 0; - int y; - for (y = 0; y < h; y++) - { - int x; - for (x = 0; x < w; x++) - { - deValue r = 255 * channelR.getValue(pos); - deValue g = 255 * channelG.getValue(pos); - deValue b = 255 * channelB.getValue(pos); - image->SetRGB(x, y, r, g, b); - - pos++; - - } - } - - channelR.unlockRead(); - channelG.unlockRead(); - channelB.unlockRead(); - - const char* c = fileName.c_str(); - wxString s(c, wxConvUTF8); - image->SaveFile(s); - delete image; -} - -void saveTIFF(const std::string& fileName, const deChannel& channelR, const deChannel& channelG, const deChannel& channelB, deSize size) -{ - logMessage("save TIFF " + fileName); - int w = size.getW(); - int h = size.getH(); - - TIFF* tif = TIFFOpen(fileName.c_str(), "w"); - - if (!tif) - { - logMessage("ERROR writing " + fileName); - return; - } - - TIFFSetField (tif, TIFFTAG_SOFTWARE, "delaboratory"); - TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, w); - TIFFSetField (tif, TIFFTAG_IMAGELENGTH, h); - TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 3); - TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField (tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, h); - TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); - - tdata_t buf; - int ssize = TIFFScanlineSize(tif); - buf = _TIFFmalloc(ssize); - uint16* bb = (uint16*)(buf); - - channelR.lockRead(); - channelG.lockRead(); - channelB.lockRead(); - - int pos = 0; - int y; - for (y = 0; y < h; y++) - { - int x; - for (x = 0; x < w; x++) - { - deValue d = 256 * 256 - 1 ;; - deValue r = d * channelR.getValue(pos); - deValue g = d * channelG.getValue(pos); - deValue b = d * channelB.getValue(pos); - bb[3*x+0] = r; - bb[3*x+1] = g; - bb[3*x+2] = b;; - - pos++; - - } - TIFFWriteScanline (tif, buf, y, 0); - } - - channelR.unlockRead(); - channelG.unlockRead(); - channelB.unlockRead(); - - TIFFClose(tif); - - logMessage("saved TIFF " + fileName); -} - -bool loadJPEG(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace) -{ - wxLogNull noerrormessages; - - if (colorSpace != deColorSpaceRGB) - { - return false; - } - - logMessage("loadJPEG " + fileName); - - const char* c = fileName.c_str(); - wxString s(c, wxConvUTF8); - wxImage fileImage; - bool result = fileImage.LoadFile(s, wxBITMAP_TYPE_JPEG); - if (!result) - { - return false; - } - int w = fileImage.GetWidth(); - int h = fileImage.GetHeight(); - - deSize size(w, h); - image.setSize(size); - - deChannel* channelRR = image.getChannel(0); - if (!channelRR) - { - return false; - } - deChannel& channelR = *channelRR; - - deChannel* channelGG = image.getChannel(1); - if (!channelGG) - { - return false; - } - deChannel& channelG = *channelGG; - - deChannel* channelBB = image.getChannel(2); - if (!channelBB) - { - return false; - } - deChannel& channelB = *channelBB; - - int pos = 0; - - image.setColorSpace(deColorSpaceRGB); - - channelR.lockWrite(); - channelG.lockWrite(); - channelB.lockWrite(); - - unsigned char* data = fileImage.GetData(); - - int p = 0; - int y; - for (y =0; y < h; y++) - { - int x; - for (x = 0; x < w; x++) - { - - deValue r = data[p] / 255.0; - p++; - deValue g = data[p] / 255.0; - p++; - deValue b = data[p] / 255.0; - p++; - channelR.setValue(pos, r ); - channelG.setValue(pos, g ); - channelB.setValue(pos, b ); - pos++; - } - } - - channelR.unlockWrite(); - channelG.unlockWrite(); - channelB.unlockWrite(); - - logMessage("loadJPEG " + fileName + " done"); - - return true; -} - - - -bool loadTIFF(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace) -{ - wxLogNull noerrormessages; - - if (colorSpace != deColorSpaceRGB) - { - return false; - } - - logMessage("load TIFF " + fileName); - - TIFF* tif = TIFFOpen(fileName.c_str(), "r"); - if (!tif) - { - return false; - } - tdata_t buf; - - int w; - int h; - uint16 bps; - uint16 spp; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp); - - logMessage("found TIFF " + str(w) + "x" + str(h) + " bps: " + str(bps) + " spp: " + str(spp)); - - deSize size(w, h); - image.setSize(size); - - deChannel* channelRR = image.getChannel(0); - if (!channelRR) - { - return false; - } - deChannel& channelR = *channelRR; - - deChannel* channelGG = image.getChannel(1); - if (!channelGG) - { - return false; - } - deChannel& channelG = *channelGG; - - deChannel* channelBB = image.getChannel(2); - if (!channelBB) - { - return false; - } - deChannel& channelB = *channelBB; - - image.setColorSpace(deColorSpaceRGB); - - channelR.lockWrite(); - channelG.lockWrite(); - channelB.lockWrite(); - - deValue* pixelsR = channelR.getPixels(); - deValue* pixelsG = channelG.getPixels(); - deValue* pixelsB = channelB.getPixels(); - - int pos = 0; - int y; - - int ssize = TIFFScanlineSize(tif); - buf = _TIFFmalloc(ssize); - - for (y = 0; y < h; y++) - { - TIFFReadScanline(tif, buf, y); - int x; - for (x = 0; x < w; x++) - { - deValue r; - deValue g; - deValue b; - if (bps == 16) - { - uint16* bb = (uint16*)(buf); - uint16 u1 = bb[spp*x+0]; - uint16 u2 = bb[spp*x+1]; - uint16 u3 = bb[spp*x+2]; - deValue d = (256 * 256) - 1; - r = u1 / d; - g = u2 / d; - b = u3 / d; - } - else - { - uint8* bb = (uint8*)(buf); - uint8 u1 = bb[spp*x+0]; - uint8 u2 = bb[spp*x+1]; - uint8 u3 = bb[spp*x+2]; - deValue d = 256 - 1; - r = u1 / d; - g = u2 / d; - b = u3 / d; - } - - pixelsR[pos] = r; - pixelsG[pos] = g; - pixelsB[pos] = b; - - pos++; - } - } - - channelR.unlockWrite(); - channelG.unlockWrite(); - channelB.unlockWrite(); - - _TIFFfree(buf); - TIFFClose(tif); - logMessage("loadTIFF " + fileName + " done"); - - return true; -} - diff -Nru delaboratory-0.7/src/image_io.h delaboratory-0.8/src/image_io.h --- delaboratory-0.7/src/image_io.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_io.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_IMAGE_IO_H -#define _DE_IMAGE_IO_H - -#include -#include "size.h" -#include "channel.h" -#include "color_space.h" -class deStaticImage; - -void saveJPEG(const std::string& fileName, const deChannel& channelR, const deChannel& channelG, const deChannel& channelB, deSize size); -void saveTIFF(const std::string& fileName, const deChannel& channelR, const deChannel& channelG, const deChannel& channelB, deSize size); - -bool loadTIFF(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace); -bool loadJPEG(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace); - -bool loadPPM(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace); - -#endif diff -Nru delaboratory-0.7/src/image_panel.cc delaboratory-0.8/src/image_panel.cc --- delaboratory-0.7/src/image_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,272 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "image_panel.h" -#include -#include "project.h" -#include "layer.h" -#include "layer_processor.h" -#include -#include "str.h" -#include "layer_frame_manager.h" -#include "zoom_manager.h" -#include "zoom_panel.h" -#include "image_area_panel.h" - -BEGIN_EVENT_TABLE(deImagePanel, wxPanel) -EVT_PAINT(deImagePanel::paintEvent) -END_EVENT_TABLE() - -void deImagePanel::click(wxMouseEvent &event) -{ - int ex = event.GetX(); - int ey = event.GetY(); - int xx; - int yy; - GetSize(&xx, &yy); - float x = (float) ex / xx; - float y = (float) ey / yy; - - clicked = true; - - onClick(x,y); - -} - -void deImagePanel::release(wxMouseEvent &event) -{ - clicked = false; - - onRelease(); - - project.getLayerProcessor().onGUIUpdate(); -} - -void deImagePanel::move(wxMouseEvent &event) -{ - int ex = event.GetX(); - int ey = event.GetY(); - int xx; - int yy; - GetSize(&xx, &yy); - float x = (float) ex / xx; - float y = (float) ey / yy; - - if (clicked) - { - if (onMove(x,y)) - { - project.getLayerProcessor().onGUIUpdate(); - } - } - -} - -void deImagePanel::wheel(wxMouseEvent &event) -{ -} - - -bool deImagePanel::onClick(deValue x, deValue y) -{ - if (zoomManager.isInSelectionMode()) - { - bool result = zoomManager.onClick(x, y); - zoomPanel->updateButtons(); - return result; - } - - bool used = project.getLayerFrameManager().onImageClick(x, y); - - if (!used) - { - used = samplerManager.onClick(x, y); - if (used) - { - project.getLayerProcessor().onGUIUpdate(); - } - } - - return used; -} - -bool deImagePanel::onMove(deValue x, deValue y) -{ - if (zoomManager.isInSelectionMode()) - { - bool result = zoomManager.onMove(x, y); - zoomPanel->updateButtons(); - return result; - } - - bool used = project.getLayerFrameManager().onImageClick(x, y); - - if (!used) - { - used = samplerManager.onMove(x, y); - } - - return used; -} - -bool deImagePanel::onRelease() -{ - if (zoomManager.isInSelectionMode()) - { - bool result = zoomManager.onRelease(); - zoomPanel->updateButtons(); - area->updateSize(true); - return result; - } - - samplerManager.onRelease(); - - return false; -} - -deImagePanel::deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel) -:wxPanel(_area, wxID_ANY, wxDefaultPosition, wxDefaultSize), area(_area), project(_project), samplerManager(_samplerManager), zoomManager(_zoomManager), zoomPanel(_zoomPanel) -{ - clicked = false; - - Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deImagePanel::click)); - Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deImagePanel::release)); - Connect(wxEVT_MOTION, wxMouseEventHandler(deImagePanel::move)); - Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(deImagePanel::wheel)); -} - -deImagePanel::~deImagePanel() -{ -} - -void deImagePanel::paintEvent(wxPaintEvent & evt) -{ - logMessage("paintEvent in deImagePanel"); - project.getLayerProcessor().lock(); - int view = project.getLayerProcessor().getLastValidLayer(); - logMessage("paintEvent view: " + str(view)); - if (view >= 0) - { - wxBufferedPaintDC dc(this); - dc.Clear(); - render(dc); - } - else - { - std::cout << "view: " << view << " in paintEvent" << std::endl; - } - project.getLayerProcessor().unlock(); -} - -void deImagePanel::repaintImagePanel() -{ - int view = project.getLayerProcessor().getLastValidLayer(); - if (view >= 0) - { - wxClientDC dc(this); - wxBufferedDC bufferedDC(&dc); - bufferedDC.Clear(); - render(bufferedDC); - } - else - { - std::cout << "view: " << view << " in repaintImagePanel" << std::endl; - } -} - -void deImagePanel::render(wxDC& dc) -{ - project.getLayerProcessor().render(dc); - if (samplerManager.getMoving()) - { - drawSamplers(dc); - } - if (zoomManager.isInSelectionMode()) - { - drawSelection(dc); - } -} - - -void deImagePanel::drawSamplers(wxDC& dc) -{ - int w; - int h; - GetSize(&w, &h); - - int n = samplerManager.getNumberOfSamplers(); - int selected = samplerManager.getSelected(); - - int i; - - wxPen penBLACK(*wxBLACK); - wxPen penGREEN(*wxGREEN); - - for (i = 0; i < n; i++) - { - deSampler* sampler = samplerManager.getSampler(i); - if (sampler->isEnabled()) - { - if (i == selected) - { - dc.SetPen(penGREEN); - } - else - { - dc.SetPen(penBLACK); - } - float x = sampler->getX(); - float y = sampler->getY(); - - if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) - { - dc.DrawCircle(w * x, h * y, 5); - } - } - } - -} - -void deImagePanel::drawSelection(wxDC& dc) -{ - int w; - int h; - GetSize(&w, &h); - - deValue x1; - deValue y1; - deValue x2; - deValue y2; - - zoomManager.getSelection(x1, y1, x2, y2); - - int xx1 = w * x1; - int yy1 = h * y1; - int xx2 = w * x2; - int yy2 = h * y2; - - wxPen pen(*wxWHITE); - dc.SetPen(pen); - - dc.DrawLine(xx1, yy1, xx2, yy1); - dc.DrawLine(xx1, yy2, xx2, yy2); - dc.DrawLine(xx1, yy1, xx1, yy2); - dc.DrawLine(xx2, yy1, xx2, yy2); - -} - diff -Nru delaboratory-0.7/src/image_panel.h delaboratory-0.8/src/image_panel.h --- delaboratory-0.7/src/image_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/image_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_IMAGE_PANEL_H -#define _DE_IMAGE_PANEL_H - -#include "wx/wx.h" -#include "renderer.h" -#include "value.h" -class deProject; -class deSamplerManager; -class deZoomManager; -class deZoomPanel; -class deImageAreaPanel; - -class deImagePanel:public wxPanel -{ -private: - - deImageAreaPanel* area; - - deProject& project; - bool clicked; - deSamplerManager& samplerManager; - deZoomManager& zoomManager; - deZoomPanel* zoomPanel; - - void click(wxMouseEvent &event); - void release(wxMouseEvent &event); - void move(wxMouseEvent &event); - void wheel(wxMouseEvent &event); - - bool onClick(deValue x, deValue y); - bool onMove(deValue x, deValue y); - bool onRelease(); - - void drawSamplers(wxDC& dc); - void drawSelection(wxDC& dc); - -public: - deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel); - virtual ~deImagePanel(); - - void paintEvent(wxPaintEvent & evt); - void render(wxDC& dc); - void repaintImagePanel(); - - DECLARE_EVENT_TABLE() - -}; - -#endif diff -Nru delaboratory-0.7/src/layer.cc delaboratory-0.8/src/layer.cc --- delaboratory-0.7/src/layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer.h" -#include -#include "xml.h" -#include "str.h" -#include "layer_processor.h" -#include "logger.h" -#include "property_value.h" -#include "preset.h" - -deLayer::deLayer(const std::string& _name, deColorSpace _colorSpace, int _index, int _sourceLayer) -:name(_name), -mutex(wxMUTEX_RECURSIVE), -colorSpace(_colorSpace), -index(_index), -sourceLayer(_sourceLayer) -{ - logMessage("creating layer " + str(index) + " " + name); -} - -deLayer::~deLayer() -{ - logMessage("destroying layer " + str(index) + " " + name); - while (valueProperties.size() > 0) - { - std::vector::iterator i = valueProperties.begin(); - //std::vector::iterator i = valueProperties.begin(); - //dePropertyValue* p = *i; - deProperty* p = *i; - delete p; - valueProperties.erase(i); - } - while (presets.size() > 0) - { - std::map::iterator i = presets.begin(); - delete i->second; - presets.erase(i); - } - logMessage("destroyed layer " + str(index) + " " + name); -} - -deColorSpace deLayer::getColorSpace() const -{ - return colorSpace; -} - -std::string deLayer::getName() const -{ - return name; -} - -bool deLayer::hasAction() const -{ - return false; -} - -bool deLayer::hasBlending() const -{ - return false; -} - -bool deLayer::canDisable() const -{ - return false; -} - -bool deLayer::isEnabled() const -{ - return true; -} - -void deLayer::setEnabled(bool e) -{ -} - -void deLayer::saveCommon(xmlNodePtr node) -{ - saveChild(node, "type", getType()); - saveChild(node, "name", name); - saveChild(node, "index", str(index)); - saveChild(node, "source", str(sourceLayer)); - saveChild(node, "color_space", getColorSpaceName(colorSpace)); -} - -bool deLayer::updateImageThreadCall() -{ -// std::cout << "updateImageThreadCall :(" << std::endl; - return updateImage(); -} - -void deLayer::lockLayer() -{ - lockWithLog(mutex, "layer mutex"); -} - -void deLayer::unlockLayer() -{ - //log("layer " + str(index) + " unlock"); - mutex.Unlock(); -} - -void deLayer::process(deLayerProcessType type, int channel) -{ - switch (type) - { - case deLayerProcessFull: - { - processFull(); - break; - } - case deLayerProcessSingleChannel: - { - processChannel(channel); - break; - } - case deLayerProcessBlend: - { - processBlend(); - break; - } - default: - break; - } -} - -void deLayer::processFull() -{ -// std::cout << "processFull :(" << std::endl; - updateImageThreadCall(); -} - -void deLayer::processBlend() -{ -} - -void deLayer::processChannel(int channel) -{ -} - -std::string deLayer::getLabel() const -{ - return getType(); -} - -int deLayer::registerPropertyValue(const std::string& _name) -{ - dePropertyValue* p = new dePropertyValue(_name); - valueProperties.push_back(p); - return valueProperties.size() - 1; -} - -dePropertyValue* deLayer::getPropertyValue(int index) -{ - if ((index < 0) || ((unsigned int)(index) >= valueProperties.size())) - { - return NULL; - } - deProperty* property = valueProperties[index]; - - return dynamic_cast(property); -} - -void deLayer::saveValueProperties(xmlNodePtr root) -{ - int n = getNumberOfValueProperties(); - int i; - for (i = 0; i < n; i++) - { - dePropertyValue* p = getPropertyValue(i); - p->save(root); - } -} - -void deLayer::loadValueProperties(xmlNodePtr root) -{ - int n = getNumberOfValueProperties(); - int i; - for (i = 0; i < n; i++) - { - dePropertyValue* p = getPropertyValue(i); - p->load(root); - } -} - -dePropertyValue* deLayer::getPropertyValue(const std::string& _name) -{ - int n = getNumberOfValueProperties(); - int i; - for (i = 0; i < n; i++) - { - dePropertyValue* p = getPropertyValue(i); - if (p->getName() == _name) - { - return p; - } - } - return NULL; -} - -bool deLayer::applyPreset(const std::string& _name) -{ - std::map::iterator i = presets.find(_name); - - if (i == presets.end()) - { - return false; - } - - dePresetLayer* preset = i->second; - - preset->apply(); - - return true; -} - -void deLayer::getPresets(std::vector& result) -{ - std::map::iterator i; - for (i = presets.begin(); i != presets.end(); i++) - { - std::string n = i->first; - result.push_back(n); - } -} diff -Nru delaboratory-0.7/src/layer_factory.cc delaboratory-0.8/src/layer_factory.cc --- delaboratory-0.7/src/layer_factory.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_factory.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_factory.h" -#include "layer_stack.h" -#include "curves_layer.h" -#include "blur_layer.h" -#include "vignette_layer.h" -#include "apply_image_layer.h" -#include "mixer_layer.h" -#include "equalizer_layer.h" -#include "conversion_layer.h" -#include "conversion_bw_layer.h" -#include "conversion_bw2hue_layer.h" -#include "usm_layer.h" -#include "source_image_layer.h" -#include "dodge_burn_layer.h" -#include "high_pass_layer.h" -#include "shadows_highlights_layer.h" -#include "basic_layer.h" -#include - -deLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& name, deStaticImage& sourceImage) -{ - int index = _layerStack.getSize(); - - if (type == "curves") - { - return new deCurvesLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "blur") - { - return new deBlurLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "vignette1") - { - return new deVignetteLayer1(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "vignette2") - { - return new deVignetteLayer2(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "usm") - { - return new deUSMLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "basic") - { - return new deBasicLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "dodge_burn") - { - return new deDodgeBurnLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "high_pass") - { - return new deHighPassLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "shadows_highlights") - { - return new deShadowsHighlightsLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "mixer") - { - return new deMixerLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "equalizer8") - { - return new deEqualizerLayer8(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "equalizer16") - { - return new deEqualizerLayer16(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - if (type == "apply_image") - { - return new deApplyImageLayer(colorSpace, index, source, _layerStack, _channelManager, _viewManager, name); - } - - bool cbw = false; - bool cbwhue = false; - - if (type == "conversion") - { - if (colorSpace == deColorSpaceBW) - { - cbw = true; - } - else - { - deLayer* sourceLayer = _layerStack.getLayer(source); - deColorSpace sourceColorSpace = sourceLayer->getColorSpace(); - if (sourceColorSpace == deColorSpaceBW) - { - switch (colorSpace) - { - case deColorSpaceHSL: - case deColorSpaceHSV: - case deColorSpaceLCH: - { - cbwhue = true; - break; - } - default: - break; - } - } - } - - if ((!cbw) && (!cbwhue)) - { - return new deConversionLayer(colorSpace, index, source, _layerStack, _channelManager); - } - } - - if (type == "conversion_bw") - { - cbw = true; - } - - if (type == "conversion_bw2hue") - { - cbwhue = true; - } - - if (cbw) - { - deLayer* sourceLayer = _layerStack.getLayer(source); - deColorSpace sourceColorSpace = sourceLayer->getColorSpace(); - int n = getColorSpaceSize(sourceColorSpace); - return new deConversionBWLayer(index, source, _layerStack, _channelManager, n); - } - - if (cbwhue) - { - return new deConversionBW2HueLayer(index, source, _layerStack, _channelManager, colorSpace); - } - - if (type == "source_image") - { - return new deSourceImageLayer(index, _channelManager, _viewManager, sourceImage, colorSpace); - } - - return NULL; -} - -void getSupportedActions(std::vector& actions) -{ - actions.push_back("curves"); - actions.push_back("basic"); - actions.push_back("mixer"); - actions.push_back("equalizer8"); - actions.push_back("equalizer16"); - actions.push_back("apply_image"); - - actions.push_back("vignette1"); - actions.push_back("vignette2"); - actions.push_back("dodge_burn"); - actions.push_back("shadows_highlights"); - - actions.push_back("usm"); - actions.push_back("high_pass"); - actions.push_back("blur"); -} - -std::string getActionGroup(const std::string n) -{ - if ((n == "vignette1") || (n == "vignette2") || (n == "dodge_burn") || (n == "shadows_highlights")) - { - return "light"; - } - - if ((n == "blur") || (n == "high_pass") || (n == "usm")) - { - return "sharp"; - } - - return "gen"; -} - -void getSupportedActionGroups(std::vector& names) -{ - std::vector actions; - getSupportedActions(actions); - std::vector::const_iterator i; - for (i = actions.begin(); i != actions.end(); i++) - { - std::string n = getActionGroup(*i); - std::vector::iterator j = find(names.begin(), names.end(), n); - if (j == names.end()) - { - names.push_back(n); - } - } -} - - -std::string getActionDescription(const std::string& a) -{ - if (a == "shadows_highlights") - { - return "sh / hi"; - } - - if (a == "apply_image") - { - return "apply image"; - } - - if (a == "high_pass") - { - return "high pass"; - } - - if (a == "dodge_burn") - { - return "d / b"; - } - - return a; -} - diff -Nru delaboratory-0.7/src/layer_factory.h delaboratory-0.8/src/layer_factory.h --- delaboratory-0.7/src/layer_factory.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_factory.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_FACTORY_H -#define _DE_LAYER_FACTORY_H - -class deLayer; -#include -#include -#include "color_space.h" -class deLayerStack; -class deLayerProcessor; -class deChannelManager; -class deViewManager; -class deImage; -class deStaticImage; - -deLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& name, deStaticImage& sourceImage); -void getSupportedActions(std::vector& actions); -std::string getActionDescription(const std::string& a); -void getSupportedActionGroups(std::vector& actions); -std::string getActionGroup(const std::string n); - -#endif diff -Nru delaboratory-0.7/src/layer_frame.cc delaboratory-0.8/src/layer_frame.cc --- delaboratory-0.7/src/layer_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_frame.h" -#include "action_layer.h" - -deLayerFrame::deLayerFrame(wxWindow *parent, deLayer& _layer, const std::string& name, deLayerFrameManager& _frameManager) -:deFrame(parent, name), -layer(_layer), -frameManager(_frameManager) -{ -} - -deLayerFrame::~deLayerFrame() -{ -} - -bool deLayerFrame::checkIndex(int index) -{ - if (layer.getIndex() == index) - { - return true; - } - - return false; -} diff -Nru delaboratory-0.7/src/layer_frame.h delaboratory-0.8/src/layer_frame.h --- delaboratory-0.7/src/layer_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_FRAME_H -#define _DE_LAYER_FRAME_H - -#include "frame.h" -class deActionLayer; -class deLayer; -class deLayerFrameManager; - -class deLayerFrame:public deFrame -{ - protected: - deLayer& layer; - deLayerFrameManager& frameManager; - public: - //deLayerFrame(wxWindow *parent, deActionLayer& _layer, const std::string& name, deLayerFrameManager& _frameManager); - deLayerFrame(wxWindow *parent, deLayer& _layer, const std::string& name, deLayerFrameManager& _frameManager); - virtual ~deLayerFrame(); - - bool checkIndex(int index); - -}; - -#endif diff -Nru delaboratory-0.7/src/layer_frame_manager.cc delaboratory-0.8/src/layer_frame_manager.cc --- delaboratory-0.7/src/layer_frame_manager.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_frame_manager.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_frame_manager.h" -#include "layer_frame.h" - -deLayerFrameManager::deLayerFrameManager() -{ -} - -deLayerFrameManager::~deLayerFrameManager() -{ - destroyAllFrames(); -} - -void deLayerFrameManager::destroyAllFrames() -{ - while (actionFrames.size() > 0) - { - std::list::iterator i = actionFrames.begin(); - actionFrames.remove(*i); - delete *i; - } - while (blendFrames.size() > 0) - { - std::list::iterator i = blendFrames.begin(); - blendFrames.remove(*i); - delete *i; - } -} - -void deLayerFrameManager::addActionFrame(deFrame* frame) -{ - deLayerFrame* lf = dynamic_cast(frame); - if (lf) - { - actionFrames.push_back(lf); - } -} - -void deLayerFrameManager::removeActionFrame(deFrame* frame) -{ - deLayerFrame* lf = dynamic_cast(frame); - if (lf) - { - actionFrames.remove(lf); - } -} - -bool deLayerFrameManager::checkActionFrame(int index) -{ - std::list::const_iterator i; - for (i = actionFrames.begin(); i != actionFrames.end(); i++) - { - if ((*i)->checkIndex(index)) - { - return true; - } - } - return false; -} - -void deLayerFrameManager::addBlendFrame(deFrame* frame) -{ - deLayerFrame* lf = dynamic_cast(frame); - if (lf) - { - blendFrames.push_back(lf); - } -} - -void deLayerFrameManager::removeBlendFrame(deFrame* frame) -{ - deLayerFrame* lf = dynamic_cast(frame); - if (lf) - { - blendFrames.remove(lf); - } -} - -bool deLayerFrameManager::checkBlendFrame(int index) -{ - std::list::const_iterator i; - for (i = blendFrames.begin(); i != blendFrames.end(); i++) - { - if ((*i)->checkIndex(index)) - { - return true; - } - } - return false; -} - -void deLayerFrameManager::onDestroyLayer(int index) -{ - destroyActionFrame(index); - destroyBlendFrame(index); -} - -void deLayerFrameManager::destroyActionFrame(int index) -{ - std::list::const_iterator i; - for (i = actionFrames.begin(); i != actionFrames.end(); i++) - { - if ((*i)->checkIndex(index)) - { - actionFrames.remove(*i); - delete *i; - return; - } - } -} - -void deLayerFrameManager::destroyBlendFrame(int index) -{ - std::list::const_iterator i; - for (i = blendFrames.begin(); i != blendFrames.end(); i++) - { - if ((*i)->checkIndex(index)) - { - blendFrames.remove(*i); - delete *i; - return; - } - } -} - -bool deLayerFrameManager::onImageClick(deValue x, deValue y) -{ - std::list::const_iterator i; - for (i = actionFrames.begin(); i != actionFrames.end(); i++) - { - deActionFrame* trueActionFrame = dynamic_cast(*i); - if (trueActionFrame) - { - return trueActionFrame->onImageClick(x, y); - } - } - return false; -} - -void deLayerFrameManager::onKey(int key) -{ - std::list::const_iterator i; - for (i = actionFrames.begin(); i != actionFrames.end(); i++) - { - deActionFrame* trueActionFrame = dynamic_cast(*i); - if (trueActionFrame) - { - trueActionFrame->onKey(key); - } - } -} - -void deLayerFrameManager::onUpdateProperties() -{ - std::list::const_iterator i; - for (i = actionFrames.begin(); i != actionFrames.end(); i++) - { - deActionFrame* trueActionFrame = dynamic_cast(*i); - if (trueActionFrame) - { - trueActionFrame->onUpdateProperties(); - } - } -} diff -Nru delaboratory-0.7/src/layer_frame_manager.h delaboratory-0.8/src/layer_frame_manager.h --- delaboratory-0.7/src/layer_frame_manager.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_frame_manager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_FRAME_MANAGER_H -#define _DE_LAYER_FRAME_MANAGER_H - -#include - -#include "value.h" -#include "action_frame.h" - -class deLayerFrame; -class deFrame; - -class deLayerFrameManager -{ - private: - std::list actionFrames; - std::list blendFrames; - deLayerFrameManager(const deLayerFrameManager& ); - deLayerFrameManager& operator =(const deLayerFrameManager& ); - - public: - deLayerFrameManager(); - virtual ~deLayerFrameManager(); - - void addActionFrame(deFrame* frame); - void removeActionFrame(deFrame* frame); - bool checkActionFrame(int index); - - void addBlendFrame(deFrame* frame); - void removeBlendFrame(deFrame* frame); - bool checkBlendFrame(int index); - - void onDestroyLayer(int index); - - void destroyActionFrame(int index); - void destroyBlendFrame(int index); - - bool onImageClick(deValue x, deValue y); - void onKey(int key); - - void destroyAllFrames(); - - void onUpdateProperties(); - -}; - -#endif diff -Nru delaboratory-0.7/src/layer_grid_panel.cc delaboratory-0.8/src/layer_grid_panel.cc --- delaboratory-0.7/src/layer_grid_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_grid_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,269 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_grid_panel.h" - -#include "project.h" -#include -#include "layer.h" - -#include - -#include "layer_factory.h" -#include "layer_processor.h" - -#include "frame_factory.h" - -#include "frame.h" - -#include "blend_frame.h" -#include "action_layer.h" - -#include "str.h" - -#include "layer_stack.h" - -#include "layer_frame_manager.h" - -void deLayerGridPanel::buildRows() -{ - project.log("build rows start"); - - deLayerStack& layerStack = project.getLayerStack(); - int n = layerStack.getSize(); - - int i; - for (i = n-1; i >=0; i--) - { - project.log("build rows i=" + str(i)); - deLayer* layer = layerStack.getLayer(i); - - layerRows.push_back(deLayerRow(i)); - deLayerRow& row = layerRows.back(); - - std::ostringstream oss; - oss << i; - - row.id = new wxStaticText(this, wxID_ANY, wxString::FromAscii(oss.str().c_str()), wxDefaultPosition, wxSize(18, -1)); - gridSizer->Add(row.id, 0, wxALIGN_CENTER); - - int style = 0; - if (i == n-1) - { - style = wxRB_GROUP; - } - - row.view = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); - gridSizer->Add(row.view, 0, wxALIGN_CENTER); - - row.name = new wxStaticText(this, wxID_ANY, wxString::FromAscii(layer->getName().c_str()), wxDefaultPosition, wxSize(100, -1)); - gridSizer->Add(row.name, 0, wxALIGN_CENTER); - - std::string action = layer->getActionName(); - - row.action = new wxButton(this, wxID_ANY, wxString::FromAscii(action.c_str()), wxDefaultPosition, wxSize(60,25)); - if (layer->hasAction()) - { - gridSizer->Add(row.action, 0); - } - else - { - gridSizer->Add(row.action, 0); - row.action->Hide(); - } - - row.blend = new wxButton(this, wxID_ANY, _T("blend"), wxDefaultPosition, wxSize(60,25)); - if (layer->hasBlending()) - { - gridSizer->Add(row.blend, 0); - } - else - { - gridSizer->Add(row.blend, 0); - row.blend->Hide(); - } - - row.enabled = new wxCheckBox(this, wxID_ANY, _T("")); - if (layer->isEnabled()) - { - row.enabled->SetValue(true); - } - if (layer->canDisable()) - { - gridSizer->Add(row.enabled, 0, wxALIGN_CENTER); - } - else - { - gridSizer->Add(row.enabled, 0, wxALIGN_CENTER); - row.enabled->Hide(); - } - - } - project.log("build rows end"); - -} - -void deLayerGridPanel::clearRows() -{ - project.log("clear rows start"); - - std::vector::iterator i; - int index = 0; - for (i = layerRows.begin(); i != layerRows.end(); i++) - { - project.log("clear rows index=" + str(index)); - index++; - deLayerRow& row = *i; - - gridSizer->Detach(row.id); - delete row.id; - - gridSizer->Detach(row.view); - delete row.view; - - gridSizer->Detach(row.name); - delete row.name; - - gridSizer->Detach(row.action); - delete row.action; - - gridSizer->Detach(row.blend); - delete row.blend; - - gridSizer->Detach(row.enabled); - delete row.enabled; - } - - gridSizer->Clear(); - - layerRows.clear(); - project.log("clear rows end"); -} - -deLayerGridPanel::deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(250, 400)), project(_project), layerProcessor(_processor) -{ - maxRows = 10; - - gridSizer = new wxFlexGridSizer(6); - gridSizer->SetFlexibleDirection(wxHORIZONTAL); - SetSizer(gridSizer); - - buildRows(); - - SetMinSize(wxSize(300, 360)); - - Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deLayerGridPanel::check)); - Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deLayerGridPanel::select)); - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deLayerGridPanel::click)); -} - -deLayerGridPanel::~deLayerGridPanel() -{ -} - -void deLayerGridPanel::check(wxCommandEvent &event) -{ - int id = event.GetId(); - bool checked = (event.GetInt() == 1); - std::vector::const_iterator i; - for (i = layerRows.begin(); i != layerRows.end(); i++) - { - const deLayerRow& row = *i; - if (row.enabled->GetId() == id) - { - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(row.index); - layer->setEnabled(checked); - int index = row.index; - layerProcessor.markUpdateAllChannels(index); - layerProcessor.onChangeViewMode(); - } - } -} - -void deLayerGridPanel::select(wxCommandEvent &event) -{ - int id = event.GetId(); - std::vector::const_iterator i; - for (i = layerRows.begin(); i != layerRows.end(); i++) - { - const deLayerRow& row = *i; - if (row.view->GetId() == id) - { - project.getViewManager().setView(row.index); - layerProcessor.onChangeViewMode(); - } - } -} - -void deLayerGridPanel::click(wxCommandEvent &event) -{ - project.log("click in layer grid panel"); - deLayerStack& layerStack = project.getLayerStack(); - int id = event.GetId(); - std::vector::const_iterator i; - for (i = layerRows.begin(); i != layerRows.end(); i++) - { - deLayerFrameManager& frameManager = project.getLayerFrameManager(); - - const deLayerRow& row = *i; - if (row.action->GetId() == id) - { - project.log("new action frame requested in row " + str(row.index)); - deLayer* layer = layerStack.getLayer(row.index); - - //if (!layer->checkActionFrame()) - if (!project.getLayerFrameManager().checkActionFrame(row.index)) - { - project.log("creating action frame"); - deFrame* actionFrame = createFrame(this, *layer, layerProcessor, frameManager); - if (actionFrame) - { -// project.getLayerFrameManager().addActionFrame(actionFrame); -// layer->setActionFrame(actionFrame); - project.log("created action frame"); - actionFrame->Show(true); - } - } - - } - if (row.blend->GetId() == id) - { - project.log("new blend frame requested in row " + str(row.index)); - - deLayer* layer = layerStack.getLayer(row.index); - deActionLayer* al = dynamic_cast(layer); - //if (!layer->checkBlendFrame()) - if (!frameManager.checkBlendFrame(row.index)) - { - project.log("creating blend frame"); - deBlendFrame* blendFrame = new deBlendFrame(this, *al, layerProcessor, frameManager); - if (blendFrame) - { - //layer->setBlendFrame(blendFrame); - // frameManager.addBlendFrame(blendFrame); - project.log("created blend frame"); - blendFrame->Show(true); - } - } - } - } - -} - diff -Nru delaboratory-0.7/src/layer_grid_panel.h delaboratory-0.8/src/layer_grid_panel.h --- delaboratory-0.7/src/layer_grid_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_grid_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_GRID_PANEL_H -#define _DE_LAYER_GRID_PANEL_H - -#include -#include -#include - -class deProject; -class deLayerProcessor; - -class deLayerGridPanel:public wxPanel -{ - class deLayerRow - { - public: - deLayerRow(int _index) - :index(_index) - { - }; - - int index; - wxStaticText* id; - wxRadioButton* view; - wxStaticText* name; - wxButton* action; - wxButton* blend; - wxCheckBox* enabled; - }; - - private: - std::vector layerRows; - - deProject& project; - deLayerProcessor& layerProcessor; - - wxSizer* mainSizer; - - wxFlexGridSizer* gridSizer; - - int maxRows; - - void check(wxCommandEvent &event); - void select(wxCommandEvent &event); - void click(wxCommandEvent &event); - - public: - deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor); - ~deLayerGridPanel(); - - void buildRows(); - void clearRows(); - -}; - -#endif diff -Nru delaboratory-0.7/src/layer.h delaboratory-0.8/src/layer.h --- delaboratory-0.7/src/layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_H -#define _DE_LAYER_H - -#include -#include -#include "color_space.h" -#include - -class deProject; -class deFrame; -class deBlendFrame; -class deImage; -class dePropertyValue; -class deProperty; -class dePresetLayer; - -enum deLayerProcessType -{ - deLayerProcessInvalid, - deLayerProcessFull, - deLayerProcessSingleChannel, - deLayerProcessBlend -}; - -class deLayer -{ - private: - deLayer(const deLayer& layer); - deLayer& operator = (const deLayer& layer); - std::string name; - wxMutex mutex; - - virtual bool updateImage() = 0; - - protected: - deColorSpace colorSpace; - unsigned int index; - unsigned int sourceLayer; - - std::vector valueProperties; - //std::vector valueProperties; - std::map presets; - - int registerPropertyValue(const std::string& _name); - - void saveCommon(xmlNodePtr node); - void saveValueProperties(xmlNodePtr node); - void loadValueProperties(xmlNodePtr root); - - public: - deLayer(const std::string& _name, deColorSpace _colorSpace, int _index, int _sourceLayer); - virtual ~deLayer(); - - deColorSpace getColorSpace() const; - virtual const deImage& getImage() const = 0; - - std::string getName() const; - virtual std::string getLabel() const; - - virtual bool hasAction() const; - virtual bool hasBlending() const; - virtual bool canDisable() const; - - virtual bool isEnabled() const; - virtual void setEnabled(bool e); - - virtual void updateChannelUsage(std::map& channelUsage) const = 0; - - int getIndex() const {return index;}; - - virtual void load(xmlNodePtr root) = 0; - virtual void save(xmlNodePtr root) = 0; - - virtual std::string getActionName() {return "action";}; - - virtual std::string getType() const = 0; - - bool updateImageThreadCall(); - - virtual bool randomize() = 0; - - void lockLayer(); - void unlockLayer(); - - void process(deLayerProcessType type, int channel); - - virtual void processFull(); - virtual void processBlend(); - virtual void processChannel(int channel); - - virtual void onUpdateProperties() {}; - - int getNumberOfValueProperties() const {return valueProperties.size();}; - dePropertyValue* getPropertyValue(int index); - dePropertyValue* getPropertyValue(const std::string& _name); - - bool applyPreset(const std::string& _name); - void getPresets(std::vector& result); - - -}; - -#endif diff -Nru delaboratory-0.7/src/layer_processor.cc delaboratory-0.8/src/layer_processor.cc --- delaboratory-0.7/src/layer_processor.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_processor.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,888 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_processor.h" -#include "main_frame.h" -#include "layer_frame_manager.h" -#include "layer_stack.h" -#include "view_manager.h" -#include -#include "layer.h" -#include "channel_manager.h" -#include "str.h" -#include "memory_info_frame.h" -#include -#include -#include "action_layer.h" -#include "logger.h" -#include "renderer.h" - -class deLayerProcessorWorkerThread:public wxThread -{ - private: - void performTasks() - { - while (true) - { - if (processor.isClosing()) - { - return; - } - - logMessage("worker thread before wait"); - semaphore.Wait(); - logMessage("worker thread after wait"); - Sleep(10); - - if (TestDestroy()) - { - return; - } - - processor.tickWork(); - - if (TestDestroy()) - { - return; - } - } - } - - virtual void *Entry() - { - performTasks(); - logMessage("worker thread finished"); - return NULL; - } - deLayerProcessor& processor; - wxSemaphore& semaphore; - - public: - deLayerProcessorWorkerThread(deLayerProcessor& _processor, wxSemaphore& _semaphore) - :processor(_processor), - semaphore(_semaphore) - { - logMessage("worker thread created"); - } - virtual ~deLayerProcessorWorkerThread() - { - } -}; - -class deRenderWorkerThread:public wxThread -{ - private: - void performTasks() - { - while (true) - { - if (processor.isClosing()) - { - return; - } - - logMessage("render thread before wait"); - semaphore.Wait(); - logMessage("render thread after wait"); - Sleep(10); - - if (TestDestroy()) - { - return; - } - - if (processor.prepareImage()) - { - processor.sendRepaintEvent(); - } - - if (TestDestroy()) - { - return; - } - } - } - - virtual void *Entry() - { - performTasks(); - logMessage("render thread finished"); - return NULL; - } - - deLayerProcessor& processor; - wxSemaphore& semaphore; - - public: - deRenderWorkerThread(deLayerProcessor& _processor, wxSemaphore& _semaphore) - :processor(_processor), - semaphore(_semaphore) - { - logMessage("render thread created"); - } - virtual ~deRenderWorkerThread() - { - } -}; - -class deHistogramWorkerThread:public wxThread -{ - private: - void performTasks() - { - while (true) - { - if (processor.isClosing()) - { - return; - } - - logMessage("histogram thread before wait"); - semaphore.Wait(); - logMessage("histogram thread after wait"); - Sleep(10); - - if (TestDestroy()) - { - return; - } - - processor.onGenerateHistogram(); - processor.sendHistogramEvent(); - - if (TestDestroy()) - { - return; - } - } - } - - virtual void *Entry() - { - performTasks(); - logMessage("histogram thread finished"); - return NULL; - } - - deLayerProcessor& processor; - wxSemaphore& semaphore; - - public: - deHistogramWorkerThread(deLayerProcessor& _processor, wxSemaphore& _semaphore) - :processor(_processor), - semaphore(_semaphore) - { - logMessage("histogram thread created"); - } - virtual ~deHistogramWorkerThread() - { - } -}; - - -deLayerProcessor::deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager) -: -layerStack(_layerStack), -layerFrameManager(_layerFrameManager), -renderWorkerSemaphore(1, 1), -histogramWorkerSemaphore(1, 1), -layerProcessMutex(wxMUTEX_RECURSIVE), -histogramMutex(wxMUTEX_RECURSIVE), -prepareImageMutex(wxMUTEX_RECURSIVE), -updateImageMutex(wxMUTEX_RECURSIVE), -updateImagesMutex(wxMUTEX_RECURSIVE), -renderer(_previewChannelManager), -previewChannelManager(_previewChannelManager) -{ - mainFrame = NULL; - viewManager = NULL; - - histogramWorkerThread = NULL; - workerThread = NULL; - renderWorkerThread = NULL; - - firstLayerToUpdate = 0; - lastValidLayer = -1; - - layerProcessType = deLayerProcessInvalid; - layerProcessChannel = -1; - - closing = false; - - realtime = true; - -} - -void deLayerProcessor::onDestroyAll() -{ - lock(); - - lastValidLayer = -1; - - unlock(); -} - -deLayerProcessor::~deLayerProcessor() -{ - logMessage("destroying layer processor"); -} - -void deLayerProcessor::setMainFrame(deMainFrame* _mainFrame) -{ - mainFrame = _mainFrame; -} - -void deLayerProcessor::stopWorkerThread() -{ - logMessage("stop worker thread"); - closing = true; - - logMessage("worker thread post before delete"); - workerSemaphore.Post(); - logMessage("stop worker thread - workerThread delete"); - workerThread->Delete(); - - logMessage("render worker thread post before delete"); - renderWorkerSemaphore.Post(); - - logMessage("stop worker thread - renderWorkerThread delete"); - renderWorkerThread->Delete(); - - logMessage("histogram worker thread post before delete"); - histogramWorkerSemaphore.Post(); - logMessage("stop worker thread - histogramWorkerThread delete"); - histogramWorkerThread->Delete(); - - logMessage("stop worker thread done"); -} - -void deLayerProcessor::startWorkerThread() -{ - logMessage("starting worker threads..."); - - workerThread = new deLayerProcessorWorkerThread(*this, workerSemaphore); - - if ( workerThread->Create() != wxTHREAD_NO_ERROR ) - { - } - - if ( workerThread->Run() != wxTHREAD_NO_ERROR ) - { - } - - renderWorkerThread = new deRenderWorkerThread(*this, renderWorkerSemaphore); - - if ( renderWorkerThread->Create() != wxTHREAD_NO_ERROR ) - { - } - - if ( renderWorkerThread->Run() != wxTHREAD_NO_ERROR ) - { - } - - histogramWorkerThread = new deHistogramWorkerThread(*this, histogramWorkerSemaphore); - - if ( histogramWorkerThread->Create() != wxTHREAD_NO_ERROR ) - { - } - - if ( histogramWorkerThread->Run() != wxTHREAD_NO_ERROR ) - { - } -} - -void deLayerProcessor::setViewManager(deViewManager* _viewManager) -{ - viewManager = _viewManager; -} - -void deLayerProcessor::repaintImageInLayerProcessor() -{ - - if (closing) - { - logMessage("skip repaintImage because closing"); - return; - } - - logMessage("repaintImage post..."); - - renderWorkerSemaphore.Post(); - generateHistogram(); - -} - -void deLayerProcessor::generateHistogram() -{ - if (closing) - { - logMessage("skip generateHistogram because closing"); - return; - } - - logMessage("generate histogram post..."); - - histogramWorkerSemaphore.Post(); -} - -void deLayerProcessor::sendRepaintEvent() -{ - if (closing) - { - return; - } - - if (mainFrame) - { - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, DE_REPAINT_EVENT ); - wxPostEvent( mainFrame, event ); - } -} - -void deLayerProcessor::sendInfoEvent(int i) -{ - if (closing) - { - return; - } - - if (mainFrame) - { - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, DE_INFO_EVENT ); - event.SetInt(i); - wxPostEvent( mainFrame, event ); - } -} - -void deLayerProcessor::sendHistogramEvent() -{ - if (closing) - { - return; - } - - if (mainFrame) - { - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, DE_HISTOGRAM_EVENT ); - wxPostEvent( mainFrame, event ); - } -} - -void deLayerProcessor::updateAllImages(bool calcHistogram) -{ - updateImages(0, -1, true); -} - -void deLayerProcessor::lockLayers() -{ - lockWithLog(layerProcessMutex, "layer process mutex"); -} - -void deLayerProcessor::unlockLayers() -{ - logMessage("unlockLayers"); - layerProcessMutex.Unlock(); -} - -void deLayerProcessor::lockHistogram() -{ - lockWithLog(histogramMutex, "histogram mutex"); -} - -void deLayerProcessor::unlockHistogram() -{ - logMessage("unlockHistogram"); - histogramMutex.Unlock(); -} - -void deLayerProcessor::lockUpdateImage() -{ - lockWithLog(updateImageMutex, "update image mutex"); -} - -void deLayerProcessor::unlockUpdateImage() -{ - logMessage("unlockUpdateImage"); - updateImageMutex.Unlock(); -} - -void deLayerProcessor::lockPrepareImage() -{ - lockWithLog(prepareImageMutex, "prepare image mutex"); -} - -void deLayerProcessor::unlockPrepareImage() -{ - logMessage("unlockPrepare"); - prepareImageMutex.Unlock(); -} - -void deLayerProcessor::updateImages(int a, int channel, bool action) -{ - if (closing) - { - return; - } - -// std::cout << "updateImages " << channel << std::endl; - -// log("requested update images " + str(a) + " " + str(channel) + " " + str(blend) + " " + str(action)); - - //lock(); - - lockLayers(); - - if (a == firstLayerToUpdate) - { - if (layerProcessChannel != channel) - { - channel = -1; - } - } - - if (a < firstLayerToUpdate) - { - firstLayerToUpdate = a; - } - - if (channel >= 0) - { - layerProcessType = deLayerProcessSingleChannel; - layerProcessChannel = channel; - } - else - { - if (action) - { - layerProcessType = deLayerProcessFull; - } - else - { - layerProcessType = deLayerProcessBlend; - } - } - - unlockLayers(); - - checkUpdateImagesRequest(); - -// unlock(); -} - -bool deLayerProcessor::updateImage() -{ - lockUpdateImage(); - - lockLayers(); - - bool ok = true; - bool result = false; - -// std::cout << "updateImage" << std::endl; - - if (firstLayerToUpdate > getLastLayerToUpdate()) - { -// std::cout << "updateImage :(" << std::endl; - ok = false; - } - - int i = firstLayerToUpdate; - - deLayerProcessType type = deLayerProcessInvalid; - int channel = -1; - - layerStack.lock(); - - deLayer* layer = layerStack.getLayer(i); - if ((layer) && (ok)) - { -// std::cout << "updateImage !" << std::endl; - - layer->lockLayer(); - layerStack.unlock(); - - type = layerProcessType; - channel = layerProcessChannel; - - layerProcessType = deLayerProcessFull; - - lastValidLayer = i; - firstLayerToUpdate = i + 1; - } - else - { - layerStack.unlock(); - } - - unlockLayers(); - - if ((layer) && (ok)) - { -// std::cout << "updateImage process..." << std::endl; - layer->process(type, channel); - - layer->unlockLayer(); - - result = true; - } - - unlockUpdateImage(); - - return result; - -} - -bool deLayerProcessor::updateImagesSmart(int view, wxProgressDialog* progressDialog, deMemoryInfoFrame* memoryInfoFrame) -{ - bool result = true; - - lock(); - - std::map channelUsage; - generateChannelUsage(channelUsage); - - unsigned int index; - int progress = 0; - for (index = 0; index <= (unsigned int)view; index++) - { - std::map::iterator i; - int previous = index - 1; - if (previous >= 0) - { - for (i = channelUsage.begin(); i != channelUsage.end(); i++) - { - int c = i->first; - int l = i->second; - if (l == previous) - { - previewChannelManager.tryDeallocateChannel(c); - } - } - } - - deLayer* layer = layerStack.getLayer(index); - std::string label = str(index) + " " + layer->getName(); - - progressDialog->Update(progress, wxString::FromAscii(label.c_str())); - - bool r = layer->updateImageThreadCall(); - if (!r) - { - result = false; - // stop loop - index = view + 1; - } - - if (memoryInfoFrame) - { - memoryInfoFrame->update(); - } - - if (view > 0) - { - progress = 100 * index / view; - } - else - { - progress = 100; - } - - progressDialog->Update(progress, wxString::FromAscii(label.c_str())); - } - - progressDialog->Update(100, _T("finished")); - - unlock(); - - return result; -} - -void deLayerProcessor::generateChannelUsage(std::map& channelUsage) -{ - channelUsage.clear(); - int i; - int n = layerStack.getSize(); - for (i = 0; i < n; i++) - { - deLayer* layer = layerStack.getLayer(i); - layer->updateChannelUsage(channelUsage); - } -} - -void deLayerProcessor::markUpdateSingleChannel(int index, int channel) -{ -// std::cout << "markUpdateSingleChannel " << index << " " << channel << std::endl; - deLayer* layer = layerStack.getLayer(index); - if (layer) - { -// layerFrameManager.onUpdateProperties(); - layer->onUpdateProperties(); - } - - logMessage("markUpdateSingleChannel"); - updateImages(index, channel, true); -} - -void deLayerProcessor::markUpdateAllChannels(int index) -{ - deLayer* layer = layerStack.getLayer(index); - if (layer) - { - layerFrameManager.onUpdateProperties(); - layer->onUpdateProperties(); - } - - updateImages(index, -1, true); -} - -void deLayerProcessor::markUpdateBlendAllChannels(int index) -{ - updateImages(index, -1, false); -} - -void deLayerProcessor::onChangeView(int a) -{ - updateImages(a + 1, -1, true); -} - -void deLayerProcessor::lock() -{ - logMessage("layer processor lock"); - lockWithLog(updateImagesMutex, "update images mutex"); -} - -void deLayerProcessor::unlock() -{ - logMessage("layer processor unlock"); - updateImagesMutex.Unlock(); -} - -void deLayerProcessor::tickWork() -{ - sendInfoEvent(DE_PROCESSING_START); - - bool result = updateImage(); - - if (result) - { - checkUpdateImagesRequest(); - - repaintImageInLayerProcessor(); - } - - sendInfoEvent(DE_PROCESSING_END); -} - -void deLayerProcessor::onChangeViewMode() -{ - repaintImageInLayerProcessor(); -} - -void deLayerProcessor::onGUIUpdate() -{ - sendRepaintEvent(); -} - -void deLayerProcessor::removeTopLayer() -{ - lockHistogram(); - lockPrepareImage(); - lockUpdateImage(); - - int index = layerStack.getSize() - 1; - logMessage("requested remove top layer " + str(index)); - if (index > 0) - { - //lock(); - layerStack.removeTopLayer(); - int view = viewManager->getView(); - if (view >= layerStack.getSize()) - { - viewManager->setView( layerStack.getSize() - 1 ); - } - repaintImageInLayerProcessor(); - //unlock(); - } - - unlockUpdateImage(); - unlockPrepareImage(); - unlockHistogram(); -} - -void deLayerProcessor::removeAllLayers() -{ - lockHistogram(); - lockPrepareImage(); - lockUpdateImage(); - - while (layerStack.getSize() > 0) - { - //int index = layerStack.getSize() - 1; - layerStack.removeTopLayer(); - } - - repaintImageInLayerProcessor(); - - unlockUpdateImage(); - unlockPrepareImage(); - unlockHistogram(); -} - -void deLayerProcessor::addLayer(deLayer* layer) -{ -// lock(); - - logMessage("add layer " + str(layer->getIndex()) + " " + layer->getName()); - - layerStack.addLayer(layer); - - int index = layer->getIndex(); - markUpdateAllChannels(index); - -// unlock(); -} - -void deLayerProcessor::checkUpdateImagesRequest() -{ - lockLayers(); - - bool ok = true; - - if (firstLayerToUpdate > getLastLayerToUpdate()) - { - ok = false; - } - - if (ok) - { - workerSemaphore.Post(); - } - - unlockLayers(); -} - -int deLayerProcessor::getLastLayerToUpdate() -{ - if (!viewManager) - { - return 0; - } - else - { - int n = viewManager->getView(); - return n; - } -} - -bool deLayerProcessor::prepareImage() -{ - sendInfoEvent(DE_RENDERING_START); - - bool result = false; - lockPrepareImage(); - logMessage("prepare image start"); - lock(); - - if (!closing) - { - if (viewManager) - { - result = renderer.prepareImage(*viewManager, *this, layerStack); - } - } - - unlock(); - logMessage("prepare image end"); - unlockPrepareImage(); - - sendInfoEvent(DE_RENDERING_END); - - return result; -} - -void deLayerProcessor::onGenerateHistogram() -{ - sendInfoEvent(DE_HISTOGRAM_START); - - lockHistogram(); - - if (!closing) - { - if (mainFrame) - { - mainFrame->generateHistogram(); - } - } - - unlockHistogram(); - - sendInfoEvent(DE_HISTOGRAM_END); -} - -void deLayerProcessor::setPreviewSize(const deSize& size) -{ - deSize oldSize = previewChannelManager.getChannelSize(); - if (oldSize == size) - { - return; - } - - logMessage("set preview size..."); - lockHistogram(); - lockPrepareImage(); - lockUpdateImage(); - - previewChannelManager.setChannelSize(size); - - updateAllImages(false); - - unlockUpdateImage(); - unlockPrepareImage(); - unlockHistogram(); - logMessage("set preview size done"); -} - -void deLayerProcessor::onImageLoad() -{ - logMessage("on image load..."); - lockHistogram(); - lockPrepareImage(); - lockUpdateImage(); - - updateAllImages(false); - - unlockUpdateImage(); - unlockPrepareImage(); - unlockHistogram(); - logMessage("on image load done..."); -} - -void deLayerProcessor::render(wxDC& dc) -{ - renderer.render(dc); -} - -bool deLayerProcessor::isRealtime() const -{ - return realtime; -} - -void deLayerProcessor::setRealtime(bool r) -{ - realtime = r; -} diff -Nru delaboratory-0.7/src/layer_processor.h delaboratory-0.8/src/layer_processor.h --- delaboratory-0.7/src/layer_processor.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_processor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_PROCESSOR_H -#define _DE_LAYER_PROCESSOR_H - -class deMainFrame; -class deLayerStack; -class deViewManager; -class deChannelManager; -class wxProgressDialog; -class deMemoryInfoFrame; -class deLayer; -class deLogger; -class deLayerFrameManager; -#include -#include -#include "layer.h" -#include "size.h" -#include "renderer.h" - -enum -{ - DE_PROCESSING_START, - DE_PROCESSING_END, - DE_RENDERING_START, - DE_RENDERING_END, - DE_HISTOGRAM_START, - DE_HISTOGRAM_END, - DE_DCRAW_START, - DE_DCRAW_END, - DE_DEBUG_START, - DE_DEBUG_END -}; - -class deLayerProcessor -{ - private: - deMainFrame* mainFrame; - deLayerStack& layerStack; - deViewManager* viewManager; - wxThread* workerThread; - wxThread* renderWorkerThread; - wxThread* histogramWorkerThread; - deLayerFrameManager& layerFrameManager; - wxSemaphore workerSemaphore; - wxSemaphore renderWorkerSemaphore; - wxSemaphore histogramWorkerSemaphore; - wxMutex layerProcessMutex; - wxMutex histogramMutex; - wxMutex prepareImageMutex; - wxMutex updateImageMutex; - wxMutex updateImagesMutex; - deRenderer renderer; - deChannelManager& previewChannelManager; - - bool realtime; - - bool closing; - - deLayerProcessType layerProcessType; - int layerProcessChannel; - - int firstLayerToUpdate; - - int lastValidLayer; - - void updateImages(int a, int channel, bool action); - bool updateImage(); - - void repaintImageInLayerProcessor(); - - deLayerProcessor(const deLayerProcessor&); - deLayerProcessor& operator = (const deLayerProcessor&); - - void checkUpdateImagesRequest(); - - int getLastLayerToUpdate(); - - void lockLayers(); - void unlockLayers(); - - void lockHistogram(); - void unlockHistogram(); - - void lockPrepareImage(); - void unlockPrepareImage(); - - void lockUpdateImage(); - void unlockUpdateImage(); - - - - public: - deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager); - virtual ~deLayerProcessor(); - - int getLastValidLayer() const {return lastValidLayer;}; - - void setMainFrame(deMainFrame* _mainFrame); - void setViewManager(deViewManager* _viewManager); - - void updateAllImages(bool calcHistogram); - bool updateImagesSmart(int view, wxProgressDialog* progressDialog, deMemoryInfoFrame* memoryInfoFrame); - void generateChannelUsage(std::map& channelUsage); - - void markUpdateSingleChannel(int index, int channel); - void markUpdateAllChannels(int index); - - void markUpdateBlendAllChannels(int index); - - void onChangeView(int a); - - void lock(); - void unlock(); - - void startWorkerThread(); - - void tickWork(); - - void onDestroyAll(); - - void onChangeViewMode(); - - void onGUIUpdate(); - - void removeTopLayer(); - void addLayer(deLayer* layer); - - void stopWorkerThread(); - - void sendRepaintEvent(); - - bool prepareImage(); - - void generateHistogram(); - void onGenerateHistogram(); - void sendHistogramEvent(); - - void setPreviewSize(const deSize& size); - void onImageLoad(); - - bool isClosing() const {return closing;}; - - void render(wxDC& dc); - - bool isRealtime() const; - void setRealtime(bool r); - - void removeAllLayers(); - - void sendInfoEvent(int i); - -}; - -#endif diff -Nru delaboratory-0.7/src/layer_stack.cc delaboratory-0.8/src/layer_stack.cc --- delaboratory-0.7/src/layer_stack.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_stack.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "layer_stack.h" -#include "layer.h" -#include "channel_manager.h" -#include "str.h" -#include "memory_info_frame.h" -#include "project.h" - -deLayerStack::deLayerStack() -:mutex(wxMUTEX_RECURSIVE) -{ -} - -deLayerStack::~deLayerStack() -{ - clear(); -} - -void deLayerStack::lock() const -{ - lockWithLog(mutex, "layer stack mutex"); -} - -void deLayerStack::unlock() const -{ - logMessage("layer stack unlock"); - mutex.Unlock(); -} - -void deLayerStack::clear() -{ - while (layers.size() > 0) - { - removeTopLayer(); - } -} - -void deLayerStack::removeTopLayer() -{ - logMessage("layer stack remove top layer..."); - lock(); - - std::vector::iterator i; - i = layers.end(); - i--; - deLayer* layer = *i; - - layers.erase(i); - unlock(); - - layer->lockLayer(); - logMessage("layer stack before delete layer"); - delete layer; - logMessage("layer stack after delete layer"); -// layer->unlock(); - -} - -void deLayerStack::addLayer(deLayer* layer) -{ - logMessage("layer stack add layer"); - lock(); - - layers.push_back(layer); - - unlock(); -} - -int deLayerStack::getSize() const -{ - lock(); - int n = layers.size(); - unlock(); - return n; -} - -deLayer* deLayerStack::getLayer(int id) const -{ - lock(); - unsigned int i = id; - if ((i >= layers.size()) || (id < 0)) - { - unlock(); - return 0; - } - unlock(); - return layers[i]; -} - -void deLayerStack::save(xmlNodePtr node) -{ - std::vector::iterator i; - for (i = layers.begin(); i != layers.end(); i++) - { - xmlNodePtr child = xmlNewChild(node, NULL, BAD_CAST("layer"), NULL); - (*i)->save(child); - } -} diff -Nru delaboratory-0.7/src/layer_stack.h delaboratory-0.8/src/layer_stack.h --- delaboratory-0.7/src/layer_stack.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/layer_stack.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LAYER_STACK_H -#define _DE_LAYER_STACK_H - -#include -#include -#include -#include - -class deLayer; -class deChannelManager; -class deMemoryInfoFrame; - -class deLayerStack -{ - private: - std::vector layers; - mutable wxMutex mutex; - - deLayerStack(const deLayerStack& ); - deLayerStack& operator = (const deLayerStack& ); - - public: - deLayerStack(); - virtual ~deLayerStack(); - - void lock() const; - void unlock() const; - - void clear(); - void removeTopLayer(); - - void addLayer(deLayer* layer); - - int getSize() const; - deLayer* getLayer(int id) const; - - void save(xmlNodePtr node); - -}; - -#endif diff -Nru delaboratory-0.7/src/logger.cc delaboratory-0.8/src/logger.cc --- delaboratory-0.7/src/logger.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/logger.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "logger.h" -#include "str.h" -#include - -#define LOCK_THRESHOLD 100 - -deLogger& deLogger::getLogger() -{ - static deLogger logger; - return logger; -} - -deLogger::deLogger() -{ - f = NULL; - fl = NULL; - started = false; -} - -deLogger::~deLogger() -{ - mutex.Lock(); - - if (f) - { - f->close(); - } - - if (fl) - { - fl->close(); - } - - mutex.Unlock(); -} - -void deLogger::setFile(const std::string& fileName) -{ -#ifdef LOGGING - mutex.Lock(); - - if (f) - { - f->close(); - } - - f = new std::ofstream(fileName.c_str()); - - mutex.Unlock(); -#endif -} - -void deLogger::setLocksFile(const std::string& fileName) -{ -#ifdef LOGGING - mutex.Lock(); - - if (fl) - { - fl->close(); - } - - fl = new std::ofstream(fileName.c_str()); - - mutex.Unlock(); -#endif -} - -std::string deLogger::getThreadName() -{ - if (!started) - { - main_id = wxThread::GetCurrentId(); - started = true; - } - - wxThreadIdType c_id = wxThread::GetCurrentId(); - - std::string thr = "main"; - - if (main_id != c_id) - { - std::ostringstream oss; - oss.str(""); - oss << c_id; - thr = oss.str(); - } - - return thr; -} - -void deLogger::log(const std::string& message) -{ - mutex.Lock(); - - if (f) - { - int t = sw.Time(); - - (*f) << t << ": [" << getThreadName() << "] " << message << std::endl; - } - - mutex.Unlock(); -} - -void deLogger::logLock(const std::string& message, int dt) -{ - if (dt < LOCK_THRESHOLD) - { - return; - } - - mutex.Lock(); - - if (f) - { - int t = sw.Time(); - - (*fl) << t << ": [" << getThreadName() << "] [" << dt << "ms] " << message << std::endl; - } - - mutex.Unlock(); -} - -int deLogger::getTime() const -{ - int t = sw.Time(); - return t; -} - -void logMessage(const std::string& message) -{ -#ifdef LOGGING - deLogger::getLogger().log(message); -#endif -} - -void logError(const std::string& message) -{ - static wxMutex mutex; - mutex.Lock(); - std::cout << message << std::endl; - mutex.Unlock(); -#ifdef LOGGING - deLogger::getLogger().log(message); -#endif -} - -void lockWithLog(wxMutex& mutex, const std::string& message) -{ -#ifdef LOGGING - deLogger& logger = deLogger::getLogger(); - int t1 = logger.getTime(); - logger.log(message + " lock"); - mutex.Lock(); - int t2 = logger.getTime(); - logger.logLock(message, t2-t1); -#else - mutex.Lock(); -#endif -} diff -Nru delaboratory-0.7/src/logger.h delaboratory-0.8/src/logger.h --- delaboratory-0.7/src/logger.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/logger.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_LOGGER_H -#define _DE_LOGGER_H - -#include -#include -#include - -class deLogger -{ - private: - std::ofstream* f; - std::ofstream* fl; - wxStopWatch sw; - wxMutex mutex; - wxThreadIdType main_id; - bool started; - - std::string getThreadName(); - - deLogger(); - - public: - static deLogger& getLogger(); - virtual ~deLogger(); - - void setFile(const std::string& fileName); - void setLocksFile(const std::string& fileName); - - void log(const std::string& message); - void logLock(const std::string& message, int t); - - int getTime() const; -}; - -void logError(const std::string& message); -void logMessage(const std::string& message); -void lockWithLog(wxMutex& mutex, const std::string& message); - -#endif diff -Nru delaboratory-0.7/src/main_frame.cc delaboratory-0.8/src/main_frame.cc --- delaboratory-0.7/src/main_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/main_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,605 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "main_frame.h" -#include "layer_grid_panel.h" -#include "control_panel.h" -#include "image_area_panel.h" -#include "histogram_panel.h" -#include "view_mode_panel.h" -#include "histogram_mode_panel.h" -#include "help_color_spaces_frame.h" -#include "help_color_spaces_frame2.h" -#include "help_color_spaces_frame3.h" -#include "help_color_spaces_frame4.h" -#include "help_color_spaces_frame5.h" -#include "help_color_spaces_frame6.h" -#include "benchmark_frame.h" -#include "color_matrix_frame.h" -#include "project.h" -#include "str.h" -#include "file_dialogs.h" -#include "delaboratory.h" -#include "samplers_panel.h" -#include "layer_processor.h" -#include "zoom_panel.h" -#include "threads_panel.h" - -#include "image_panel.h" - -#include "wx/thread.h" -#include "wx/notebook.h" - - -BEGIN_EVENT_TABLE(deMainFrame, wxFrame) -EVT_MENU(ID_Quit, deMainFrame::onQuit) -EVT_MENU(ID_NewProject, deMainFrame::onNewProject) -EVT_MENU(ID_TestImageSmall, deMainFrame::onTestImageSmall) -EVT_MENU(ID_TestImageBig, deMainFrame::onTestImageBig) -EVT_MENU(ID_OpenImage, deMainFrame::onOpenImage) -EVT_MENU(ID_OpenRawImageLAB, deMainFrame::onOpenRawImageLAB) -EVT_MENU(ID_OpenRawImageProPhoto, deMainFrame::onOpenRawImageProPhoto) -EVT_MENU(ID_OpenProject, deMainFrame::onOpenProject) -EVT_MENU(ID_SaveProject, deMainFrame::onSaveProject) -EVT_MENU(ID_OpenLayerStack, deMainFrame::onOpenLayerStack) -EVT_MENU(ID_SaveLayerStack, deMainFrame::onSaveLayerStack) -EVT_MENU(ID_HelpColorSpaces, deMainFrame::onHelpColorSpaces) -EVT_MENU(ID_HelpColorSpaces2, deMainFrame::onHelpColorSpaces2) -EVT_MENU(ID_HelpColorSpaces3, deMainFrame::onHelpColorSpaces3) -EVT_MENU(ID_HelpColorSpaces4, deMainFrame::onHelpColorSpaces4) -EVT_MENU(ID_HelpColorSpaces5, deMainFrame::onHelpColorSpaces5) -EVT_MENU(ID_LABColors1, deMainFrame::onLABColors1) -EVT_MENU(ID_LABColors2, deMainFrame::onLABColors2) -EVT_MENU(ID_LABColors5, deMainFrame::onLABColors5) -EVT_MENU(ID_MemoryInfo, deMainFrame::onMemoryInfo) -EVT_MENU(ID_ColorMatrix1, deMainFrame::onColorMatrix1) -EVT_MENU(ID_ColorMatrix2, deMainFrame::onColorMatrix2) -EVT_MENU(ID_ColorMatrix3, deMainFrame::onColorMatrix3) -EVT_MENU(ID_ColorMatrix4, deMainFrame::onColorMatrix4) -EVT_MENU(ID_ColorMatrix5, deMainFrame::onColorMatrix5) -EVT_MENU(ID_BenchmarkBlur, deMainFrame::onBenchmarkBlur) -EVT_MENU(ID_BenchmarkColor, deMainFrame::onBenchmarkColor) -EVT_MENU(DE_REPAINT_EVENT, deMainFrame::onRepaintEvent) -EVT_MENU(DE_IMAGE_LOAD_EVENT, deMainFrame::onImageLoadEvent) -EVT_MENU(DE_HISTOGRAM_EVENT, deMainFrame::onHistogramEvent) -EVT_MENU(DE_RANDOM_EVENT, deMainFrame::onRandomEvent) -EVT_MENU(DE_INFO_EVENT, deMainFrame::onInfoEvent) -END_EVENT_TABLE() - -deMainFrame::deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcraw_version) -: wxFrame() , project(_project), layerProcessor(_layerProcessor), imageSize(0,0) -{ - project.setMainFrame(this); - - project.log("creating main frame"); - - imageName = ""; - -#ifdef __WXOSX_MAC__ - Create((wxFrame *)NULL, wxID_ANY, _T("main frame"), wxDefaultPosition, wxSize(1440, 800), wxDEFAULT_FRAME_STYLE); -#else - Create((wxFrame *)NULL, wxID_ANY, _T("main frame"), wxDefaultPosition, size, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE); -#endif - - updateTitle(); - - mainSizer = new wxBoxSizer(wxHORIZONTAL); - - wxSizer* leftSizer = new wxBoxSizer(wxVERTICAL); - mainSizer->Add(leftSizer, 1, wxEXPAND); - - topPanel = new wxPanel(this); - leftSizer->Add(topPanel, 0, wxEXPAND); - - wxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL); - topPanel->SetSizer(topSizer); - - wxPanel* viewModePanel = new deViewModePanel(topPanel, project); - topSizer->Add(viewModePanel); - - threadsPanel = new deThreadsPanel(topPanel); - topSizer->Add(threadsPanel, 0, wxEXPAND); - - wxSizer* sizerR = new wxStaticBoxSizer(wxHORIZONTAL, topPanel, _T("options")); - topSizer->Add(sizerR, 0, wxEXPAND); - - realtime = new wxCheckBox(topPanel, wxID_ANY, _T("real time")); - sizerR->Add(realtime); - - autoUI = new wxCheckBox(topPanel, wxID_ANY, _T("auto UI")); - sizerR->Add(autoUI); - - bool r = layerProcessor.isRealtime(); - if (r) - { - realtime->SetValue(1); - } - else - { - realtime->SetValue(0); - } - - deZoomPanel* zoomPanel = new deZoomPanel(topPanel, _zoomManager); - topSizer->Add(zoomPanel); - - wxSizer* sizerI = new wxStaticBoxSizer(wxVERTICAL, this, _T("image")); - leftSizer->Add(sizerI, 1, wxEXPAND); - - imageAreaPanel = new deImageAreaPanel(this, project, _samplerManager, _zoomManager, zoomPanel); - sizerI->Add(imageAreaPanel, 1, wxEXPAND); - - wxSizer* rightSizer = new wxBoxSizer(wxVERTICAL); - hPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(280, 250)); - wxSizer* sizerH = new wxStaticBoxSizer(wxVERTICAL, hPanel, _T("histogram")); - hPanel->SetSizer(sizerH); - - histogramPanel = new deHistogramPanel(hPanel, &project); - sizerH->Add(histogramPanel, 0, wxCENTER); - - deHistogramModePanel* histogramModePanel = new deHistogramModePanel(hPanel, project, histogramPanel); - sizerH->Add(histogramModePanel, 0, wxLEFT); - - rightSizer->Add(hPanel, 0, wxEXPAND); - - wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); - rightSizer->Add(notebook, 1, wxEXPAND); - - layerGridPanel = new deLayerGridPanel(notebook, project, _layerProcessor); - - notebook->AddPage(layerGridPanel, _T("layers")); - samplersPanel = new deSamplersPanel(notebook, project, _samplerManager); - notebook->AddPage(samplersPanel, _T("samplers")); - - controlPanel = new deControlPanel(this, project, _layerProcessor, layerGridPanel); - rightSizer->Add(controlPanel, 0, wxEXPAND); - - bool a = controlPanel->getAutoUI(); - if (a) - { - autoUI->SetValue(1); - } - else - { - autoUI->SetValue(0); - } - - mainSizer->Add(rightSizer, 0, wxEXPAND); - - SetSizer(mainSizer); - - full = false; - - wxMenu *menuFile = new wxMenu; - menuFile->Append( ID_NewProject, _("New project") ); - menuFile->AppendSeparator(); - menuFile->Append( ID_OpenRawImageLAB, _("Open RAW image as LAB") ); - menuFile->Append( ID_OpenRawImageProPhoto, _("Open RAW image as ProPhoto RGB") ); - menuFile->Append( ID_OpenImage, _("Open TIFF/JPG image") ); - menuFile->AppendSeparator(); - menuFile->Append( ID_TestImageSmall, _("Generate test image (small)") ); - menuFile->Append( ID_TestImageBig, _("Generate test image (big, slow)") ); - menuFile->AppendSeparator(); - menuFile->Append( ID_OpenLayerStack, _("Open layer stack") ); - menuFile->Append( ID_SaveLayerStack, _("Save layer stack") ); - menuFile->AppendSeparator(); - menuFile->Append( ID_OpenProject, _("Open project ( stack + image )") ); - menuFile->Append( ID_SaveProject, _("Save project ( stack + image )") ); - menuFile->AppendSeparator(); - menuFile->Append( ID_Quit, _("E&xit") ); - - wxMenu *menuHelp = new wxMenu; - menuHelp->Append( ID_HelpColorSpaces, _("channels") ); - menuHelp->Append( ID_HelpColorSpaces2, _("mix of channels") ); - menuHelp->Append( ID_HelpColorSpaces3, _("lightness/value in LAB/LCH/HSL/HSV") ); - menuHelp->Append( ID_HelpColorSpaces4, _("hue in LCH/HSL/HSV") ); - menuHelp->Append( ID_HelpColorSpaces5, _("CMYK skin colors") ); - menuHelp->Append( ID_LABColors1, _("LAB colors 1") ); - menuHelp->Append( ID_LABColors2, _("LAB colors 2") ); - menuHelp->Append( ID_LABColors5, _("LAB colors 5") ); - - wxMenu *menuInfo = new wxMenu; - menuInfo->Append( ID_MemoryInfo, _("memory info") ); - menuInfo->AppendSeparator(); - menuInfo->Append( ID_BenchmarkColor, _("benchmark color conversion") ); - menuInfo->Append( ID_BenchmarkBlur, _("benchmark blur (slow!)") ); - - wxMenu *menuPalette = new wxMenu; - menuPalette->Append( ID_ColorMatrix1, _("LAB color matrix 40x40") ); - menuPalette->Append( ID_ColorMatrix2, _("LAB color matrix 20x20") ); - menuPalette->Append( ID_ColorMatrix3, _("color tiles 20") ); - menuPalette->Append( ID_ColorMatrix4, _("color tiles 40") ); - menuPalette->Append( ID_ColorMatrix5, _("color tiles 80") ); - - wxMenuBar *menuBar = new wxMenuBar; - menuBar->Append( menuFile, _("&File") ); - menuBar->Append( menuInfo, _("&Info") ); - menuBar->Append( menuPalette, _("&Palette") ); - menuBar->Append( menuHelp, _("&Channels") ); - - SetMenuBar( menuBar ); - - Layout(); - - imageAreaPanel->SetFocus(); - Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deMainFrame::check)); - - Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(deMainFrame::onCloseEvent)); - - Connect(wxEVT_TIMER, wxTimerEventHandler(deMainFrame::onTimerEvent)); - - project.log("main frame created"); - - threadsPanel->setInfoColor(DE_DCRAW_END); -} - -#define TILE1 20 -#define TILE2 40 -#define TILE3 60 -#define TILER1 30 -#define TILER2 50 -#define TILER3 80 -#define PALRW 60 -#define PALRH 40 -#define PAL1 16 -#define PAL2 12 -#define PAL3 10 -#define MAR1 0.03 -#define MAR2 0.06 - - -void deMainFrame::hidePanels() -{ - topPanel->Hide(); - hPanel->Hide(); - layerGridPanel->Hide(); - controlPanel->Hide(); - mainSizer->Layout(); - full = true; - imageAreaPanel->SetFocus(); -} - -deMainFrame::~deMainFrame() -{ - project.log("closing main frame"); - layerProcessor.stopWorkerThread(); - project.log("closing main frame lock layerProcessor..."); - layerProcessor.lock(); - project.log("closing main frame unlock layerProcessor..."); - layerProcessor.unlock(); - project.log("closing main frame done"); -} - -void deMainFrame::showPanels() -{ - topPanel->Show(); - hPanel->Show(); - layerGridPanel->Show(); - controlPanel->Show(); - mainSizer->Layout(); - full = false; - imageAreaPanel->SetFocus(); -} - -void deMainFrame::rebuild() -{ - topPanel->Layout(); - topPanel->Update(); - topPanel->Refresh(); -} - -void deMainFrame::onKey(int key) -{ - if (key == 'F') - { - if (full) - { - showPanels(); - } - else - { - hidePanels(); - } - } -} - -void deMainFrame::onQuit(wxCommandEvent& WXUNUSED(event)) -{ - Close(TRUE); -} - -void deMainFrame::onSaveProject(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getSaveFile(this, "save project", "delab"); - project.save(fileName, true); -} - -void deMainFrame::onSaveLayerStack(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getSaveFile(this, "save layer stack", "delab"); - project.save(fileName, false); -} - -void deMainFrame::onOpenProject(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getOpenFile(this, "open project", "delab"); - project.open(fileName, true); -} - -void deMainFrame::onOpenLayerStack(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getOpenFile(this, "open layer stack", "delab"); - project.open(fileName, false); -} - -void deMainFrame::onNewProject(wxCommandEvent& WXUNUSED(event)) -{ - project.newProject(); -} - -void deMainFrame::onTestImageSmall(wxCommandEvent& WXUNUSED(event)) -{ - project.setTestImage(900); -} - -void deMainFrame::onTestImageBig(wxCommandEvent& WXUNUSED(event)) -{ - project.setTestImage(1800); -} - -void deMainFrame::onOpenImage(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getOpenFile(this, "load source image", "image"); - project.openImage(fileName, false, deColorSpaceRGB); -} - -void deMainFrame::onOpenRawImageLAB(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getOpenFile(this, "load source image", "raw"); - project.openImage(fileName, true, deColorSpaceLAB); -} - -void deMainFrame::onOpenRawImageProPhoto(wxCommandEvent& WXUNUSED(event)) -{ - std::string fileName = getOpenFile(this, "load source image", "raw"); - project.openImage(fileName, true, deColorSpaceProPhoto); -} - -void deMainFrame::onHelpColorSpaces(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame(this); - help->Show(); -} - -void deMainFrame::onHelpColorSpaces2(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame2(this); - help->Show(); -} - -void deMainFrame::onHelpColorSpaces3(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame3(this); - help->Show(); -} - -void deMainFrame::onHelpColorSpaces4(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame4(this); - help->Show(); -} - -void deMainFrame::onHelpColorSpaces5(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame5(this); - help->Show(); -} - -void deMainFrame::onLABColors1(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame6(this, 1); - help->Show(); -} - -void deMainFrame::onLABColors2(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame6(this, 2); - help->Show(); -} - -void deMainFrame::onLABColors5(wxCommandEvent& event) -{ - wxFrame* help = new deHelpColorSpacesFrame6(this, 5); - help->Show(); -} - -void deMainFrame::onMemoryInfo(wxCommandEvent& event) -{ - project.openMemoryInfoFrame(this); -} - -void deMainFrame::onColorMatrix1(wxCommandEvent& event) -{ - dePalette3* palette = NULL; - wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 32, 32, palette); - help->Show(); -} - -void deMainFrame::onColorMatrix2(wxCommandEvent& event) -{ - dePalette3* palette = NULL; - wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 16, 16, palette); - help->Show(); -} - -void deMainFrame::onColorMatrix3(wxCommandEvent& event) -{ - wxFrame* help = new deColorMatrixFrame(this, project, 20, 20, 20, 20, 40, 40, 12, 0.1); - help->Show(); -} - -void deMainFrame::onColorMatrix4(wxCommandEvent& event) -{ - wxFrame* help = new deColorMatrixFrame(this, project, 40, 40, 40, 40, 40, 40, 12, 0.1); - help->Show(); -} - -void deMainFrame::onColorMatrix5(wxCommandEvent& event) -{ - wxFrame* help = new deColorMatrixFrame(this, project, 80, 80, 80, 80, 40, 40, 12, 0.1); - help->Show(); -} - - -void deMainFrame::onBenchmarkBlur(wxCommandEvent& event) -{ - deBenchmarkFrame* help = new deBenchmarkFrame(this, "blur"); - help->Show(); - help->perform(); -} - -void deMainFrame::onBenchmarkColor(wxCommandEvent& event) -{ - deBenchmarkFrame* help = new deBenchmarkFrame(this, "color"); - help->Show(); - help->perform(); -} - -void deMainFrame::onRepaintEvent(wxCommandEvent& event) -{ - repaintMainFrame(true); -} - -void deMainFrame::onImageLoadEvent(wxCommandEvent& event) -{ - layerProcessor.onImageLoad(); -} - -void deMainFrame::onRandomEvent(wxCommandEvent& event) -{ - project.log("random event start"); - project.addRandomLayer(); - project.log("random event end"); -} - -void deMainFrame::onInfoEvent(wxCommandEvent& event) -{ - int i = event.GetInt(); - threadsPanel->setInfoColor(i); -} - -class deTestThread:public wxThread -{ - private: - virtual void *Entry() - { - int i; - int max = 999999; - for (i = 0; i < max; i++) - { - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, DE_RANDOM_EVENT ); - wxPostEvent( frame, event ); - wxThread::Sleep(100 + rand() % 1000); - if (TestDestroy()) - { - i = max; - } - } - return NULL; - } - deMainFrame* frame; - deProject& project; - public: - deTestThread(deMainFrame* _frame, deProject& _project) - :frame(_frame), project(_project) - { - } - virtual ~deTestThread() - { - } -}; - -void deMainFrame::repaintMainFrame(bool calcHistogram) -{ - project.log("repaint main frame start"); - if (!project.isSourceValid()) - { - std::cout << "source not valid" << std::endl; - return; - } - - project.log("repaint main frame 1"); - imageAreaPanel->getImagePanel()->repaintImagePanel(); - project.log("repaint main frame 2"); - project.log("repaint main frame 3"); - samplersPanel->update(); - project.log("repaint main frame 4"); - project.updateMemoryInfo(); - project.log("repaint main frame end"); - -} - -void deMainFrame::check(wxCommandEvent &event) -{ - bool r = realtime->IsChecked(); - layerProcessor.setRealtime(r); - - bool aui = autoUI->IsChecked(); - controlPanel->setAutoUI(aui); -} - -void deMainFrame::onCloseEvent(wxCloseEvent& event) -{ - project.log("deMainFrame::onCloseEvent"); - this->Destroy(); -} - -void deMainFrame::generateHistogram() -{ - if (histogramPanel) - { - histogramPanel->generateHistogram(); - } -} - -void deMainFrame::onHistogramEvent(wxCommandEvent& event) -{ - if (histogramPanel) - { - histogramPanel->paintHistogram(); - } -} - -void deMainFrame::updateTitle() -{ - std::string s = imageName + " " + str(imageSize.getW()) + "x" + str(imageSize.getH()) + " - " + getApplicationName() + " " + getVersion() + " " + getCopyright(); - - SetTitle(wxString::FromAscii(s.c_str())); -} - -void deMainFrame::setImageName(const std::string& _imageName, const deSize& _size) -{ - imageName = _imageName; - imageSize = _size; - updateTitle(); -} - -void deMainFrame::onTimerEvent(wxTimerEvent& event) -{ - project.onTimerUpdate(); -} - diff -Nru delaboratory-0.7/src/main_frame.h delaboratory-0.8/src/main_frame.h --- delaboratory-0.7/src/main_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/main_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MAIN_FRAME_H -#define _DE_MAIN_FRAME_H - -#include "wx/wx.h" -class deProject; -class deImageAreaPanel; -class deLayerGridPanel; -class deControlPanel; -class deHistogramPanel; -class deLayerProcessor; -class deSamplersPanel; -class deSamplerManager; -class deZoomManager; -class deThreadsPanel; -#include "size.h" - -enum -{ - ID_Quit = 1, - ID_NewProject, - ID_TestImageSmall, - ID_TestImageBig, - ID_OpenImage, - ID_OpenRawImageLAB, - ID_OpenRawImageProPhoto, - ID_OpenProject, - ID_SaveProject, - ID_OpenLayerStack, - ID_SaveLayerStack, - ID_HelpColorSpaces, - ID_HelpColorSpaces2, - ID_HelpColorSpaces3, - ID_HelpColorSpaces4, - ID_HelpColorSpaces5, - ID_LABColors1, - ID_LABColors2, - ID_LABColors5, - ID_MemoryInfo, - ID_ColorMatrix1, - ID_ColorMatrix2, - ID_ColorMatrix3, - ID_ColorMatrix4, - ID_ColorMatrix5, - ID_BenchmarkBlur, - ID_BenchmarkColor, - DE_REPAINT_EVENT, - DE_IMAGE_LOAD_EVENT, - DE_HISTOGRAM_EVENT, - DE_RANDOM_EVENT, - DE_INFO_EVENT - -}; - -class deMainFrame: public wxFrame -{ -private: - deProject& project; - wxPanel* hPanel; - wxPanel* topPanel; - deLayerGridPanel* layerGridPanel; - deSamplersPanel* samplersPanel; - deControlPanel* controlPanel; - wxSizer* mainSizer; - deImageAreaPanel* imageAreaPanel; - deHistogramPanel* histogramPanel; - deThreadsPanel* threadsPanel; - - wxCheckBox* realtime; - wxCheckBox* autoUI; - - std::string imageName; - - deLayerProcessor& layerProcessor; - - deSize imageSize; - - bool full; - - void onTestImageSmall(wxCommandEvent& event); - void onTestImageBig(wxCommandEvent& event); - void onOpenImage(wxCommandEvent& event); - void onOpenRawImageLAB(wxCommandEvent& event); - void onOpenRawImageProPhoto(wxCommandEvent& event); - void onQuit(wxCommandEvent& event); - void onNewProject(wxCommandEvent& event); - void onOpenProject(wxCommandEvent& event); - void onSaveProject(wxCommandEvent& event); - void onOpenLayerStack(wxCommandEvent& event); - void onSaveLayerStack(wxCommandEvent& event); - void onHelpColorSpaces(wxCommandEvent& event); - void onHelpColorSpaces2(wxCommandEvent& event); - void onHelpColorSpaces3(wxCommandEvent& event); - void onHelpColorSpaces4(wxCommandEvent& event); - void onHelpColorSpaces5(wxCommandEvent& event); - void onLABColors1(wxCommandEvent& event); - void onLABColors2(wxCommandEvent& event); - void onLABColors5(wxCommandEvent& event); - void onMemoryInfo(wxCommandEvent& event); - void onColorMatrix1(wxCommandEvent& event); - void onColorMatrix2(wxCommandEvent& event); - void onColorMatrix3(wxCommandEvent& event); - void onColorMatrix4(wxCommandEvent& event); - void onColorMatrix5(wxCommandEvent& event); - void onBenchmarkBlur(wxCommandEvent& event); - void onBenchmarkColor(wxCommandEvent& event); - void onRepaintEvent(wxCommandEvent& event); - void onImageLoadEvent(wxCommandEvent& event); - void onRandomEvent(wxCommandEvent& event); - void onInfoEvent(wxCommandEvent& event); - void onHistogramEvent(wxCommandEvent& event); - void onTimerEvent(wxTimerEvent& event); - - void onCloseEvent(wxCloseEvent& event); - - void repaintMainFrame(bool calcHistogram); - - void check(wxCommandEvent &event); - - void updateTitle(); - -public: - deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcrawVersion); - ~deMainFrame(); - - void showPanels(); - void hidePanels(); - void rebuild(); - - void onKey(int key); - - void generateHistogram(); - void paintHistogram(); - - void setImageName(const std::string& _imageName, const deSize& _size); - - - DECLARE_EVENT_TABLE() - -}; - - -#endif diff -Nru delaboratory-0.7/src/memory_info_frame.cc delaboratory-0.8/src/memory_info_frame.cc --- delaboratory-0.7/src/memory_info_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/memory_info_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "memory_info_frame.h" -#include "project.h" -#include -#include "str.h" -#include "channel_manager.h" - -int generateInfo(deChannelManager& channelManager, wxWindow* parent, wxSizer* sizer, wxString name) -{ - wxSizer* sizerB = new wxStaticBoxSizer(wxVERTICAL, parent, name); - sizer->Add(sizerB); - - int size = sizeof(deValue) * channelManager.getChannelSize().getN(); - int n = channelManager.getNumberOfAllocatedChannels(); - int m = n * size / (1024 * 1024); - - { - std::ostringstream oss; - oss << "channel size: " << size; - wxStaticText* l1 = new wxStaticText(parent, wxID_ANY, wxString::FromAscii(oss.str().c_str())); - sizerB->Add(l1); - } - { - std::ostringstream oss; - oss << "allocated channels: " << n; - wxStaticText* l1 = new wxStaticText(parent, wxID_ANY, wxString::FromAscii(oss.str().c_str())); - sizerB->Add(l1); - } - { - std::ostringstream oss; - oss << "memory usage: " << m << " MB"; - wxStaticText* l1 = new wxStaticText(parent, wxID_ANY, wxString::FromAscii(oss.str().c_str())); - sizerB->Add(l1); - } - - return m; -} - -void deMemoryInfoFrame::update() -{ - int m1; - { - deChannelManager& channelManager = project.getPreviewChannelManager(); - int size = sizeof(deValue) * channelManager.getChannelSize().getN(); - int n = channelManager.getNumberOfAllocatedChannels(); - m1 = n * size / (1024 * 1024); - - previewChannels->SetLabel(wxString::FromAscii(str(n).c_str())); - previewSize->SetLabel(wxString::FromAscii(str(size).c_str())); - std::string s = str(m1) + "MB"; - previewMemory->SetLabel(wxString::FromAscii(s.c_str())); - } - - Layout(); - Fit(); -} - -deMemoryInfoFrame::deMemoryInfoFrame(wxWindow *parent, deProject& _project) -:deHelpFrame(parent, "memory info"), project(_project) -{ - wxSizer* sizerB = new wxStaticBoxSizer(wxVERTICAL, this, _T("memory info")); - SetSizer(sizerB); - wxSizer* sizer = new wxFlexGridSizer(2); - sizerB->Add(sizer); - - { - wxStaticText* l = new wxStaticText(this, wxID_ANY, _T("allocated preview channels:")); - sizer->Add(l); - previewChannels = new wxStaticText(this, wxID_ANY, _T("")); - sizer->Add(previewChannels); - } - { - wxStaticText* l = new wxStaticText(this, wxID_ANY, _T("preview channel size:")); - sizer->Add(l); - previewSize = new wxStaticText(this, wxID_ANY, _T("")); - sizer->Add(previewSize); - } - { - wxStaticText* l = new wxStaticText(this, wxID_ANY, _T("memory used by preview channels:")); - sizer->Add(l); - previewMemory = new wxStaticText(this, wxID_ANY, _T("")); - sizer->Add(previewMemory); - } - - update(); - - -} - -deMemoryInfoFrame::~deMemoryInfoFrame() -{ - project.closeMemoryInfoFrame(); -} - diff -Nru delaboratory-0.7/src/memory_info_frame.h delaboratory-0.8/src/memory_info_frame.h --- delaboratory-0.7/src/memory_info_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/memory_info_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MEMORY_INFO_FRAME_H -#define _DE_MEMORY_INFO_FRAME_H - -#include "help_frame.h" -class deProject; - -class deMemoryInfoFrame:public deHelpFrame -{ - private: - deProject& project; - wxStaticText* previewChannels; - wxStaticText* previewSize; - wxStaticText* previewMemory; - public: - deMemoryInfoFrame(wxWindow *parent, deProject& _project); - virtual ~deMemoryInfoFrame(); - - void update(); -}; - -#endif diff -Nru delaboratory-0.7/src/mixer_bw_editor.cc delaboratory-0.8/src/mixer_bw_editor.cc --- delaboratory-0.7/src/mixer_bw_editor.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_bw_editor.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "mixer_bw_editor.h" -#include "conversion_bw_layer.h" -#include "property_value_slider.h" -#include "layer_processor.h" -#include "layer_frame_manager.h" - -deMixerBWEditor::deMixerBWEditor(wxWindow *parent, deConversionBWLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deLayerFrame(parent, _layer, "conversion BW", _frameManager), layer( _layer), layerProcessor(_layerProcessor) -{ - frameManager.addActionFrame(this); - - deColorSpace sourceColorSpace = layer.getSourceColorSpace(); - int cs = getColorSpaceSize(sourceColorSpace); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - int range = 300; - - wxSizer* sizerM = new wxStaticBoxSizer(wxVERTICAL, this, _T("monochrome mixer")); - sizer->Add(sizerM); - - add0 = new dePropertyValueSlider(this, range, layer.getAdd0(), layer, layerProcessor); - sizerM->Add(add0); - - add1 = new dePropertyValueSlider(this, range, layer.getAdd1(), layer, layerProcessor); - sizerM->Add(add1); - - add2 = new dePropertyValueSlider(this, range, layer.getAdd2(), layer, layerProcessor); - sizerM->Add(add2); - - if (cs == 4) - { - add3 = new dePropertyValueSlider(this, range, layer.getAdd3(), layer, layerProcessor); - sizerM->Add(add3); - } - - wxSizer* sizerBM = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizerM->Add(sizerBM); - - int w = 80; - - resetM = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(w,25)); - sizerBM->Add(resetM, 0); - - preset0M = new wxButton(this, wxID_ANY, wxString::FromAscii(getChannelName(sourceColorSpace, 0).c_str()), wxDefaultPosition, wxSize(w,25)); - sizerBM->Add(preset0M, 0); - - preset1M = new wxButton(this, wxID_ANY, wxString::FromAscii(getChannelName(sourceColorSpace, 1).c_str()), wxDefaultPosition, wxSize(w,25)); - sizerBM->Add(preset1M, 0); - - preset2M = new wxButton(this, wxID_ANY, wxString::FromAscii(getChannelName(sourceColorSpace, 2).c_str()), wxDefaultPosition, wxSize(w,25)); - sizerBM->Add(preset2M, 0); - - wxSizer* sizerO = new wxStaticBoxSizer(wxVERTICAL, this, _T("overlay")); - sizer->Add(sizerO); - - overlay0 = new dePropertyValueSlider(this, range, layer.getOverlay0(), layer, layerProcessor); - sizerO->Add(overlay0); - - overlay1 = new dePropertyValueSlider(this, range, layer.getOverlay1(), layer, layerProcessor); - sizerO->Add(overlay1); - - overlay2 = new dePropertyValueSlider(this, range, layer.getOverlay2(), layer, layerProcessor); - sizerO->Add(overlay2); - - if (cs == 4) - { - overlay3 = new dePropertyValueSlider(this, range, layer.getOverlay3(), layer, layerProcessor); - sizerO->Add(overlay3); - } - - wxSizer* sizerBF = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerBF); - - wxSizer* sizerGF = new wxGridSizer(5); - sizerBF->Add(sizerGF); - - int w2 = 100; - - const std::vector& films = layer.getFilms(); - std::vector::const_iterator i; - for (i = films.begin(); i != films.end(); i++) - { - const deFilm& film = *i; - wxButton* b = new wxButton(this, wxID_ANY, wxString::FromAscii(film.getName().c_str()), wxDefaultPosition, wxSize(w2, 25)); - filmButtons.push_back(b); - sizerGF->Add(b, 0); - - } - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deMixerBWEditor::click)); - - Layout(); - Fit(); - -} - -deMixerBWEditor::~deMixerBWEditor() -{ - frameManager.removeActionFrame(this); -} - -void deMixerBWEditor::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - if (resetM->GetId() == id) - { - layer.resetM(); - } - - if (preset0M->GetId() == id) - { - layer.presetM(0); - } - - if (preset1M->GetId() == id) - { - layer.presetM(1); - } - - if (preset2M->GetId() == id) - { - layer.presetM(2); - } - - std::vector::iterator i; - int f = 0; - for (i = filmButtons.begin(); i != filmButtons.end(); i++) - { - if ((*i)->GetId() == id) - { - layer.applyFilm(f); - } - f++; - } - - add0->setFromProperty(); - add1->setFromProperty(); - add2->setFromProperty(); - - deColorSpace sourceColorSpace = layer.getSourceColorSpace(); - int cs = getColorSpaceSize(sourceColorSpace); - if (cs == 4) - { - add3->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); - -} diff -Nru delaboratory-0.7/src/mixer_bw_editor.h delaboratory-0.8/src/mixer_bw_editor.h --- delaboratory-0.7/src/mixer_bw_editor.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_bw_editor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MIXER_BW_EDITOR_H -#define _DE_MIXER_BW_EDITOR_H - -#include "layer_frame.h" -#include -class deConversionBWLayer; -class dePropertyValueSlider; -class deLayerProcessor; - -class deMixerBWEditor:public deLayerFrame -{ - private: - deConversionBWLayer& layer; - deLayerProcessor& layerProcessor; - - wxButton* resetM; - wxButton* preset0M; - wxButton* preset1M; - wxButton* preset2M; - - std::vector filmButtons; - - dePropertyValueSlider* add0; - dePropertyValueSlider* add1; - dePropertyValueSlider* add2; - dePropertyValueSlider* add3; - dePropertyValueSlider* overlay0; - dePropertyValueSlider* overlay1; - dePropertyValueSlider* overlay2; - dePropertyValueSlider* overlay3; - - void click(wxCommandEvent &event); - - public: - deMixerBWEditor(wxWindow *parent, deConversionBWLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deMixerBWEditor(); - -}; - - -#endif diff -Nru delaboratory-0.7/src/mixer.cc delaboratory-0.8/src/mixer.cc --- delaboratory-0.7/src/mixer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "mixer.h" -#include "channel.h" -#include "str.h" -#include "xml.h" -#include -#include -#include "logger.h" - -deMixer::deMixer(int _size) -:size(_size), - mutex(wxMUTEX_RECURSIVE) -{ - weights = new deValue [size]; -} - -deMixer::~deMixer() -{ - delete [] weights; -} - -void deMixer::reset(int index) -{ - lock(); - - int i; - for (i = 0; i < size; i++) - { - if (i == index) - { - weights[i] = 1.0; - } - else - { - weights[i] = 0.0; - } - } - - unlock(); -} - -deValue deMixer::getWeight(int c) const -{ - lock(); - - if ((c < 0) || (c >= size)) - { - unlock(); - return 0.0; - } - - unlock(); - return weights[c]; -} - -void deMixer::setWeight(int c, deValue value) -{ - if ((c < 0) || (c >= size)) - { - return; - } - - lock(); - - weights[c] = value; - - unlock(); -} - -void deMixer::process(const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& destination, int n) -{ - if (size < 1) - { - return; - } - - int i; - - if (!s1) - { - return; - } - - lock(); - - const deValue *p1 = s1->getPixels(); - if (size == 1) - { - for (i = 0; i < n; i++) - { - deValue result = weights[0] * p1[i]; - destination.setValueClip(i, result); - } - unlock(); - return; - } - - if (!s2) - { - unlock(); - return; - } - if (!s3) - { - unlock(); - return; - } - const deValue *p2 = s2->getPixels(); - const deValue *p3 = s3->getPixels(); - if (size == 3) - { - for (i = 0; i < n; i++) - { - deValue result = weights[0] * p1[i]; - result += weights[1] * p2[i]; - result += weights[2] * p3[i]; - destination.setValueClip(i, result); - } - unlock(); - return; - } - - if (!s4) - { - unlock(); - return; - } - const deValue *p4 = s4->getPixels(); - for (i = 0; i < n; i++) - { - deValue result = weights[0] * p1[i]; - result += weights[1] * p2[i]; - result += weights[2] * p3[i]; - result += weights[3] * p4[i]; - destination.setValueClip(i, result); - } - - unlock(); -} - -bool deMixer::isNeutral(int index) const -{ - int i; - for (i = 0; i < size; i++) - { - if (i == index) - { - if (weights[i] != 1.0) - { - return false; - } - } - else - { - if (weights[i] != 0.0) - { - return false; - } - } - } - return true; -} - -void deMixer::save(xmlNodePtr node) -{ - int i; - for (i = 0; i < size; i++) - { - saveChild(node, "weight", str(weights[i])); - } -} - -void deMixer::load(xmlNodePtr node) -{ - xmlNodePtr child = node->xmlChildrenNode; - - int i = 0; - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("weight")))) - { - assert(i < size); - weights[i] = getValue(getContent(child)); - i++; - } - - child = child->next; - } -} - -void deMixer::lock() const -{ - lockWithLog(mutex, "mixer mutex"); -} - -void deMixer::unlock() const -{ - mutex.Unlock(); -} diff -Nru delaboratory-0.7/src/mixer_editor.cc delaboratory-0.8/src/mixer_editor.cc --- delaboratory-0.7/src/mixer_editor.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_editor.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "mixer_editor.h" -#include "color_space.h" -#include "mixer_layer.h" -#include "mixer_editor_channel.h" -#include "layer_processor.h" -#include "str.h" - -deMixerEditor::deMixerEditor(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager) -{ - - deMixerLayer& mixerLayer = dynamic_cast(_layer); - - deColorSpace colorSpace = layer.getColorSpace(); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - int n = getColorSpaceSize(colorSpace); - - int i; - for (i = 0; i < n; i++) - { - deMixerEditorChannel* mixerEditorChannel = new deMixerEditorChannel(this, mixerLayer, i, _layerProcessor); - sizer->Add(mixerEditorChannel); - channels.push_back(mixerEditorChannel); - } - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition); - sizerB->Add(reset, 0); - random1 = new wxButton(this, wxID_ANY, _T("light random"), wxDefaultPosition); - sizerB->Add(random1, 0); - random2 = new wxButton(this, wxID_ANY, _T("medium random"), wxDefaultPosition); - sizerB->Add(random2, 0); - random3 = new wxButton(this, wxID_ANY, _T("heavy random"), wxDefaultPosition); - sizerB->Add(random3, 0); - - sizer->Layout(); - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deMixerEditor::click)); - -} - -deMixerEditor::~deMixerEditor() -{ -} - -void deMixerEditor::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - std::vector::iterator i; - - if (reset->GetId() == id) - { - for (i = channels.begin(); i != channels.end(); i++) - { - (*i)->preset(0); - } - } - - if (random1->GetId() == id) - { - for (i = channels.begin(); i != channels.end(); i++) - { - (*i)->random(0.15); - } - } - - if (random2->GetId() == id) - { - for (i = channels.begin(); i != channels.end(); i++) - { - (*i)->random(0.3); - } - } - - if (random3->GetId() == id) - { - for (i = channels.begin(); i != channels.end(); i++) - { - (*i)->random(0.45); - } - } -} diff -Nru delaboratory-0.7/src/mixer_editor_channel.cc delaboratory-0.8/src/mixer_editor_channel.cc --- delaboratory-0.7/src/mixer_editor_channel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_editor_channel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,248 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "mixer_editor_channel.h" -#include "mixer_layer.h" -#include "slider.h" -#include "gradient_panel.h" -#include "layer_processor.h" -#include "str.h" - -class deMixerSlider:public deSlider -{ - private: - deMixerLayer& layer; - int s; - int d; - deLayerProcessor& layerProcessor; - - public: - deMixerSlider(wxWindow *parent, int range, deMixerLayer& _layer, int _s, int _d, const std::string& name, deLayerProcessor& _layerProcessor) - :deSlider(parent, name, range, -2.0, 2.0, 0.0), layer(_layer), s(_s), d(_d), - layerProcessor(_layerProcessor) - { - setValue(layer.getWeight(s, d)); - } - - virtual ~deMixerSlider() - { - } - - virtual void onValueChange(deValue value, bool finished) - { - if ((finished) || (layerProcessor.isRealtime())) - { - layer.setWeight(s, d, value); - layer.setHistogramChannel(d); - - int index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(index, d); - } - } -}; - -deMixerEditorChannel::deMixerEditorChannel(wxWindow *parent, deMixerLayer& _layer, int _index, deLayerProcessor& _layerProcessor) -:wxPanel(parent), layer(_layer), index(_index), layerProcessor(_layerProcessor) -{ - deColorSpace colorSpace = layer.getColorSpace(); - unsigned int n = getColorSpaceSize(colorSpace); - - std::string name = getChannelName(colorSpace, index); - - wxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString::FromAscii(name.c_str())); - SetSizer(sizer); - - int barSize = 20; - int width = 300; - - deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), colorSpace, index, -1, -1, -1, -1); - sizer->Add(gradient, 0, wxCENTER); - - std::string src1; - std::string src2; - - unsigned int i; - int counter = 0; - for (i = 0; i < n; i++) - { - std::string src = getChannelName(colorSpace, i); - deMixerSlider* slider = new deMixerSlider(this, width, layer, i, index, src, layerProcessor); - sliders.push_back(slider); - sizer->Add(slider); - if (i != index) - { - counter++; - if (counter == 1) - { - src1 = src; - } - else - { - src2 = src; - } - } - } - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(reset, 0); - - app1 = new wxButton(this, wxID_ANY, wxString::FromAscii(src1.c_str()), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(app1, 0); - - app2 = new wxButton(this, wxID_ANY, wxString::FromAscii(src2.c_str()), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(app2, 0); - - mix1 = new wxButton(this, wxID_ANY, _T("0.1"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(mix1, 0); - - mix2 = new wxButton(this, wxID_ANY, _T("0.3"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(mix2, 0); - - mix3 = new wxButton(this, wxID_ANY, _T("-0.3"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(mix3, 0); - - mix4 = new wxButton(this, wxID_ANY, _T("-0.5"), wxDefaultPosition, wxSize(60,25)); - sizerB->Add(mix4, 0); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deMixerEditorChannel::click)); - - Layout(); - Fit(); - -} - -deMixerEditorChannel::~deMixerEditorChannel() -{ -} - -void deMixerEditorChannel::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - layer.setHistogramChannel(index); - - if (reset->GetId() == id) - { - preset(0); - } - - if (mix1->GetId() == id) - { - preset(0.1); - } - - if (mix2->GetId() == id) - { - preset(0.3); - } - - if (mix3->GetId() == id) - { - preset(-0.3); - } - - if (mix4->GetId() == id) - { - preset(-0.5); - } - - if (app1->GetId() == id) - { - preset2(1.0, 0, 0); - } - - if (app2->GetId() == id) - { - preset2(0, 1.0, 0); - } -} - -void deMixerEditorChannel::preset(deValue a) -{ - unsigned int i; - for (i = 0; i < sliders.size(); i++) - { - deValue v = a; - if (i == index) - { - v = 1.0 - 2 * a; - } - sliders[i]->setValue(v); - layer.setWeight(i, index, v); - } - - int l_index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(l_index, index); -} - -void deMixerEditorChannel::random(deValue a) -{ - unsigned int i; - for (i = 0; i < sliders.size(); i++) - { - deValue v = 0; - if (i == index) - { - v = 1.0; - } - - deValue r = (deValue) rand() / RAND_MAX; - - r *= 2.0; - r -= 1.0; - r *= a; - - v += r; - - sliders[i]->setValue(v); - layer.setWeight(i, index, v); - } - - int l_index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(l_index, index); -} - -void deMixerEditorChannel::preset2(deValue a, deValue b, deValue c) -{ - unsigned int i; - int counter = 0; - for (i = 0; i < sliders.size(); i++) - { - deValue v = c; - if (i != index) - { - counter++; - if (counter == 1) - { - v = a; - } - else - { - v = b; - } - } - sliders[i]->setValue(v); - layer.setWeight(i, index, v); - } - - int l_index = layer.getIndex(); - layerProcessor.markUpdateSingleChannel(l_index, index); -} diff -Nru delaboratory-0.7/src/mixer_editor_channel.h delaboratory-0.8/src/mixer_editor_channel.h --- delaboratory-0.7/src/mixer_editor_channel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_editor_channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MIXER_EDITOR_CHANNEL_H -#define _DE_MIXER_EDITOR_CHANNEL_H - -#include -class deMixerLayer; -#include "slider.h" -#include -class deLayerProcessor; - -class deMixerEditorChannel:public wxPanel -{ - private: - std::vector sliders; - deMixerLayer& layer; - unsigned int index; - - deLayerProcessor& layerProcessor; - - wxButton* reset; - wxButton* app1; - wxButton* app2; - wxButton* mix1; - wxButton* mix2; - wxButton* mix3; - wxButton* mix4; - - void click(wxCommandEvent &event); - void preset2(deValue a, deValue b, deValue c); - - public: - deMixerEditorChannel(wxWindow *parent, deMixerLayer& _layer, int _index, deLayerProcessor& _layerProcessor); - virtual ~deMixerEditorChannel(); - - void random(deValue a); - void preset(deValue a); - - - -}; - - -#endif diff -Nru delaboratory-0.7/src/mixer_editor.h delaboratory-0.8/src/mixer_editor.h --- delaboratory-0.7/src/mixer_editor.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_editor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MIXER_EDITOR_H -#define _DE_MIXER_EDITOR_H - -#include "action_frame.h" -class deMixerEditorChannel; -#include -class deLayerProcessor; - -class deMixerEditor:public deActionFrame -{ - private: - std::vector channels; - wxButton* reset; - wxButton* random1; - wxButton* random2; - wxButton* random3; - - void click(wxCommandEvent &event); - - public: - deMixerEditor(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deMixerEditor(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/mixer.h delaboratory-0.8/src/mixer.h --- delaboratory-0.7/src/mixer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MIXER_H -#define _DE_MIXER_H - -#include -#include "value.h" -#include -class deChannel; - -class deMixer -{ - private: - int size; - deValue* weights; - - mutable wxMutex mutex; - - deMixer(const deMixer& mixer); - deMixer operator=(const deMixer& mixer); - - void lock() const; - void unlock() const; - - public: - deMixer(int _size); - virtual ~deMixer(); - - deValue getWeight(int c) const; - void setWeight(int c, deValue value); - - void process(const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& destination, int n); - - bool isNeutral(int index) const; - - void reset(int index); - - void save(xmlNodePtr node); - void load(xmlNodePtr node); - -}; - -#endif diff -Nru delaboratory-0.7/src/mixer_layer.cc delaboratory-0.8/src/mixer_layer.cc --- delaboratory-0.7/src/mixer_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "mixer_layer.h" -#include "project.h" -#include -#include "frame_factory.h" - -deMixerLayer::deMixerLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - mixers.push_back( new deMixer(n)); - mixers[i]->reset(i); - } - -} - -deMixerLayer::~deMixerLayer() -{ - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - delete mixers[i]; - } -} - -bool deMixerLayer::processAction4(int i, const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& channel, int channelSize) -{ - logMessage("process mixer start"); - mixers[i]->process(s1, s2, s3, s4, channel, channelSize); - logMessage("process mixer end"); - - return true; -} - -deMixer* deMixerLayer::getMixer(int index) -{ - int n = getColorSpaceSize(colorSpace); - if ((index < 0) || (index >= n)) - { - return NULL; - } - return mixers[index]; -} - -bool deMixerLayer::isChannelNeutral(int index) -{ - return mixers[index]->isNeutral(index); -} - -void deMixerLayer::setWeight(int s, int d, deValue value) -{ - mixers[d]->setWeight(s, value); -} - -deValue deMixerLayer::getWeight(int s, int d) -{ - return mixers[d]->getWeight(s); -} - -void deMixerLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - - int n = getColorSpaceSize(colorSpace); - int i; - for (i = 0; i < n; i++) - { - xmlNodePtr child = xmlNewChild(root, NULL, BAD_CAST("mixer"), NULL); - mixers[i]->save(child); - } -} - -void deMixerLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - int i = 0; - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("mixer")))) - { - mixers[i]->load(child); - i++; - } - - child = child->next; - } -} - -bool deMixerLayer::randomize() -{ - int n = getColorSpaceSize(colorSpace); - - int s = rand() % n; - int d = rand() % n; - - deValue v = (deValue) rand() / RAND_MAX; - - v *= 1.3; - v -= 0.2; - - mixers[d]->setWeight(s, v); - - return true; -} diff -Nru delaboratory-0.7/src/mixer_layer.h delaboratory-0.8/src/mixer_layer.h --- delaboratory-0.7/src/mixer_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/mixer_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_MIXER_LAYER_H -#define _DE_MIXER_LAYER_H - -#include "action_layer.h" -#include "mixer.h" - -class deMixerLayer:public deActionLayer -{ - private: - std::vector mixers; - - protected: - virtual bool singleChannelProcessing() const {return false;}; - virtual std::string getType() const {return "mixer";}; - virtual std::string getLabel() const {return "channel mixer";}; - - public: - deMixerLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deMixerLayer(); - - deMixer* getMixer(int index); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction4(int i, const deChannel* s1, const deChannel* s2, const deChannel* s3, const deChannel* s4, deChannel& channel, int channelSize); - - void setWeight(int s, int d, deValue value); - deValue getWeight(int s, int d); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "mixer";}; - - virtual bool randomize(); - - - -}; - -#endif diff -Nru delaboratory-0.7/src/palette.cc delaboratory-0.8/src/palette.cc --- delaboratory-0.7/src/palette.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/palette.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "palette.h" - -dePalette3::dePalette3(deColorSpace _colorSpace) -:colorSpace(_colorSpace) -{ -} - -dePalette3::~dePalette3() -{ -} - -void dePalette3::addColor(const deColor3& color) -{ - colors.push_back(color); -} - -void dePalette3::optimize(const dePalette3& source, int n, deValue margin) -{ - int ss = source.colors.size(); - - deValue** distances = new deValue * [ss]; - - int i; - int j; - for (i = 0; i < ss; i++) - { - distances[i] = new deValue [ss]; - for (j = 0; j < ss; j++) - { - deValue d = 0; - if (i != j) - { - d = source.colors[i].calcDistance(source.colors[j]); - } - distances[i][j] = d; - } - - } - - bool no_more = false; - - while ((colors.size() < (unsigned int)n) && (!no_more)) - { - int winner = -1; - int max = 0; - - for (i = 0; i < ss; i++) - { - int counter = 0; - for (j = 0; j < ss; j++) - { - deValue d = distances[i][j]; - if (d != 0) - { - if ( d < margin ) - { - counter++; - } - } - } - if (counter > max) - { - winner = i; - max = counter; - } - } - - if (winner >= 0) - { - colors.push_back(source.colors[winner]); - for (i = 0; i < ss; i++) - { - deValue d = distances[winner][i]; - if (d != 0) - { - if ( d < margin ) - { - for (j = 0; j < ss; j++) - { - distances[i][j] = 0; - distances[j][i] = 0; - } - } - } - } - } - else - { - no_more = true; - } - } - - for (i = 0; i < ss; i++) - { - delete [] distances[i]; - } - delete [] distances; -} - -deColor3 dePalette3::getColor(int index) -{ - return colors[index]; -} - -void dePalette3::getMinMax(int index, deValue& min, deValue& max) -{ - int n = colors.size(); - int i; - min = -1; - max = -1; - for (i = 0; i < n; i++) - { - deColor3& color = colors[i]; - deValue v; - switch (index) - { - case 1: - v = color.getV1(); - break; - case 2: - v = color.getV2(); - break; - case 3: - v = color.getV3(); - break; - default: - break; - } - if (min < 0) - { - min = v; - max = v; - } - else - { - if (v < min) - { - min = v; - } - if (v > max) - { - max = v; - } - } - } -} - -bool dePalette3::find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& resultL) -{ - int n = colors.size(); - int i; - - deValue sum = 0.0; - int found = 0; - - for (i = 0; i < n; i++) - { - deColor3& color = colors[i]; - deValue L = color.getV1(); - deValue A = color.getV2(); - deValue B = color.getV3(); - if ((A >= minA) && (A < maxA) && (B >= minB) && (B < maxB)) - { - sum += L; - found++; - } - } - - resultL = sum / found; - return (found > 0); -} diff -Nru delaboratory-0.7/src/palette.h delaboratory-0.8/src/palette.h --- delaboratory-0.7/src/palette.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/palette.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PALETTE_H -#define _DE_PALETTE_H - -#include -#include "value.h" -#include "color_space.h" - -class deColor3 -{ - private: - deValue v1; - deValue v2; - deValue v3; - public: - deColor3(deValue _v1, deValue _v2, deValue _v3) - :v1(_v1), - v2(_v2), - v3(_v3) - { - }; - virtual ~deColor3() - { - }; - - deValue getV1() {return v1;}; - deValue getV2() {return v2;}; - deValue getV3() {return v3;}; - - deValue calcDistance(const deColor3& c) const - { - deValue d1 = c.v1 - v1; - deValue d2 = c.v2 - v2; - deValue d3 = c.v3 - v3; - deValue d = d1 * d1 + d2 * d2 + d3 * d3; - return sqrt(d); - }; -}; - -class dePalette3 -{ - private: - deColorSpace colorSpace; - std::vector colors; - - public: - dePalette3(deColorSpace _colorSpace); - virtual ~dePalette3(); - - void addColor(const deColor3& color); - - void optimize(const dePalette3& source, int n, deValue margin); - - deColor3 getColor(int index); - - int getSize() const {return colors.size();}; - - void getMinMax(int index, deValue& min, deValue& max); - bool find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& L); - -}; - -#endif diff -Nru delaboratory-0.7/src/power.cc delaboratory-0.8/src/power.cc --- delaboratory-0.7/src/power.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/power.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "power.h" -#include -#include "logger.h" -#include "str.h" - -dePower::dePower(double _power, int s) -{ - power = _power; - - scale = (POWER_CACHE_SIZE - 1.0) / s; - - logMessage("create dePower power: " + str((float)power) + " scale: " +str((float)scale)); - - int i; - for (i = 0; i < POWER_CACHE_SIZE; i++) - { - double p = i / scale; - values[i] = pow(p, power); - } - -} - -dePower::~dePower() -{ - logMessage("destroy dePower power: " + str((float)power) + " scale: " +str((float)scale)); -} - -double dePower::get(double v) -{ - int i = v * scale; - if ((i >= 0) && (i < POWER_CACHE_SIZE)) - return values[i]; - return pow(v, power); -} - diff -Nru delaboratory-0.7/src/power.h delaboratory-0.8/src/power.h --- delaboratory-0.7/src/power.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/power.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_POWER_H -#define _DE_POWER_H - -#define POWER_CACHE_SIZE 65536 - -class dePower -{ - private: - double power; - double values[POWER_CACHE_SIZE]; - double scale; - - public: - dePower(double _power, int s); - ~dePower(); - - double get(double v); -}; - -#endif diff -Nru delaboratory-0.7/src/preset.cc delaboratory-0.8/src/preset.cc --- delaboratory-0.7/src/preset.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/preset.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "preset.h" - diff -Nru delaboratory-0.7/src/preset.h delaboratory-0.8/src/preset.h --- delaboratory-0.7/src/preset.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/preset.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PRESET_H -#define _DE_PRESET_H - -#include -#include "value.h" -#include "layer.h" -#include "property_value.h" - -class dePreset -{ - private: - dePreset(const dePreset&); - dePreset& operator =(const dePreset&); - - protected: - const std::string name; - - public: - dePreset(const std::string& _name) - :name(_name) - { - } - - virtual ~dePreset() - { - } - - std::string getName() {return name;}; - -}; - -class dePresetValue:public dePreset -{ - private: - deValue value; - - public: - dePresetValue(const std::string& _name, deValue _value) - :dePreset(_name), - value(_value) - { - } - - virtual ~dePresetValue() - { - } - - deValue getValue() {return value;}; - - -}; - -class dePresetLayer -{ - private: - deLayer& layer; - std::vector valuePresets; - - dePresetLayer(const dePresetLayer&); - dePresetLayer& operator =(const dePresetLayer&); - - public: - dePresetLayer(deLayer& _layer) - :layer(_layer) - { - } - - virtual ~dePresetLayer() - { - } - - void addPresetValue(dePresetValue* preset) - { - valuePresets.push_back(preset); - } - - bool apply() - { - std::vector::iterator i; - for (i = valuePresets.begin(); i != valuePresets.end(); i++) - { - dePresetValue* pv = *i; - const std::string n = pv->getName(); - const deValue v = pv->getValue(); - - dePropertyValue* property = layer.getPropertyValue(n); - property->set(v); - - } - - return true; - } -}; - - -#endif diff -Nru delaboratory-0.7/src/process_linear.cc delaboratory-0.8/src/process_linear.cc --- delaboratory-0.7/src/process_linear.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/process_linear.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "process_linear.h" - -void processLinear(const deValue* src, deValue* dst, int n, deValue min, deValue max, bool invert) -{ - if ((min == 0) && (max == 1) && (src==dst)) - { - return; - } - - if (max < min) - { - invert = !invert; - deValue m = min; - min = max; - max = m; - } - - deValue left; - deValue right; - deValue a = 0; - - if (min < max) - { - a = 1.0 / (max - min); - } - - if (invert) - { - left = 1.0; - right = 0.0; - a = -a; - } - else - { - left = 0.0; - right = 1.0; - } - - int i; - - for (i = 0; i < n; i++) - { - deValue v = src[i]; - if (v <= min) - { - dst[i] = left; - } else if (v >= max) - { - dst[i] = right; - } - else - { - dst[i] = left + a * (v - min); - } - } -} - -void shiftChannel(const deValue* src, deValue* dst, deValue shift, int n) -{ - int i; - - for (i = 0; i < n; i++) - { - deValue v = src[i]; - v += shift; - if (v < 0.0) - { - v += 1.0; - } - if (v > 1.0) - { - v -= 1.0; - } - dst[i] = v; - } -} diff -Nru delaboratory-0.7/src/process_linear.h delaboratory-0.8/src/process_linear.h --- delaboratory-0.7/src/process_linear.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/process_linear.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROCESS_LINEAR_H -#define _DE_PROCESS_LINEAR_H - -#include "value.h" - -void processLinear(const deValue* src, deValue* dst, int n, deValue min, deValue max, bool invert); -void shiftChannel(const deValue* src, deValue* dst, deValue shift, int n); - -#endif diff -Nru delaboratory-0.7/src/project.cc delaboratory-0.8/src/project.cc --- delaboratory-0.7/src/project.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/project.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,855 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "project.h" -#include "image_io.h" -#include -#include -#include -#include "source_image_layer.h" -#include "curves_layer.h" -#include "conversion_layer.h" -#include "conversion_functions.h" -#include "image_panel.h" -#include "str.h" -#include "histogram_panel.h" -#include "histogram_mode_panel.h" -#include "control_panel.h" -#include "view_mode_panel.h" -#include -#include "layer_factory.h" -#include "convert_image.h" -#include "fractal.h" -#include "xml.h" -#include "image_area_panel.h" -#include "memory_info_frame.h" -#include -#include "main_frame.h" -#include "layer_processor.h" -#include "external_editor.h" -#include "channel_manager.h" -#include "layer_stack.h" -#include "layer_frame_manager.h" -#include "static_image.h" -#include "raw_module.h" -#include "zoom_manager.h" - -#define ICC_MESSAGE 0 - -deProject::deProject(deLayerProcessor& _processor, deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager) -:layerProcessor(_processor), - viewModePanel(NULL), - previewChannelManager(_previewChannelManager), - controlPanel(NULL), - memoryInfoFrame(NULL), - viewManager(*this, _processor, _zoomManager), - mainFrame(NULL), - sourceImage(_sourceImage), - layerStack(_layerStack), - layerFrameManager(_layerFrameManager), - histogramModePanel(NULL), - imageAreaPanel(NULL), - rawModule(_rawModule), - zoomManager(_zoomManager) -{ - imageFileName = ""; - sourceImageFileName = ""; - receiveKeys = true; - - log("project started"); - - layerProcessor.setViewManager(&viewManager); - - resetLayerStack(deColorSpaceRGB); - -} - -void deProject::disableKeys() -{ - receiveKeys = false; -} - -void deProject::enableKeys() -{ - receiveKeys = true; -} - -deProject::~deProject() -{ - log("closing project"); - layerProcessor.lock(); - layerProcessor.unlock(); - layerStack.clear(); - log("closed project"); -} - -void deProject::setHistogramChannel(int channel) -{ - if (histogramModePanel) - { - histogramModePanel->updateMode(channel); - } - layerProcessor.generateHistogram(); -} - -void deProject::onKey(int key) -{ - if (key == '`') - { - viewManager.setNormal(); - } - if (key == '1') - { - viewManager.setSingleChannel(0); - } - if (key == '2') - { - viewManager.setSingleChannel(1); - } - if (key == '3') - { - viewManager.setSingleChannel(2); - } - if (key == '4') - { - viewManager.setSingleChannel(3); - } - if (key == WXK_F1) - { - setHistogramChannel(0); - } - if (key == WXK_F2) - { - setHistogramChannel(1); - } - if (key == WXK_F3) - { - setHistogramChannel(2); - } - if (key == WXK_F4) - { - setHistogramChannel(3); - } - - layerFrameManager.onKey(key); - if (controlPanel) - { - controlPanel->onKey(key); - } -} - -void deProject::init(const std::string& fileName) -{ - if (openImage(fileName, true, deColorSpaceLAB)) - { - return; - } - if (openImage(fileName, false, deColorSpaceRGB)); - { - return; - } - open(fileName, true); -} - -void deProject::freeImage() -{ -} - -void deProject::setTestImage(int s) -{ - freeImage(); - - deSize size(s, s); - - sourceImage.setColorSpace(deColorSpaceRGB); - sourceImage.setSize(size); - deChannel* channelRR = sourceImage.getChannel(0); - deChannel* channelGG = sourceImage.getChannel(1); - deChannel* channelBB = sourceImage.getChannel(2); - - generateFractal(channelRR->getPixels(), channelGG->getPixels(), channelBB->getPixels(), size); - - imageFileName = "delaboratory_test_image"; - onImageNameUpdate(); - - previewChannelManager.destroyAllChannels(); - if (imageAreaPanel) - { - imageAreaPanel->updateSize(true); - } - layerProcessor.updateAllImages(true); -} - -void deProject::resetLayerStack(deColorSpace colorSpace) -{ - logMessage("reset layer stack"); - - layerProcessor.removeAllLayers(); - - deLayer* layer = createLayer("source_image", -1, colorSpace, layerStack, previewChannelManager, viewManager, "source image", sourceImage); - - if (layer) - { - layerProcessor.addLayer(layer); - } - - previewChannelManager.destroyAllChannels(); - layerProcessor.updateAllImages(true); - - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } - - setLastView(); - -} - -deChannelManager& deProject::getPreviewChannelManager() -{ - return previewChannelManager; -} - -deSize deProject::getSourceImageSize() -{ - deSize size = sourceImage.getSize(); - - deValue x1; - deValue y1; - deValue x2; - deValue y2; - - zoomManager.getZoom(x1, y1, x2, y2); - - deValue w = size.getW() * (x2 - x1); - deValue h = size.getH() * (y2 - y1); - - return deSize(w, h); -} - -deLayerStack& deProject::getLayerStack() -{ - return layerStack; -} - -deLayerProcessor& deProject::getLayerProcessor() -{ - return layerProcessor; -} - -void deProject::onChangeView(int a) -{ - - logMessage("change view from " + str(a) + " start"); - layerProcessor.onChangeView(a); - - if (controlPanel) - { - controlPanel->onChangeView(); - } - if (viewModePanel) - { - viewModePanel->updateNames(); - } - if (histogramModePanel) - { - histogramModePanel->updateNames(); - } - updateMemoryInfo(); - if (mainFrame) - { - mainFrame->rebuild(); - } - logMessage("change view from " + str(a) + " end"); -} - -const deViewManager& deProject::getViewManager() const -{ - return viewManager; -} - -deViewManager& deProject::getViewManager() -{ - return viewManager; -} - -void deProject::saveImage(const std::string& fileName, const deImage& image, const std::string& type) -{ - if (image.getColorSpace() == deColorSpaceRGB) - { - deChannel* r = previewChannelManager.getChannel(image.getChannelIndex(0)); - deChannel* g = previewChannelManager.getChannel(image.getChannelIndex(1)); - deChannel* b = previewChannelManager.getChannel(image.getChannelIndex(2)); - - if (type == "tiff") - { - saveTIFF(fileName, *r, *g, *b, previewChannelManager.getChannelSize()); - } - if (type == "jpeg") - { - saveJPEG(fileName, *r, *g, *b, previewChannelManager.getChannelSize()); - } - } - else - { - deImage finalImage(deColorSpaceRGB, previewChannelManager); - finalImage.enableAllChannels(); - convertImage(image, finalImage, previewChannelManager); - deChannel* r = previewChannelManager.getChannel(finalImage.getChannelIndex(0)); - deChannel* g = previewChannelManager.getChannel(finalImage.getChannelIndex(1)); - deChannel* b = previewChannelManager.getChannel(finalImage.getChannelIndex(2)); - if (type == "tiff") - { - saveTIFF(fileName, *r, *g, *b, previewChannelManager.getChannelSize()); - } - if (type == "jpeg") - { - saveJPEG(fileName, *r, *g, *b, previewChannelManager.getChannelSize()); - } - } -} - -bool deProject::exportFinalImage(const std::string& app, const std::string& type, const std::string& name, wxProgressDialog* progressDialog) -{ - // name is taken from file dialog, it can be empty when we are exporting to external editor - // but in this case we need correct imageFileName - if ((name == "") && (imageFileName == "")) - { - wxMessageBox( _T("exporting final image failed - no file name set")); - return false; - } - - std::string fileName; - - if (name == "") - { - // path is a directory for temporary save, used only when exporting to external editor - std::string path = getTmp(); - - // we save file in the temporary directory - fileName = path + "/" + imageFileName + "." + type; - } - else - { - // wa save file in the location taken from file dialog - fileName = name; - } - - // remember original size of preview - deSize originalSize = previewChannelManager.getChannelSize(); - - // calculate final image in full size - int view = viewManager.getView(); - - previewChannelManager.setChannelSize(sourceImage.getSize()); - - bool result = layerProcessor.updateImagesSmart(view, progressDialog, memoryInfoFrame); - - if (result) - { - // take the final image - deLayer* layer = layerStack.getLayer(view); - const deImage& image = layer->getImage(); - - // save it - saveImage(fileName, image, type); - } - else - { - wxMessageBox( _T("exporting final image failed - error during update images\n(probably out of memory)")); - } - - // bring back original size of preview - previewChannelManager.setChannelSize(originalSize); - - if (result) - { - // execute external editor - if (app.size() > 0) - { - executeExternalEditor(fileName, app); - } - } - - // calculate image in preview size to continue editing - layerProcessor.updateAllImages(true); - - return result; -} - -void deProject::setLastView() -{ - int n = layerStack.getSize(); - n--; - viewManager.setView(n); -} - -void deProject::setViewModePanel(deViewModePanel* _viewModePanel) -{ - viewModePanel = _viewModePanel; -} - -void deProject::setHistogramModePanel(deHistogramModePanel* _histogramModePanel) -{ - histogramModePanel = _histogramModePanel; -} - - -void deProject::setControlPanel(deControlPanel* _controlPanel) -{ - controlPanel = _controlPanel; -} - -void deProject::onChangeViewMode() -{ - if (viewModePanel) - { - viewModePanel->updateMode(); - } -} - -void deProject::save(const std::string& fileName, bool image) -{ - std::string f = fileName; - - size_t pos = f.rfind(".delab"); - if (pos != f.size() - 6) - { - f += ".delab"; - } - - xmlDocPtr doc = xmlNewDoc(BAD_CAST("1.0")); - - xmlNodePtr root = xmlNewNode(NULL, BAD_CAST("project")); - xmlDocSetRootElement(doc, root); - - { - xmlNodePtr child = xmlNewChild(root, NULL, BAD_CAST("layer_stack"), NULL); - layerStack.save(child); - - if (image) - { - saveChild(root, "source_image", sourceImageFileName); - } - } - - xmlSaveFormatFile (f.c_str(), doc, 1); -} - -void deProject::loadLayer(xmlNodePtr root) -{ - xmlNodePtr child = root->xmlChildrenNode; - - std::string type = ""; - std::string name = ""; - int source = -1; - deColorSpace colorSpace = deColorSpaceInvalid; - - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("source")))) - { - source = getInt(getContent(child)); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("color_space")))) - { - colorSpace = colorSpaceFromString(getContent(child)); - } - - if (type == "") - // this is fix for multiple "type" node in single layer - { - if ((!xmlStrcmp(child->name, BAD_CAST("type")))) - { - type = getContent(child); - } - } - - if ((!xmlStrcmp(child->name, BAD_CAST("name")))) - { - name = getContent(child); - } - - child = child->next; - } - - deLayer* layer = createLayer(type, source, colorSpace, layerStack, previewChannelManager, viewManager, name, sourceImage); - - if (layer) - { - layerProcessor.addLayer(layer); - layer->load(root); - } - - -} - -void deProject::loadLayers(xmlNodePtr root) -{ - layerStack.clear(); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("layer")))) - { - loadLayer(child); - } - - child = child->next; - } - - previewChannelManager.destroyAllChannels(); - layerProcessor.updateAllImages(true); -} - -void deProject::open(const std::string& fileName, bool image) -{ - xmlDocPtr doc = xmlParseFile(fileName.c_str()); - - if (!doc) - { - return; - } - - xmlNodePtr root = xmlDocGetRootElement(doc); - - if (!root) - { - return; - } - - xmlNodePtr child = root->xmlChildrenNode; - - std::string imageFile = ""; - - while (child) - { - if ((!xmlStrcmp(child->name, BAD_CAST("layer_stack")))) - { - loadLayers(child); - } - - if ((!xmlStrcmp(child->name, BAD_CAST("source_image")))) - { - imageFile = getContent(child); - } - - child = child->next; - } - - if (image) - { - if (!openImage(imageFile, true, deColorSpaceLAB)) // FIXME - { - openImage(imageFile, false, deColorSpaceRGB); - } - } - - setLastView(); - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } -} - -void deProject::newProject() -{ - resetLayerStack(deColorSpaceRGB); - setLastView(); - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } -} - -void deProject::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) -{ - imageAreaPanel = _imageAreaPanel; -} - -bool deProject::openImage(const std::string& fileName, bool raw, deColorSpace colorSpace) -{ - - freeImage(); - - logMessage("open image " + fileName); - - deColorSpace oldColorSpace = sourceImage.getColorSpace(); - - if (raw) - { - layerProcessor.sendInfoEvent(DE_DCRAW_START); - if ((rawModule.loadRAW(fileName, sourceImage, colorSpace, true))) - { - logMessage("found RAW " + fileName); - bool failure = false; - while (!rawModule.update(failure)) - { - wxThread::Sleep(200); - if (failure) - { - logMessage("failed RAW load " + fileName); - layerProcessor.sendInfoEvent(DE_DCRAW_END); - return false; - } - } - bool result = rawModule.loadRAW(fileName, sourceImage, colorSpace, false); - if (!result) - { - return false; - } - - rawTimer->Start(500); - - } - else - { - logMessage("failed RAW " + fileName); - layerProcessor.sendInfoEvent(DE_DCRAW_END); - return false; - } - } - else - { - if (!loadTIFF(fileName, sourceImage, colorSpace)) - { - if (!loadJPEG(fileName, sourceImage, colorSpace)) - { - return false; - } - } - } - - imageFileName = removePathAndExtension(fileName); - onImageNameUpdate(); - sourceImageFileName = fileName; - - previewChannelManager.destroyAllChannels(); - if (imageAreaPanel) - { - imageAreaPanel->updateSize(true); - } - layerProcessor.updateAllImages(true); - - deColorSpace newColorSpace = sourceImage.getColorSpace(); - - if (oldColorSpace != newColorSpace) - { - resetLayerStack(newColorSpace); - onChangeView(0); - } - - return true; -} - -void deProject::openMemoryInfoFrame(wxWindow* parent) -{ - if (!memoryInfoFrame) - { - memoryInfoFrame = new deMemoryInfoFrame(parent, *this); - memoryInfoFrame->Show(); - } -} - -void deProject::closeMemoryInfoFrame() -{ - memoryInfoFrame = NULL; -} - -void deProject::updateMemoryInfo() -{ - if (memoryInfoFrame) - { - memoryInfoFrame->update(); - } -} - -void deProject::setMainFrame(deMainFrame* _mainFrame) -{ - log("set main frame in project"); - mainFrame = _mainFrame; - - rawTimer = new wxTimer(mainFrame, wxID_ANY); -} - -bool deProject::isSourceValid() const -{ - return (previewChannelManager.getChannelSize().getN() > 0); -} - -void deProject::log(const std::string& message) -{ - logMessage(message); -} - -void deProject::addActionLayer(const std::string& action) -{ - int s = viewManager.getView(); - - deLayer* vLayer = layerStack.getLayer(s); - if (!vLayer) - { - return; - } - - deColorSpace colorSpace = vLayer->getColorSpace(); - - std::string actionDescription = getActionDescription(action); - - log("creating action " + action + " layer"); - - deLayer* layer = createLayer(action, s, colorSpace, layerStack, previewChannelManager, viewManager, actionDescription, sourceImage); - - if (layer) - { - layerProcessor.addLayer(layer); - setLastView(); - - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } - } -} - -void deProject::addConversionLayer(deColorSpace colorSpace) -{ - int s = viewManager.getView(); - - std::string name = getColorSpaceName(colorSpace); - - log("creating conversion to " + name + " layer"); - - deLayer* layer = createLayer("conversion", s, colorSpace, layerStack, previewChannelManager, viewManager, name, sourceImage); - - if (layer) - { - layerProcessor.addLayer(layer); - setLastView(); - - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } - - } -} - -void deProject::addRandomLayer() -{ - int view = layerStack.getSize() - 1; - - if (view > 0) - { - if (rand() % view > 3) - { - layerProcessor.removeTopLayer(); - if (controlPanel) - { - controlPanel->updateLayerGrid(); - } - return; - } - } - - if (rand() % 10 > 2) - { - std::vector actions; - getSupportedActions(actions); - - int n = actions.size(); - int r = rand() % n; - - std::string a = actions[r]; - addActionLayer(a); - } - else - { - deLayer* layer = layerStack.getLayer(view); - if (!layer) - { - return; - } - - deColorSpace currentColorSpace = layer->getColorSpace(); - - bool valid = false; - deColorSpace c = deColorSpaceInvalid; - - while (!valid) - { - std::vector colorSpaces; - getSupportedColorSpaces(colorSpaces); - - int n = colorSpaces.size(); - int r = rand() % n; - - c = colorSpaces[r]; - - valid = checkConversion(currentColorSpace, c); - - if (c == currentColorSpace) - { - valid = false; - } - } - - addConversionLayer(c); - } - - int n = layerStack.getSize(); - int i; - for (i = 0 ; i < n ; i++) - { - deLayer* layer = layerStack.getLayer(i); - if (layer->randomize()) - { - layerProcessor.markUpdateAllChannels(i); - } - } -} - -void deProject::onImageNameUpdate() -{ - if (mainFrame) - { - mainFrame->setImageName(imageFileName, sourceImage.getSize()); - } -} - -void deProject::onTimerUpdate() -{ - bool failure = false; - - bool result = rawModule.update(failure); - - if ((result) || (failure)) - { - layerProcessor.sendInfoEvent(DE_DCRAW_END); - rawTimer->Stop(); - } - if (result) - { - wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, DE_IMAGE_LOAD_EVENT ); - wxPostEvent( mainFrame, event ); - } - -} diff -Nru delaboratory-0.7/src/project.h delaboratory-0.8/src/project.h --- delaboratory-0.7/src/project.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/project.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROJECT_H -#define _DE_PROJECT_H - -#include "sampler_manager.h" -#include "view_manager.h" -#include "logger.h" -#include "image.h" -#include -#include "size.h" -#include - -class deImagePanel; -class deHistogramPanel; -class deControlPanel; -class deViewModePanel; -class deHistogramModePanel; -class deImageAreaPanel; -class deMemoryInfoFrame; -class deMainFrame; -class deLayerProcessor; -class deLayerStack; -class deLayerFrameManager; -class deLayer; -class deStaticImage; -class deRawModule; -class deZoomManager; - -class deProject -{ - private: - deProject(const deProject& project); - deProject& operator =(const deProject& project); - - deLayerProcessor& layerProcessor; - deViewModePanel* viewModePanel; - deChannelManager& previewChannelManager; - - deControlPanel* controlPanel; - deMemoryInfoFrame* memoryInfoFrame; - deViewManager viewManager; - - deMainFrame* mainFrame; - - deStaticImage& sourceImage; - - deLayerStack& layerStack; - - deLayerFrameManager& layerFrameManager; - - std::string imageFileName; - std::string sourceImageFileName; - - bool receiveKeys; - - deHistogramModePanel* histogramModePanel; - deImageAreaPanel* imageAreaPanel; - - deRawModule& rawModule; - - deZoomManager& zoomManager; - - wxTimer* rawTimer; - - void onImageNameUpdate(); - - void loadLayers(xmlNodePtr root); - void loadLayer(xmlNodePtr root); - - void freeImage(); - - void onScaleSet(); - - void saveImage(const std::string& filename, const deImage& image, const std::string& type); - - public: - deProject(deLayerProcessor& _processor, deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager); - - virtual ~deProject(); - void onKey(int key); - void init(const std::string& fileName); - void resetLayerStack(deColorSpace colorSpace); - - deChannelManager& getPreviewChannelManager(); - deSize getSourceImageSize(); - deLayerStack& getLayerStack(); - deLayerProcessor& getLayerProcessor(); - - bool isSourceValid() const; - - const deViewManager& getViewManager() const; - deViewManager& getViewManager(); - - void addLAB(); - void addRGB(); - - void onChangeView(int a); - - bool exportFinalImage(const std::string& app, const std::string& type, const std::string& name, wxProgressDialog* progressDialog); - - void setLastView(); - - bool shouldReceiveKeys() const {return receiveKeys;}; - - void disableKeys(); - void enableKeys(); - - void setViewModePanel(deViewModePanel* _viewModePanel); - void setHistogramModePanel(deHistogramModePanel* _histogramModePanel); - void setControlPanel(deControlPanel* _controlPanel); - void onChangeViewMode(); - - void save(const std::string& fileName, bool image); - void open(const std::string& fileName, bool image); - bool openImage(const std::string& fileName, bool raw, deColorSpace colorSpace); - void newProject(); - void setTestImage(int s); - - void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); - - void openMemoryInfoFrame(wxWindow* parent); - void closeMemoryInfoFrame(); - - void updateMemoryInfo(); - - void setHistogramChannel(int channel); - - void setMainFrame(deMainFrame* _mainFrame); - - void addRandomLayer(); - - deLayerFrameManager& getLayerFrameManager() {return layerFrameManager;}; - - void log(const std::string& message); - - void addActionLayer(const std::string& action); - void addConversionLayer(deColorSpace colorSpace); - - void onTimerUpdate(); - -}; - -#endif diff -Nru delaboratory-0.7/src/property_boolean.cc delaboratory-0.8/src/property_boolean.cc --- delaboratory-0.7/src/property_boolean.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_boolean.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_boolean.h" -#include "str.h" -#include "xml.h" - -dePropertyBoolean::dePropertyBoolean(const std::string& _name) -:deProperty(_name) -{ - value = false; -} - -dePropertyBoolean::~dePropertyBoolean() -{ -} - -void dePropertyBoolean::set(bool _value) -{ - value = _value; -} - - -bool dePropertyBoolean::get() const -{ - return value; -} - -void dePropertyBoolean::save(xmlNodePtr root) const -{ - saveChild(root, name, str(value)); -} - -void dePropertyBoolean::load(xmlNodePtr child) -{ - if ((!xmlStrcmp(child->name, BAD_CAST(name.c_str())))) - { - value = getBool(getContent(child)); - } -} - diff -Nru delaboratory-0.7/src/property_boolean.h delaboratory-0.8/src/property_boolean.h --- delaboratory-0.7/src/property_boolean.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_boolean.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_BOOLEAN_H -#define _DE_PROPERTY_BOOLEAN_H - -#include "property.h" - -class dePropertyBoolean:public deProperty -{ - private: - bool value; - - public: - dePropertyBoolean(const std::string& _name); - virtual ~dePropertyBoolean(); - - void set(bool _value); - bool get() const; - - virtual void save(xmlNodePtr root) const; - virtual void load(xmlNodePtr root); -}; - -#endif diff -Nru delaboratory-0.7/src/property_boolean_ui.cc delaboratory-0.8/src/property_boolean_ui.cc --- delaboratory-0.7/src/property_boolean_ui.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_boolean_ui.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_boolean_ui.h" -#include "property_boolean.h" -#include "layer.h" -#include "layer_processor.h" - -dePropertyBooleanUI::dePropertyBooleanUI(wxWindow *parent, dePropertyBoolean& _property, deLayer& _layer, deLayerProcessor& _layerProcessor) -:deCheckBox(parent, _property.getLabel()), -property(_property), -layer(_layer), -layerProcessor(_layerProcessor) -{ - setFromProperty(); -} - -dePropertyBooleanUI::~dePropertyBooleanUI() -{ -} - -void dePropertyBooleanUI::onCheck(bool c) -{ - property.set(c); - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} - -void dePropertyBooleanUI::setFromProperty() -{ - set(property.get()); -} diff -Nru delaboratory-0.7/src/property_boolean_ui.h delaboratory-0.8/src/property_boolean_ui.h --- delaboratory-0.7/src/property_boolean_ui.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_boolean_ui.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_BOOLEAN_UI_H -#define _DE_PROPERTY_BOOLEAN_UI_H - -#include "check_box.h" -class deLayer; -class dePropertyBoolean; -class deLayerProcessor; - -class dePropertyBooleanUI:public deCheckBox -{ - private: - dePropertyBoolean& property; - deLayer& layer; - deLayerProcessor& layerProcessor; - - public: - dePropertyBooleanUI(wxWindow *parent, dePropertyBoolean& _property, deLayer& _layer, deLayerProcessor& _layerProcessor); - virtual ~dePropertyBooleanUI(); - - virtual void onCheck(bool c); - - void setFromProperty(); - -}; - -#endif diff -Nru delaboratory-0.7/src/property.cc delaboratory-0.8/src/property.cc --- delaboratory-0.7/src/property.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property.h" - -deProperty::deProperty(const std::string& _name) -:name(_name) -{ - label = ""; -} - -deProperty::~deProperty() -{ -} - -std::string deProperty::getName() const -{ - return name; -} - -std::string deProperty::getLabel() const -{ - if (label == "") - { - return name; - } - else - { - return label; - } -} - -void deProperty::setLabel(const std::string& _label) -{ - label = _label; -} diff -Nru delaboratory-0.7/src/property_choice.cc delaboratory-0.8/src/property_choice.cc --- delaboratory-0.7/src/property_choice.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_choice.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_choice.h" -#include "xml.h" -#include "str.h" - -dePropertyChoice::dePropertyChoice(const std::string& _name) -:deProperty(_name) -{ - value = ""; -} - -dePropertyChoice::~dePropertyChoice() -{ -} - -void dePropertyChoice::set(std::string _value) -{ - value = _value; -} - -std::string dePropertyChoice::get() const -{ - return value; -} - -int dePropertyChoice::getIndex() const -{ - std::vector::const_iterator i = choices.begin(); - int index = 0; - while (i != choices.end()) - { - if (*i == value) - { - return index; - } - i++; - index++; - } - return -1; -} - -void dePropertyChoice::save(xmlNodePtr root) const -{ - saveChild(root, name, value); -} - -void dePropertyChoice::load(xmlNodePtr root) -{ - if ((!xmlStrcmp(root->name, BAD_CAST(name.c_str())))) - { - value = getContent(root); - } -} - -void dePropertyChoice::setIndex(int index) -{ - set(choices[index]); -} diff -Nru delaboratory-0.7/src/property_choice.h delaboratory-0.8/src/property_choice.h --- delaboratory-0.7/src/property_choice.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_choice.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_CHOICE_H -#define _DE_PROPERTY_CHOICE_H - -#include "property.h" -#include - -class dePropertyChoice:public deProperty -{ - private: - std::string value; - - std::vector choices; - public: - dePropertyChoice(const std::string& _name); - virtual ~dePropertyChoice(); - - void set(std::string _value); - std::string get() const; - - virtual void save(xmlNodePtr root) const; - virtual void load(xmlNodePtr root); - - std::vector& getChoices() {return choices;}; - - void setIndex(int index); - int getIndex() const; - -}; - -#endif diff -Nru delaboratory-0.7/src/property_choice_ui.cc delaboratory-0.8/src/property_choice_ui.cc --- delaboratory-0.7/src/property_choice_ui.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_choice_ui.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_choice_ui.h" -#include "property_choice.h" -#include "layer.h" -#include "layer_processor.h" - -dePropertyChoiceUI::dePropertyChoiceUI(wxWindow *parent, dePropertyChoice& _property, deLayer& _layer, deLayerProcessor& _layerProcessor) -:deChoice(parent, _property.getLabel(), _property.getChoices()), -property(_property), -layer(_layer), -layerProcessor(_layerProcessor) -{ - setFromProperty(); -} - -dePropertyChoiceUI::~dePropertyChoiceUI() -{ -} - -void dePropertyChoiceUI::onChoose(int c) -{ - property.setIndex(c); - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} - -void dePropertyChoiceUI::setFromProperty() -{ - int index = property.getIndex(); - set(index); -} diff -Nru delaboratory-0.7/src/property_choice_ui.h delaboratory-0.8/src/property_choice_ui.h --- delaboratory-0.7/src/property_choice_ui.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_choice_ui.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_CHOICE_UI_H -#define _DE_PROPERTY_CHOICE_UI_H - -#include "choice.h" -class deLayer; -class dePropertyChoice; -class deLayerProcessor; - -class dePropertyChoiceUI:public deChoice -{ - private: - dePropertyChoice& property; - deLayer& layer; - deLayerProcessor& layerProcessor; - - public: - dePropertyChoiceUI(wxWindow *parent, dePropertyChoice& _property, deLayer& _layer, deLayerProcessor& _layerProcessor); - virtual ~dePropertyChoiceUI(); - - virtual void onChoose(int c); - - void setFromProperty(); - -}; - -#endif diff -Nru delaboratory-0.7/src/property.h delaboratory-0.8/src/property.h --- delaboratory-0.7/src/property.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_H -#define _DE_PROPERTY_H - -#include -#include - -class deProperty -{ - private: - std::string label; - - protected: - std::string name; - - public: - deProperty(const std::string& _name); - virtual ~deProperty(); - - virtual void save(xmlNodePtr root) const = 0; - virtual void load(xmlNodePtr root) = 0; - - std::string getLabel() const; - void setLabel(const std::string& _label); - - std::string getName() const; -}; - -#endif diff -Nru delaboratory-0.7/src/property_value.cc delaboratory-0.8/src/property_value.cc --- delaboratory-0.7/src/property_value.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_value.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_value.h" -#include "str.h" -#include "xml.h" - -dePropertyValue::dePropertyValue(const std::string& _name) -:deProperty(_name) -{ - min = 0.0; - max = 1.0; - defaultValue = 0.0; - - channel = -1; - - value = defaultValue; -} - -dePropertyValue::~dePropertyValue() -{ -} - -void dePropertyValue::set(deValue _value) -{ - value = _value; -} - -deValue dePropertyValue::get() const -{ - return value; -} - -void dePropertyValue::save(xmlNodePtr root) const -{ - saveChild(root, name, str(value)); -} - -void dePropertyValue::load(xmlNodePtr child) -{ - if ((!xmlStrcmp(child->name, BAD_CAST(name.c_str())))) - { - value = getValue(getContent(child)); - } -} - -deValue dePropertyValue::getMin() const -{ - return min; -} - -deValue dePropertyValue::getMax() const -{ - return max; -} - -deValue dePropertyValue::getDefault() const -{ - return defaultValue; -} - -void dePropertyValue::setMax(deValue _max) -{ - max = _max; -} - -void dePropertyValue::setMin(deValue _min) -{ - min = _min; -} - -void dePropertyValue::setChannel(int _channel) -{ - channel = _channel; -} diff -Nru delaboratory-0.7/src/property_value.h delaboratory-0.8/src/property_value.h --- delaboratory-0.7/src/property_value.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_value.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_VALUE_H -#define _DE_PROPERTY_VALUE_H - -#include "property.h" -#include "value.h" - -class dePropertyValue:public deProperty -{ - private: - deValue value; - - deValue min; - deValue max; - deValue defaultValue; - - int channel; - public: - dePropertyValue(const std::string& _name); - virtual ~dePropertyValue(); - - void set(deValue _value); - deValue get() const; - - virtual void save(xmlNodePtr root) const; - virtual void load(xmlNodePtr root); - - deValue getMin() const; - deValue getMax() const; - deValue getDefault() const; - - void setMin(deValue _min); - void setMax(deValue _max); - - void setChannel(int _channel); - int getChannel() const {return channel;}; -}; - -#endif diff -Nru delaboratory-0.7/src/property_value_slider.cc delaboratory-0.8/src/property_value_slider.cc --- delaboratory-0.7/src/property_value_slider.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_value_slider.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "property_value_slider.h" -#include "property_value.h" -#include "layer.h" -#include "layer_processor.h" - -dePropertyValueSlider::dePropertyValueSlider(wxWindow *parent, int _sliderRange, dePropertyValue& _property, deLayer& _layer, deLayerProcessor& _layerProcessor) -:deSlider(parent, _property.getLabel(), _sliderRange, _property.getMin(), _property.getMax(), _property.getDefault()), -property(_property), -layer(_layer), -layerProcessor(_layerProcessor) -{ - channel = property.getChannel(); - setFromProperty(); -} - -dePropertyValueSlider::~dePropertyValueSlider() -{ -} - -void dePropertyValueSlider::onValueChange(deValue value, bool finished) -{ - if ((finished) || (layerProcessor.isRealtime())) - { - property.set(value); - - int index = layer.getIndex(); - if (channel >= 0) - { - layerProcessor.markUpdateSingleChannel(index, channel); - } - else - { - layerProcessor.markUpdateAllChannels(index); - } - } -} - -void dePropertyValueSlider::setFromProperty() -{ - setValue(property.get()); -} - -/* -void dePropertyValueSlider::setChannel(int _channel) -{ - channel = _channel; -} -*/ diff -Nru delaboratory-0.7/src/property_value_slider.h delaboratory-0.8/src/property_value_slider.h --- delaboratory-0.7/src/property_value_slider.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/property_value_slider.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PROPERTY_VALUE_SLIDER_H -#define _DE_PROPERTY_VALUE_SLIDER_H - -#include "slider.h" -class deLayer; -class dePropertyValue; -class deLayerProcessor; - -class dePropertyValueSlider:public deSlider -{ - private: - dePropertyValue& property; - deLayer& layer; - deLayerProcessor& layerProcessor; - - int channel; - - public: - dePropertyValueSlider(wxWindow *parent, int _sliderRange, dePropertyValue& _property, deLayer& _layer, deLayerProcessor& _layerProcessor); - virtual ~dePropertyValueSlider(); - - virtual void onValueChange(deValue value, bool finished); - - void setFromProperty(); - -// void setChannel(int _index); -}; - -#endif diff -Nru delaboratory-0.7/src/raw_module.cc delaboratory-0.8/src/raw_module.cc --- delaboratory-0.7/src/raw_module.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/raw_module.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "raw_module.h" -#include "dcraw_support.h" -#include "image_io.h" -#include "str.h" -#include "logger.h" - -deRawModule::deRawModule() -:mutex(wxMUTEX_RECURSIVE) -{ - dcraw_version = ""; - loader = NULL; -} - -deRawModule::~deRawModule() -{ -} - -void deRawModule::onInit() -{ - dcraw_version = getDcrawVersion(); -} - -std::string deRawModule::getVersion() const -{ - return dcraw_version; -} - -bool deRawModule::loadRAW(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace, bool half) -{ - if (loader) - { - return false; - } - - bool status = false; - - lockWithLog(mutex, "raw module mutex"); - - loader = new deRawLoader(fileName, image, colorSpace, half); - - status = loader->getStatus(); - - mutex.Unlock(); - - return status; -} - -bool deRawModule::update(bool& failure) -{ - if (!loader) - { - return false; - } - - bool result = loader->load(failure); - - if ((result) || (failure)) - { - delete loader; - loader = NULL; - } - - return result; -} diff -Nru delaboratory-0.7/src/raw_module.h delaboratory-0.8/src/raw_module.h --- delaboratory-0.7/src/raw_module.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/raw_module.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_RAW_MODULE_H -#define _DE_RAW_MODULE_H - -#include -class deStaticImage; -#include "color_space.h" -#include "dcraw_support.h" - -class deRawModule -{ - private: - mutable wxMutex mutex; - - deRawLoader* loader; - - deRawModule(const deRawModule&); - deRawModule& operator =(const deRawModule&); - - std::string dcraw_version; - - public: - deRawModule(); - virtual ~deRawModule(); - - void onInit(); - - std::string getVersion() const; - bool loadRAW(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace, bool half); - - bool update(bool& failure); - - -}; - -#endif diff -Nru delaboratory-0.7/src/rendered_image.cc delaboratory-0.8/src/rendered_image.cc --- delaboratory-0.7/src/rendered_image.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/rendered_image.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "rendered_image.h" -#include "logger.h" -#include "str.h" -#include - -void deRenderedImage::setSize(const deSize& _size) -{ - requestedSize = _size; -} - -unsigned char* deRenderedImage::getCurrentImageData() -{ - if (requestedSize != size) - { - if (internalData) - { - delete [] internalData; - } - size = requestedSize; - int w = size.getW(); - int h = size.getH(); - internalData = new unsigned char [ 3 * w * h ]; - } - - return internalData; -} - - -deRenderedImage::deRenderedImage() -:size(0,0), -requestedSize(0,0), -bitmapSize(0,0) -{ - logMessage("create rendered image"); - renderedBitmap = NULL; - internalData = NULL; -} - -deRenderedImage::~deRenderedImage() -{ - logMessage("destroy rendered image"); - if (renderedBitmap) - { - delete renderedBitmap; - } - if (internalData) - { - delete [] internalData; - } -} - -bool deRenderedImage::render(wxDC& dc) -{ - if (!internalData) - { - logMessage("ERROR can't render - no internal data"); - return false; - } - - int w = size.getW(); - int h = size.getH(); - - if (bitmapSize != size) - { - if (renderedBitmap) - { - delete renderedBitmap; - } - renderedBitmap = new wxBitmap(w, h, 24); - bitmapSize = size; - } - - if (!renderedBitmap) - { - logMessage("ERROR can't render - no rendered bitmap"); - return false; - } - - wxNativePixelData bitmapData(*renderedBitmap); - if (!bitmapData) - { - logMessage("ERROR can't render - wxNativePixelData doesn't work"); - return false; - } - - wxNativePixelData::Iterator p(bitmapData); - - p.Offset(bitmapData, 0, 0); - - int x; - int y; - int pos = 0; - for (y = 0; y < h; y++) - { - wxNativePixelData::Iterator rowStart = p; - - for (x = 0; x < w; x++) - { - unsigned char r = internalData[pos]; - p.Red() = r; - pos++; - unsigned char g = internalData[pos]; - p.Green() = g; - pos++; - unsigned char b = internalData[pos]; - p.Blue() = b; - pos++; - p++; - } - - p = rowStart; - p.OffsetY(bitmapData, 1); - } - - dc.DrawBitmap(*renderedBitmap, 0, 0, false); - return true; -} diff -Nru delaboratory-0.7/src/rendered_image.h delaboratory-0.8/src/rendered_image.h --- delaboratory-0.7/src/rendered_image.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/rendered_image.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_RENDERED_IMAGE_H -#define _DE_RENDERED_IMAGE_H - -#include -#include "size.h" - -class deRenderedImage -{ - private: - wxBitmap* renderedBitmap; - unsigned char* internalData; - - deRenderedImage(const deRenderedImage& i); - deRenderedImage& operator = (const deRenderedImage& i); - - deSize size; - deSize requestedSize; - deSize bitmapSize; - - public: - deRenderedImage(); - - virtual ~deRenderedImage(); - - void setSize(const deSize& _size); - unsigned char* getCurrentImageData(); - unsigned char* getCurrentBitmapData(); - bool render(wxDC& dc); -}; - -#endif diff -Nru delaboratory-0.7/src/renderer.cc delaboratory-0.8/src/renderer.cc --- delaboratory-0.7/src/renderer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/renderer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,386 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "renderer.h" -#include -#include "project.h" -#include "image.h" -#include "layer.h" -#include -#include "conversion_functions.h" -#include "layer_processor.h" -#include "str.h" -#include "logger.h" -#include "channel_manager.h" -#include "layer_stack.h" - -bool renderImage(const deImage& image, unsigned char* data, deChannelManager& channelManager) -{ - deColorSpace colorSpace = image.getColorSpace(); - - deConversion3x3 conversion3x3 = getConversion3x3(colorSpace, deColorSpaceRGB); - deConversion4x3 conversion4x3 = NULL; - deConversion1x3 conversion1x3 = NULL; - if (!conversion3x3) - { - conversion4x3 = getConversion4x3(colorSpace, deColorSpaceRGB); - if (!conversion4x3) - { - conversion1x3 = getConversion1x3(colorSpace, deColorSpaceRGB); - if (!conversion1x3) - { - return false; - } - } - } - - const deSize& s = channelManager.getChannelSize(); - - deChannel* channel0 = channelManager.getChannel(image.getChannelIndex(0)); - deChannel* channel1 = channelManager.getChannel(image.getChannelIndex(1)); - deChannel* channel2 = channelManager.getChannel(image.getChannelIndex(2)); - deChannel* channel3 = channelManager.getChannel(image.getChannelIndex(3)); - - if (conversion4x3) - { - if (!channel0) - { - return false; - } - if (!channel1) - { - return false; - } - if (!channel2) - { - return false; - } - if (!channel3) - { - return false; - } - channel0->lockRead(); - channel1->lockRead(); - channel2->lockRead(); - channel3->lockRead(); - } - else if (conversion1x3) - { - if (!channel0) - { - return false; - } - channel0->lockRead(); - } - else - { - if (!channel0) - { - return false; - } - if (!channel1) - { - return false; - } - if (!channel2) - { - return false; - } - channel0->lockRead(); - channel1->lockRead(); - channel2->lockRead(); - } - - if (!channel0) - { - return false; - } - - deValue rr; - deValue gg; - deValue bb; - - int n = s.getN(); - int i; - int pos = 0; - - if (conversion4x3) - { - const deValue* p0 = channel0->getPixels(); - const deValue* p1 = channel1->getPixels(); - const deValue* p2 = channel2->getPixels(); - const deValue* p3 = channel3->getPixels(); - for (i = 0; i < n; i++) - { - deValue s0 = p0[i]; - deValue s1 = p1[i]; - deValue s2 = p2[i]; - deValue s3 = p3[i]; - conversion4x3(s0, s1, s2, s3, rr, gg, bb); - - unsigned char r = 255 * rr; - data[pos] = r; - pos++; - unsigned char g = 255 * gg; - data[pos] = g; - pos++; - unsigned char b = 255 * bb; - data[pos] = b; - pos++; - } - - channel0->unlockRead(); - channel1->unlockRead(); - channel2->unlockRead(); - channel3->unlockRead(); - - } - else if (conversion1x3) - { - const deValue* p0 = channel0->getPixels(); - for (i = 0; i < n; i++) - { - deValue s0 = p0[i]; - conversion1x3(s0, rr, gg, bb); - - unsigned char r = 255 * rr; - data[pos] = r; - pos++; - unsigned char g = 255 * gg; - data[pos] = g; - pos++; - unsigned char b = 255 * bb; - data[pos] = b; - pos++; - } - channel0->unlockRead(); - } - else - { - const deValue* p0 = channel0->getPixels(); - const deValue* p1 = channel1->getPixels(); - const deValue* p2 = channel2->getPixels(); - for (i = 0; i < n; i++) - { - - deValue s1 = p0[i]; - deValue s2 = p1[i]; - deValue s3 = p2[i]; - conversion3x3(s1, s2, s3, rr, gg, bb); - - unsigned char r = 255 * rr; - data[pos] = r; - pos++; - unsigned char g = 255 * gg; - data[pos] = g; - pos++; - unsigned char b = 255 * bb; - data[pos] = b; - pos++; - - } - channel0->unlockRead(); - channel1->unlockRead(); - channel2->unlockRead(); - } - - return true; - -} - -void renderChannel(const deImage& image, int c, unsigned char* data, deChannelManager& channelManager) -{ - const deSize& s = channelManager.getChannelSize(); - - deChannel* channel = channelManager.getChannel(image.getChannelIndex(c)); - - if (!channel) - { - return; - } - - channel->lockRead(); - - const deValue* pixels = channel->getPixels(); - - int n = s.getN(); - int i; - int pos = 0; - for (i = 0; i < n; i++) - { - deValue s = pixels[i]; - - unsigned char ss = 255 * s; - - data[pos] = ss; - pos++; - data[pos] = ss; - pos++; - data[pos] = ss; - pos++; - } - - channel->unlockRead(); - -} - -void renderChannel(int c, unsigned char* data, deChannelManager& channelManager) -{ - const deSize& s = channelManager.getChannelSize(); - - deChannel* channel = channelManager.getChannel(c); - - if (!channel) - { - return; - } - - channel->lockRead(); - - const deValue* pixels = channel->getPixels(); - - int n = s.getN(); - int i; - int pos = 0; - for (i = 0; i < n; i++) - { - deValue s = pixels[i]; - - unsigned char ss = 255 * s; - - data[pos] = ss; - pos++; - data[pos] = ss; - pos++; - data[pos] = ss; - pos++; - } - - channel->unlockRead(); - -} - -deRenderer::deRenderer(deChannelManager& _channelManager) -:size(0,0), - channelManager(_channelManager), - mutex(wxMUTEX_RECURSIVE) -{ -} - -deRenderer::~deRenderer() -{ -} - -bool deRenderer::prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack) -{ - const deSize& s = channelManager.getChannelSize(); - - if ((s.getW() == 0) || (s.getH() == 0)) - { - return false; - } - - lockWithLog(mutex, "renderer mutex"); - - int viewV = viewManager.getView(); - int view = layerProcessor.getLastValidLayer(); - if (view > viewV) - { -// std::cout << "WARNING view was " << view << " while viewV was " << viewV << std::endl; - view = viewV; - } - - if (view < 0) - { - mutex.Unlock(); - return false; - } - - if (viewManager.maskVisible()) - { - renderChannel(viewManager.getMaskChannel(), getCurrentImageData(), channelManager); - - } - else - { - logMessage("renderer getLayer " +str(view)); - deLayer* layer = layerStack.getLayer(view); - if (!layer) - { - logMessage("ERROR no layer"); - logMessage("unlock renderer mutex"); - mutex.Unlock(); - return false; - } - logMessage("renderer lock layer " +str(view)); - - layer->lockLayer(); - - logMessage("renderer get image from layer " +str(view)); - - const deImage& layerImage = layer->getImage(); - - logMessage("renderer before renderer"); - - if (viewManager.isSingleChannel()) - { - renderChannel(layerImage, viewManager.getChannel(), getCurrentImageData(), channelManager); - } - else - { - if (!renderImage(layerImage, getCurrentImageData(), channelManager)) - { - std::cout << "failed renderImage" << std::endl; - logMessage("render image FAILED"); - } - } - - logMessage("renderer unlock layer " +str(view)); - - layer->unlockLayer(); - } - - logMessage("unlock renderer mutex"); - mutex.Unlock(); - - return true; -} - -bool deRenderer::render(wxDC& dc) -{ - lockWithLog(mutex, "renderer mutex"); - - bool result = renderedImage.render(dc); - - if (!result) - { - dc.Clear(); - } - - logMessage("unlock renderer mutex"); - mutex.Unlock(); - - return result; -} - -unsigned char* deRenderer::getCurrentImageData() -{ - const deSize& s = channelManager.getChannelSize(); - renderedImage.setSize(s); - return renderedImage.getCurrentImageData(); -} diff -Nru delaboratory-0.7/src/renderer.h delaboratory-0.8/src/renderer.h --- delaboratory-0.7/src/renderer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/renderer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_RENDERER_H -#define _DE_RENDERER_H - -class wxDC; -class deChannelManager; -class deViewManager; -class deLayerProcessor; -class deLayerStack; -#include -#include "size.h" -#include "rendered_image.h" - -class deRenderer -{ - private: - deRenderedImage renderedImage; - deSize size; - deChannelManager& channelManager; - wxMutex mutex; - - unsigned char* getCurrentImageData(); - - public: - deRenderer(deChannelManager& _channelManager); - virtual ~deRenderer(); - - bool render(wxDC& dc); - bool prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack); -}; - -#endif diff -Nru delaboratory-0.7/src/rgb2xyz2lab.cc delaboratory-0.8/src/rgb2xyz2lab.cc --- delaboratory-0.7/src/rgb2xyz2lab.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/rgb2xyz2lab.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,421 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "power.h" -#include "rgb2xyz2lab.h" -#include -#include -#include - -//const deValue lch_hue_shift = 1.0/8.0; -const deValue lch_hue_shift = 0; - -/* almost same for conversion */ -static const deValue Xn = 0.951; -static const deValue Yn = 1.0; -static const deValue Zn = 1.089; - -/* consts for conversion */ -static const deValue c6_29 = 6.0 / 29.0; -static const deValue c29_6 = 29.0 / 6.0; -static const deValue c6_29_2 = c6_29 * c6_29; -static const deValue c6_29_3 = c6_29 * c6_29 * c6_29; -static const deValue c29_6_2 = c29_6 * c29_6; -static const deValue c4_29 = 4.0 / 29.0; - -void rgb2xyz(deValue r, deValue g, deValue b, deValue &x, deValue &y, deValue& z) -{ - assert(r >= 0); - assert(g >= 0); - assert(b >= 0); - assert(r <= 1); - assert(g <= 1); - assert(b <= 1); - x = 0.4124 * r + 0.3576 * g + 0.1805 * b; - y = 0.2126 * r + 0.7152 * g + 0.0722 * b; - z = 0.0193 * r + 0.1192 * g + 0.9505 * b; - -/* - assert(x >= 0); - assert(y >= 0); - assert(z >= 0); - assert(x <= 1); - assert(y <= 1); - assert(z <= 1); - */ -} - -void xyz2rgb(deValue x, deValue y, deValue z, deValue &r, deValue &g, deValue& b) -{ - r = 3.2410 * x - 1.5374 * y - 0.4986 * z; - g = -0.9692 * x + 1.8760 * y + 0.0416 * z; - b = 0.0556 * x - 0.2040 * y + 1.0570 * z; - - if (r < 0) - { - r = 0; - } - else if (r > 1) - { - r = 1; - } - if (g < 0) - { - g = 0; - } - else if (g > 1) - { - g = 1; - } - if (b < 0) - { - b = 0; - } - else if (b > 1) - { - b = 1; - } -} - -void rgb2prophoto(deValue r, deValue g, deValue b, deValue &pr, deValue &pg, deValue& pb) -{ - /* - from dcraw - - octave:1> x = [0.529317, 0.330092, 0.140588; 0.098368, 0.873465, 0.028169; 0.016879, 0.117663, 0.865457] - x = - - 0.529317 0.330092 0.140588 - 0.098368 0.873465 0.028169 - 0.016879 0.117663 0.865457 - - */ - - - pr = 0.529317 * r + 0.330092 * g + 0.140588 * b; - pg = 0.098368 * r + 0.873465 * g + 0.028169 * b; - pb = 0.016879 * r + 0.117663 * g + 0.865457 * b; - -} - -void prophoto2rgb(deValue pr, deValue pg, deValue pb, deValue &r, deValue &g, deValue& b) -{ - - /* - invert matrix from dcraw - - octave:2> inv(x) - ans = - - 2.0341926 -0.7274198 -0.3067655 - -0.2288108 1.2317292 -0.0029216 - -0.0085649 -0.1532726 1.1618390 - - */ - - r = 2.0341926 * pr -0.7274198 * pg -0.3067655 * pb; - g = -0.2288108 * pr + 1.2317292 * pg -0.0029216 * pb; - b = -0.0085649 * pr -0.1532726 * pg + 1.1618390 * pb; - - if (r < 0) - { - r = 0; - } - else if (r > 1) - { - r = 1; - } - if (g < 0) - { - g = 0; - } - else if (g > 1) - { - g = 1; - } - if (b < 0) - { - b = 0; - } - else if (b > 1) - { - b = 1; - } - -} - -void prophoto2xyz(deValue pr, deValue pg, deValue pb, deValue &x, deValue &y, deValue& z) -{ - - /* - - octave:7> z - z = - - 2.0341926 -0.7274198 -0.3067655 - -0.2288108 1.2317292 -0.0029216 - -0.0085649 -0.1532726 1.1618390 - - octave:8> y - y = - - 0.412400 0.357600 0.180500 - 0.212600 0.715200 0.072200 - 0.019300 0.119200 0.950500 - - octave:10> y * z - ans = - - 0.7555323 0.1128127 0.0821571 - 0.2682055 0.7152170 0.0165769 - 0.0038447 -0.0129027 1.0980591 - - */ - - x = 0.7555323 * pr + 0.1128127* pg + 0.0821571* pb; - y = 0.2682055 * pr + 0.7152170* pg + 0.0165769* pb; - z = 0.0038447 * pr -0.0129027 * pg + 1.0980591* pb; - -} - -void xyz2prophoto(deValue x, deValue y, deValue z, deValue &pr, deValue &pg, deValue& pb) -{ - /* - - x = [0.7555323, 0.1128127, 0.0821571; 0.2682055, 0.7152170, 0.0165769; 0.0038447, -0.0129027, 1.0980591] - - octave:2> inv(x) - ans = - - 1.403314 -0.223181 -0.101627 - -0.525984 1.481448 0.016990 - -0.011094 0.018189 0.911253 - - */ - - - pr = 1.403314* x -0.223181* y -0.101627* z; - pg = -0.525984* x + 1.481448* y + 0.016990* z; - pb = -0.011094* x + 0.018189* y + 0.911253* z; - -} - -void lab2lch(deValue l, deValue a, deValue b, deValue &_l, deValue &_c, deValue& _h) -{ - _l = l; - - a = ( a - 0.5) * 200.0; - b = ( b - 0.5) * 200.0; - - _c = sqrt(a * a + b * b); - _h = atan2(b, a); - - _c = _c / 100.0; - _h = (_h / ( 2 * M_PI )) - lch_hue_shift; - - if (_h < 0) - { - _h += 1; - } - - if ( _c > 1) - { - _c = 1; - } - - assert(_c >= 0.0); - assert(_c <= 1.0); - assert(_h >= 0.0); - assert(_h <= 1.0); - -} - -void lch2lab(deValue l, deValue c, deValue h, deValue &_l, deValue &_a, deValue& _b) -{ - _l = l; - - c = c * 100.0; - h = (h + lch_hue_shift) * (2 * M_PI); - - _a = c * cos(h); - _b = c * sin(h); - - _a = _a / 200.0 + 0.5; - _b = _b / 200.0 + 0.5; - - assert(_a >= 0.0); - assert(_a <= 1.0); - assert(_b >= 0.0); - assert(_b <= 1.0); -} - - -void xyz2lab(deValue x, deValue y, deValue z, deValue &l, deValue &a, deValue& b) -{ - static dePower power(1.0 / 3.0, 2); - - deValue xx = x / Xn; - deValue yy = y / Yn; - deValue zz = z / Zn; - - deValue fx; - deValue fy; - deValue fz; - - if (xx > c6_29_3) - { - fx = power.get(xx); - } - else - { - fx = 1.0 / 3.0 * c29_6_2 * xx + c4_29; - } - - if (yy > c6_29_3) - { - fy = power.get(yy); - } - else - { - fy = 1.0 / 3.0 * c29_6_2 * yy + c4_29; - } - - if (zz > c6_29_3) - { - fz = power.get(zz); - } - else - { - fz = 1.0 / 3.0 * c29_6_2 * zz + c4_29; - } - - l = 116.0 * fy - 16.0; - a = 500.0 * (fx - fy); - b = 200.0 * (fy - fz); - - l /= 100.0; - a += 100.0; - b += 100.0; - a /= 200.0; - b /= 200.0; - - if (l < 0) - { - l = 0; - } - - if (a < 0) - { - a = 0; - } - if (b < 0) - { - b = 0; - } - -/* - assert(l >= 0); - assert(a >= 0); - assert(b >= 0); - assert(l <= 1); - assert(a <= 1); - assert(b <= 1); - */ -} - -void lab2xyz(deValue l, deValue a, deValue b, deValue &x, deValue &y, deValue& z) -{ -/* - assert( l >= 0); - assert( l <= 1); - assert( a >= 0); - assert( a <= 1); - assert( b >= 0); - assert( b <= 1); - */ - - l *= 100.0; - a *= 200.0; - b *= 200.0; - a -= 100.0; - b -= 100.0; - - deValue ll = (l + 16.0) / 116.0; - deValue ll_aa = ll + a / 500.0; - deValue ll_bb = ll - b / 200.0; - - deValue ffx; - deValue ffy; - deValue ffz; - - if (ll > c6_29) - { - ffy = ll * ll * ll; - } - else - { - ffy = 3.0 * c6_29_2 * (ll - c4_29); - } - - if (ll_aa > c6_29) - { - ffx = ll_aa * ll_aa * ll_aa; - } - else - { - ffx = 3.0 * c6_29_2 * (ll_aa - c4_29); - } - - if (ll_bb > c6_29) - { - ffz = ll_bb * ll_bb * ll_bb; - } - else - { - ffz = 3.0 * c6_29_2 * (ll_bb - c4_29); - } - - x = Xn * ffx; - y = Yn * ffy; - z = Zn * ffz; - -/* - assert(x >= 0); - assert(y >= 0); - assert(z >= 0); - assert(x <= 1); - assert(y <= 1); - assert(z <= 1); - */ - -} - -void initLAB() -{ - /* this code just calls LAB conversion to create dePower function - calling this is not important for functionality but will affect benchmarks */ - - deValue x = 0.4; - deValue y = 0.4; - deValue z = 0.4; - deValue l; - deValue a; - deValue b; - xyz2lab(x, y, z, l, a, b); - -} diff -Nru delaboratory-0.7/src/rgb2xyz2lab.h delaboratory-0.8/src/rgb2xyz2lab.h --- delaboratory-0.7/src/rgb2xyz2lab.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/rgb2xyz2lab.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_RGB_2_XYZ_2_LAB_H -#define _DE_RGB_2_XYZ_2_LAB_H - -#include "value.h" - -void rgb2xyz(deValue r, deValue g, deValue b, deValue &x, deValue &y, deValue& z); -void xyz2rgb(deValue x, deValue y, deValue z, deValue &r, deValue &g, deValue& b); -void xyz2lab(deValue x, deValue y, deValue z, deValue &l, deValue &a, deValue& b); -void lab2xyz(deValue l, deValue a, deValue b, deValue &x, deValue &y, deValue& z); -void lab2lch(deValue l, deValue a, deValue b, deValue &_l, deValue &_c, deValue& _h); -void lch2lab(deValue l, deValue c, deValue h, deValue &_l, deValue &_a, deValue& _b); - -void rgb2prophoto(deValue r, deValue g, deValue b, deValue &pr, deValue &pg, deValue& pb); -void prophoto2rgb(deValue pr, deValue pg, deValue pb, deValue &r, deValue &g, deValue& b); - -void prophoto2xyz(deValue pr, deValue pg, deValue pb, deValue &x, deValue &y, deValue& z); -void xyz2prophoto(deValue x, deValue y, deValue z, deValue &pr, deValue &pg, deValue& pb); - -/* for benchmarks only */ -void initLAB(); - - -#endif diff -Nru delaboratory-0.7/src/sampler.cc delaboratory-0.8/src/sampler.cc --- delaboratory-0.7/src/sampler.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "sampler.h" - -deSampler::deSampler() -{ - x = -1; - y = -1; - colorSpace = deColorSpaceCMYK; - enabled = false; - selected = false; -} - -deSampler::~deSampler() -{ -} - -void deSampler::setPosition(deValue _x, deValue _y) -{ - x = _x; - y = _y; -} - -void deSampler::setColorSpace(deColorSpace c) -{ - colorSpace = c; -} - -bool deSampler::isEnabled() const -{ - return enabled; -} - -void deSampler::enable() -{ - enabled = true; -} - -void deSampler::disable() -{ - enabled = false; -} - -bool deSampler::isSelected() const -{ - return selected; -} - -void deSampler::setSelected(bool s) -{ - selected = s; -} diff -Nru delaboratory-0.7/src/sampler.h delaboratory-0.8/src/sampler.h --- delaboratory-0.7/src/sampler.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SAMPLER_H -#define _DE_SAMPLER_H - -#include "color_space.h" - -class deSampler -{ - private: - deValue x; - deValue y; - deColorSpace colorSpace; - bool enabled; - bool selected; - - public: - deSampler(); - virtual ~deSampler(); - - deValue getX() const {return x;}; - deValue getY() const {return y;}; - - void setPosition(deValue _x, deValue _y); - - deColorSpace getColorSpace() const {return colorSpace;}; - void setColorSpace(deColorSpace c); - - bool isEnabled() const; - void enable(); - void disable(); - - bool isSelected() const; - void setSelected(bool s); - -}; - -#endif diff -Nru delaboratory-0.7/src/sampler_manager.cc delaboratory-0.8/src/sampler_manager.cc --- delaboratory-0.7/src/sampler_manager.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler_manager.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "sampler_manager.h" -#include "layer_processor.h" - -deSamplerManager::deSamplerManager() -{ - size = 5; - - int i; - for (i = 0; i < size; i++) - { - deSampler s; - samplers.push_back(s); - } - - selected = -1; - moving = false; -} - -deSamplerManager::~deSamplerManager() -{ -} - - -deSampler* deSamplerManager::getSampler(int index) -{ - if ((index < 0) || ((unsigned int)index >= samplers.size())) - { - return NULL; - } - - return &(samplers[index]); -} - -bool deSamplerManager::select(deValue x, deValue y) -{ - int i; - - for (i = 0; i < size; i++) - { - deSampler& s = samplers[i]; - s.setSelected(false); - } - - for (i = 0; i < size; i++) - { - deSampler& s = samplers[i]; - if (s.isEnabled()) - { - deValue dx = s.getX() - x; - deValue dy = s.getY() - y; - deValue r = sqrt(dx*dx + dy*dy); - - if (r < 0.01) - { - selected = i; - s.setSelected(true); - return true; - } - } - } - - for (i = 0; i < size; i++) - { - deSampler& s = samplers[i]; - if (!s.isEnabled()) - { - s.enable(); - selected = i; - s.setSelected(true); - return true; - } - } - - return false; -} - -bool deSamplerManager::onClick(deValue x, deValue y) -{ - if (!moving) - { - return false; - } - - if (select(x,y)) - { - deSampler& s = samplers[selected]; - s.setPosition(x, y); - - return true; - } - - return false; - -} - -bool deSamplerManager::onMove(deValue x, deValue y) -{ - if (!moving) - { - return false; - } - - if (selected >= 0) - { - deSampler& s = samplers[selected]; - - if ((x < -0.01) || (y < -0.01) || (x>1.01) || (y>1.01)) - { - s.disable(); - selected = -1; - s.setSelected(false); - } - else - { - s.setPosition(x, y); - } - - return true; - } - - return false; -} - -bool deSamplerManager::onRelease() -{ - int i; - - for (i = 0; i < size; i++) - { - deSampler& s = samplers[i]; - s.setSelected(false); - } - - selected = -1; - - return true; -} - -void deSamplerManager::setMoving(bool m) -{ - moving = m; -} - -bool deSamplerManager::getMoving() const -{ - return moving; -} diff -Nru delaboratory-0.7/src/sampler_manager.h delaboratory-0.8/src/sampler_manager.h --- delaboratory-0.7/src/sampler_manager.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler_manager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SAMPLER_MANAGER_H -#define _DE_SAMPLER_MANAGER_H - -#include "sampler.h" -#include - -class deSamplerManager -{ - private: - std::vector samplers; - - int selected; - int size; - - bool moving; - - bool select(deValue x, deValue y); - - deSamplerManager(const deSamplerManager&); - deSamplerManager& operator =(const deSamplerManager&); - - public: - deSamplerManager(); - virtual ~deSamplerManager(); - - int getNumberOfSamplers() const {return samplers.size();}; - deSampler* getSampler(int index); - - bool onClick(deValue x, deValue y); - bool onMove(deValue x, deValue y); - bool onRelease(); - - int getSelected() const {return selected;}; - - void setMoving(bool m); - - bool getMoving() const; -}; - -#endif diff -Nru delaboratory-0.7/src/sampler_panel.cc delaboratory-0.8/src/sampler_panel.cc --- delaboratory-0.7/src/sampler_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "sampler_panel.h" -#include "sampler.h" -#include "project.h" -#include "layer.h" -#include "convert_pixel.h" -#include "image.h" -#include -#include "channel_manager.h" -#include "layer_stack.h" - -deSamplerPanel::deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project) -:wxPanel(parent, wxID_ANY, wxDefaultPosition), sampler(_sampler), project(_project) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - int valueWidth = 70; - - getSupportedColorSpaces(colorSpaces); - - wxSizer* sizerT = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(sizerT); - - wxString* colorSpaceStrings = new wxString [colorSpaces.size()]; - unsigned int i; - for (i = 0; i < colorSpaces.size(); i++) - { - colorSpaceStrings[i] = wxString::FromAscii(getColorSpaceName(colorSpaces[i]).c_str()); - } - - colorSpaceChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, colorSpaces.size(), colorSpaceStrings); - sizerT->Add(colorSpaceChoice); - - colorPanel = new deColorPanel(this, wxSize(60, 25), NULL, 0); - sizerT->Add(colorPanel, 0, wxALIGN_CENTER); - - sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerS); - - v1 = new wxStaticText(this, wxID_ANY, _T("v1"), wxDefaultPosition, wxSize(valueWidth, -1)); - sizerS->Add(v1); - v2 = new wxStaticText(this, wxID_ANY, _T("v2"), wxDefaultPosition, wxSize(valueWidth, -1)); - sizerS->Add(v2); - v3 = new wxStaticText(this, wxID_ANY, _T("v3"), wxDefaultPosition, wxSize(valueWidth, -1)); - sizerS->Add(v3); - v4 = new wxStaticText(this, wxID_ANY, _T("v4"), wxDefaultPosition, wxSize(valueWidth, -1)); - sizerS->Add(v4); - - delete [] colorSpaceStrings; - - setChoice(); - - Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deSamplerPanel::choose)); - -} - -deSamplerPanel::~deSamplerPanel() -{ -} - -void deSamplerPanel::setChoice() -{ - deColorSpace colorSpace = sampler.getColorSpace(); - unsigned int i; - for (i = 0; i != colorSpaces.size(); i++) - { - if (colorSpaces[i] == colorSpace) - { - colorSpaceChoice->SetSelection(i); - } - } -} - -void deSamplerPanel::update() -{ - if (sampler.isEnabled()) - { - colorSpaceChoice->Enable(); - v1->Enable(); - v2->Enable(); - v3->Enable(); - v4->Enable(); - } - else - { - v1->Disable(); - v2->Disable(); - v3->Disable(); - v4->Disable(); - colorSpaceChoice->Disable(); - } - - int g = 240; - - if (sampler.isSelected()) - { - g = 200; - } - - sizerS->GetStaticBox()->SetBackgroundColour(wxColour(g, g, g)); - - const deViewManager& viewManager = project.getViewManager(); - int view = viewManager.getView(); - - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(view); - - if (!layer) - { - return; - } - - const deImage& image = layer->getImage(); - - deChannelManager& channelManager = project.getPreviewChannelManager(); - deSize channelSize = channelManager.getChannelSize(); - - deValue x = sampler.getX(); - deValue y = sampler.getY(); - - if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) - { - int xx = channelSize.getW() * x; - int yy = channelSize.getH() * y; - int p = channelSize.getW() * yy + xx; - - deColorSpace colorSpace = sampler.getColorSpace(); - int n = getColorSpaceSize(colorSpace); - - switch (n) - { - case 1: - { - v1->Show(); - v2->Hide(); - v3->Hide(); - v4->Hide(); - break; - } - case 3: - { - v1->Show(); - v2->Show(); - v3->Show(); - v4->Hide(); - break; - } - case 4: - { - v1->Show(); - v2->Show(); - v3->Show(); - v4->Show(); - break; - } - } - - deValue vv1; - deValue vv2; - deValue vv3; - deValue vv4; - - deValue rr; - deValue gg; - deValue bb; - - image.lockRead(); - - convertPixel(image, p, deColorSpaceRGB, rr, gg, bb, vv4); - convertPixel(image, p, colorSpace, vv1, vv2, vv3, vv4); - - colorPanel->setRGB(rr, gg, bb); - - image.unlockRead(); - - std::ostringstream oss; - oss.setf(std::ios_base::fixed); - oss.precision(3); - - { - oss.str(""); - oss << getPresentationValue(colorSpace, 0, vv1); - v1->SetLabel(wxString::FromAscii(oss.str().c_str())); - } - { - oss.str(""); - oss << getPresentationValue(colorSpace, 1, vv2); - v2->SetLabel(wxString::FromAscii(oss.str().c_str())); - } - { - oss.str(""); - oss << getPresentationValue(colorSpace, 2, vv3); - v3->SetLabel(wxString::FromAscii(oss.str().c_str())); - } - { - oss.str(""); - oss << getPresentationValue(colorSpace, 3, vv4); - v4->SetLabel(wxString::FromAscii(oss.str().c_str())); - } - } - -} - -void deSamplerPanel::choose(wxCommandEvent &event) -{ - int c = colorSpaceChoice->GetSelection(); - deColorSpace colorSpace = colorSpaces[c]; - sampler.setColorSpace(colorSpace); - update(); -} - diff -Nru delaboratory-0.7/src/sampler_panel.h delaboratory-0.8/src/sampler_panel.h --- delaboratory-0.7/src/sampler_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/sampler_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SAMPLER_PANEL_H -#define _DE_SAMPLER_PANEL_H - -#include "wx/wx.h" -#include -#include "color_space.h" -#include "gradient_panel.h" -class deSampler; -class deProject; - -class deSamplerPanel:public wxPanel -{ -private: - deSampler& sampler; - deProject& project; - - wxChoice* colorSpaceChoice; -// wxPanel* colorPanel; - deColorPanel* colorPanel; - wxStaticText* v1; - wxStaticText* v2; - wxStaticText* v3; - wxStaticText* v4; - - wxStaticBoxSizer* sizerS; - - std::vector colorSpaces; - - void choose(wxCommandEvent &event); - -public: - deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project); - virtual ~deSamplerPanel(); - - void update(); - void setChoice(); - -}; - -#endif diff -Nru delaboratory-0.7/src/samplers_panel.cc delaboratory-0.8/src/samplers_panel.cc --- delaboratory-0.7/src/samplers_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/samplers_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "samplers_panel.h" -#include "sampler_panel.h" -#include "project.h" -#include "layer_processor.h" - -deSamplersPanel::deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager) -:wxPanel(parent, wxID_ANY, wxDefaultPosition), project(_project), samplerManager(_samplerManager) -{ - unsigned int n = samplerManager.getNumberOfSamplers(); - - unsigned int i; - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - show = new wxCheckBox(this, wxID_ANY, _T("show samplers")); - show->SetValue(0); - sizer->Add(show); - - for (i = 0; i < n; i++) - { - deSampler* sampler = samplerManager.getSampler(i); - - if (sampler) - { - deSamplerPanel* panel = new deSamplerPanel(this, *sampler, project); - sizer->Add(panel); - panels.push_back(panel); - } - } - - Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deSamplersPanel::check)); - -} - -deSamplersPanel::~deSamplersPanel() -{ -} - -void deSamplersPanel::update() -{ - std::list::iterator i; - for (i = panels.begin(); i != panels.end(); i++) - { - (*i)->update(); - } -} - -void deSamplersPanel::check(wxCommandEvent &event) -{ - bool checked = show->IsChecked(); - samplerManager.setMoving(checked); - project.getLayerProcessor().onGUIUpdate(); -} diff -Nru delaboratory-0.7/src/samplers_panel.h delaboratory-0.8/src/samplers_panel.h --- delaboratory-0.7/src/samplers_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/samplers_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SAMPLERS_PANEL_H -#define _DE_SAMPLERS_PANEL_H - -#include "wx/wx.h" -class deProject; -class deSamplerPanel; -class deSamplerManager; -#include - -class deSamplersPanel:public wxPanel -{ -private: - deProject& project; - std::list panels; - wxCheckBox* show; - deSamplerManager& samplerManager; - - void check(wxCommandEvent &event); - -public: - deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager); - virtual ~deSamplersPanel(); - - void update(); - -}; - -#endif diff -Nru delaboratory-0.7/src/scale_channel.cc delaboratory-0.8/src/scale_channel.cc --- delaboratory-0.7/src/scale_channel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/scale_channel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "scale_channel.h" -#include "channel.h" -#include -#include - -void scaleChannel(deValue* src, deValue* dst, int x1, int y1, int x2, int y2, int w, int h, int ws) -{ - if (w <= 0) - { - return; - } - if (h <= 0) - { - return; - } - - deValue ww = x2 - x1; - deValue scaleW = ww / w; - - deValue hh = y2 - y1; - deValue scaleH = hh / h; - - int x; - for (x = 0; x < w; x++) - { - int y; - - int xx1 = x1 + scaleW * x; - int xx2 = x1 + scaleW * (x + 1); - if (xx2 >= x2) - { - xx2 = x2 - 1; - } - - for (y = 0; y < h; y++) - { - int yy1 = y1 + scaleH * y; - int yy2 = y1 + scaleH * (y + 1); - if (yy2 >= y2) - { - yy2 = y2 - 1; - } - - deValue value = 0.0; - int n = 0; - - int x0; - int y0; - - for (x0 = xx1; x0 <= xx2; x0++) - { - for (y0 = yy1; y0 <= yy2; y0++) - { - value += src[x0 + y0 * ws]; - n++; - } - } - - if (n > 0) - { - deValue v = value / n; - dst[y*w+x] = v; - } - } - - } - - - -} diff -Nru delaboratory-0.7/src/scale_channel.h delaboratory-0.8/src/scale_channel.h --- delaboratory-0.7/src/scale_channel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/scale_channel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SCALE_CHANNEL_H -#define _DE_SCALE_CHANNEL_H - -#include "size.h" -#include "value.h" - -void scaleChannel(deValue* src, deValue* dst, int x1, int y1, int x2, int y2, int w, int h, int ws); - -#endif diff -Nru delaboratory-0.7/src/shadows_highlights_frame.cc delaboratory-0.8/src/shadows_highlights_frame.cc --- delaboratory-0.7/src/shadows_highlights_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/shadows_highlights_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "shadows_highlights_frame.h" -#include "shadows_highlights_layer.h" -#include -#include "property_value_slider.h" - -deShadowsHighlightsFrame::deShadowsHighlightsFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deShadowsHighlightsLayer& shLayer = dynamic_cast(_layer); - - int range = 400; - - int n = shLayer.getNumberOfValueProperties(); - - int i; - - for (i = 0; i < n; i++) - { - dePropertyValue* p = shLayer.getPropertyValue(i); - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, shLayer, layerProcessor); - valueSliders.push_back(s); - sizer->Add(s); - } - } - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deShadowsHighlightsFrame::click)); -} - -deShadowsHighlightsFrame::~deShadowsHighlightsFrame() -{ -} - -void deShadowsHighlightsFrame::click(wxCommandEvent &event) -{ -} diff -Nru delaboratory-0.7/src/shadows_highlights_frame.h delaboratory-0.8/src/shadows_highlights_frame.h --- delaboratory-0.7/src/shadows_highlights_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/shadows_highlights_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SHADOWS_HIGHLIGHTS_FRAME_H -#define _DE_SHADOWS_HIGHLIGHTS_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include - -class dePropertyValueSlider; -class deLayerProcessor; - -class deShadowsHighlightsFrame:public deActionFrame -{ - private: - std::vector valueSliders; - - deLayerProcessor& layerProcessor; - - void click(wxCommandEvent &event); - - public: - deShadowsHighlightsFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deShadowsHighlightsFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/shadows_highlights_layer.cc delaboratory-0.8/src/shadows_highlights_layer.cc --- delaboratory-0.7/src/shadows_highlights_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/shadows_highlights_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "shadows_highlights_layer.h" -#include "project.h" -#include -#include "blur.h" -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "copy_channel.h" -#include "blend_channel.h" -#include "process_linear.h" -#include "layer_processor.h" - -deShadowsHighlightsLayer::deShadowsHighlightsLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - blurRadiusIndex = registerPropertyValue("blur_radius"); - shadowsHighlightsAmountIndex = registerPropertyValue("shadows_highlights_amount"); - darkenAmountIndex = registerPropertyValue("darken_amount"); - lightenAmountIndex = registerPropertyValue("lighten_amount"); - - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - dePropertyValue* shadowsHighlightsAmount = valueProperties[shadowsHighlightsAmountIndex]; - dePropertyValue* darkenAmount = valueProperties[darkenAmountIndex]; - dePropertyValue* lightenAmount = valueProperties[lightenAmountIndex]; - - blurRadius->setLabel("radius"); - blurRadius->setMin(1); - blurRadius->setMax(50); - - shadowsHighlightsAmount->setLabel("sh/hi"); - - darkenAmount->setLabel("darken"); - lightenAmount->setLabel("lighten"); - - reset(); - - disableNotLuminance(); -} - -void deShadowsHighlightsLayer::reset() -{ - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - dePropertyValue* shadowsHighlightsAmount = valueProperties[shadowsHighlightsAmountIndex]; - dePropertyValue* darkenAmount = valueProperties[darkenAmountIndex]; - dePropertyValue* lightenAmount = valueProperties[lightenAmountIndex]; - - blurRadius->set(5); - shadowsHighlightsAmount->set(0.3); - darkenAmount->set(0.0); - lightenAmount->set(0.0); -} - -deShadowsHighlightsLayer::~deShadowsHighlightsLayer() -{ -} - -bool deShadowsHighlightsLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("shadows/highlights start"); - - const deValue* source = sourceChannel.getPixels(); - deValue* destination = channel.getPixels(); - - deValue* blurMap = NULL; - deValue* firstStage = NULL; - deValue* secondStage = NULL; - - try - { - blurMap = new deValue [size.getN()]; - firstStage = new deValue [size.getN()]; - secondStage = new deValue [size.getN()]; - } - catch (std::bad_alloc) - { - logMessage("ERROR allocating memory in shadows/highlights"); - if (blurMap) - { - delete [] blurMap; - } - if (firstStage) - { - delete [] firstStage; - } - if (secondStage) - { - delete [] secondStage; - } - return false; - } - - dePropertyValue* blurRadius = valueProperties[blurRadiusIndex]; - dePropertyValue* shadowsHighlightsAmount = valueProperties[shadowsHighlightsAmountIndex]; - dePropertyValue* darkenAmount = valueProperties[darkenAmountIndex]; - dePropertyValue* lightenAmount = valueProperties[lightenAmountIndex]; - - deValue r = viewManager.getRealScale() * blurRadius->get(); - deBlurType type = deGaussianBlur; - bool result = blurChannel(source, blurMap, size, r, r, type, 0.0); - - deValue sha = shadowsHighlightsAmount->get(); - blendChannel(source, blurMap, firstStage, NULL, deBlendOverlayInvert, sha, size.getN()); - - deValue da = darkenAmount->get(); - blendChannel(firstStage, source, secondStage, NULL, deBlendDarken, da, size.getN()); - - deValue la = lightenAmount->get(); - blendChannel(secondStage, source, destination, NULL, deBlendLighten, la, size.getN()); - - delete [] blurMap; - delete [] firstStage; - delete [] secondStage; - - logMessage("shadows/highlights end"); - - return result; -} - - -bool deShadowsHighlightsLayer::isChannelNeutral(int index) -{ - return false; -} - -void deShadowsHighlightsLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - saveValueProperties(root); -} - -void deShadowsHighlightsLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - loadValueProperties(child); - - child = child->next; - - } -} - diff -Nru delaboratory-0.7/src/shadows_highlights_layer.h delaboratory-0.8/src/shadows_highlights_layer.h --- delaboratory-0.7/src/shadows_highlights_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/shadows_highlights_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SHADOWS_HIGHLIGHTS_LAYER_H -#define _DE_SHADOWS_HIGHLIGHTS_LAYER_H - -#include "action_layer.h" -#include "property_value.h" - -class deShadowsHighlightsLayer:public deActionLayer -{ - private: - int blurRadiusIndex; - int shadowsHighlightsAmountIndex; - int darkenAmountIndex; - int lightenAmountIndex; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "shadows_highlights";}; - virtual std::string getLabel() const {return "shadows / highlights";}; - - public: - deShadowsHighlightsLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deShadowsHighlightsLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "s/h";}; - - void reset(); - - virtual bool randomize() {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/size.cc delaboratory-0.8/src/size.cc --- delaboratory-0.7/src/size.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/size.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "size.h" -#include - -deSize::deSize(int _w, int _h) -{ - w = _w; - h = _h; -} - -deSize::~deSize() -{ -} - -bool operator ==(const deSize& a, const deSize& b) -{ - return ( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); -} - -bool operator !=(const deSize& a, const deSize& b) -{ - return !( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); -} - -deSize fitInside(const deSize& area, const deSize& rect, deValue scale) -{ - if ((rect.getW() == 0) && (rect.getH() == 0)) - { - return deSize(area.getW(), area.getH()); - } - - deValue aspect = rect.getAspect(); - - int w = area.getW(); - int h = w / aspect; - - if (h > area.getH()) - { - h = area.getH(); - w = h * aspect; - } - - w *= scale; - h *= scale; - - if ( w > area.getW( )) - { - w = area.getW(); - } - - if ( h > area.getH( )) - { - h = area.getH(); - } - - return deSize(w,h); -} - -std::string deSize::str() const -{ - std::ostringstream oss; - oss << "[w: " << w << " h: " << h << "]"; - return oss.str(); -} diff -Nru delaboratory-0.7/src/size.h delaboratory-0.8/src/size.h --- delaboratory-0.7/src/size.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/size.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SIZE_H -#define _DE_SIZE_H - -#include -#include "value.h" - -class deSize -{ - private: - int w; - int h; - - public: - deSize(int _w, int _h); - virtual ~deSize(); - - int getW() const {return w;}; - int getH() const {return h;}; - - int getN() const {return w*h;}; - - float getAspect() const {return (float) w / h;}; - - std::string str() const; -}; - -bool operator ==(const deSize& a, const deSize& b); -bool operator !=(const deSize& a, const deSize& b); - -deSize fitInside(const deSize& area, const deSize& rect, deValue scale); - -#endif diff -Nru delaboratory-0.7/src/skin_color_chart.cc delaboratory-0.8/src/skin_color_chart.cc --- delaboratory-0.7/src/skin_color_chart.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/skin_color_chart.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "skin_color_chart.h" - -void getFelixVonLuschan(std::vector& skins) -{ - skins.push_back(deSkinRGB(244, 242, 245)); - skins.push_back(deSkinRGB(236, 235, 233)); - skins.push_back(deSkinRGB(250, 249, 247)); - skins.push_back(deSkinRGB(253, 251, 230)); - skins.push_back(deSkinRGB(253, 246, 230)); - - skins.push_back(deSkinRGB(254, 247, 229)); - skins.push_back(deSkinRGB(249, 241, 239)); - skins.push_back(deSkinRGB(243, 234, 229)); - skins.push_back(deSkinRGB(244, 241, 234)); - skins.push_back(deSkinRGB(251, 252, 244)); - - skins.push_back(deSkinRGB(251, 247, 235)); - skins.push_back(deSkinRGB(254, 246, 225)); - skins.push_back(deSkinRGB(255, 249, 225)); - skins.push_back(deSkinRGB(255, 249, 224)); - skins.push_back(deSkinRGB(241, 231, 195)); - - skins.push_back(deSkinRGB(239, 226, 173)); - skins.push_back(deSkinRGB(224, 210, 147)); - skins.push_back(deSkinRGB(242, 226, 151)); - skins.push_back(deSkinRGB(235, 214, 159)); - skins.push_back(deSkinRGB(235, 217, 133)); - skins.push_back(deSkinRGB(227, 196, 103)); - - skins.push_back(deSkinRGB(225, 193, 106)); - skins.push_back(deSkinRGB(223, 193, 123)); - skins.push_back(deSkinRGB(222, 184, 119)); - skins.push_back(deSkinRGB(199, 164, 100)); - skins.push_back(deSkinRGB(188, 151, 98)); - skins.push_back(deSkinRGB(155, 107, 67)); - skins.push_back(deSkinRGB(142, 88, 62)); - - skins.push_back(deSkinRGB(121, 77, 48)); - skins.push_back(deSkinRGB(100, 49, 22)); - skins.push_back(deSkinRGB(101, 48, 32)); - skins.push_back(deSkinRGB(96, 49, 33)); - skins.push_back(deSkinRGB(87, 50, 41)); - skins.push_back(deSkinRGB(64, 32, 21)); - skins.push_back(deSkinRGB(49, 37, 41)); - skins.push_back(deSkinRGB(27, 28, 27)); - -} - -void getSkinRanges(std::vector& ranges) -{ - deSkinRange t1; - t1.first = 1; - t1.last = 5; - t1.description = "Very light or \"white\" type"; - ranges.push_back(t1); - - deSkinRange t2; - t2.first = 6; - t2.last = 10; - t2.description = "Light"; - ranges.push_back(t2); - - deSkinRange t3; - t3.first = 11; - t3.last = 15; - t3.description = "Light intermediate"; - ranges.push_back(t3); - - deSkinRange t4; - t4.first = 16; - t4.last = 21; - t4.description = "Dark intermediate"; - ranges.push_back(t4); - - deSkinRange t5; - t5.first = 22; - t5.last = 28; - t5.description = "Dark or \"brown\" type"; - ranges.push_back(t5); - - deSkinRange t6; - t6.first = 29; - t6.last = 36; - t6.description = "Very dark or \"black\" type"; - ranges.push_back(t6); - -} diff -Nru delaboratory-0.7/src/skin_color_chart.h delaboratory-0.8/src/skin_color_chart.h --- delaboratory-0.7/src/skin_color_chart.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/skin_color_chart.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SKIN_COLOR_CHART_H -#define _DE_SKIN_COLOR_CHART_H - -#include "value.h" - -#include -#include - -struct deSkinCMYK -{ - deValue c; - deValue m; - deValue y; - deValue k; - - deSkinCMYK(int _c, int _m, int _y, int _k) - :c(_c), m(_m), y(_y), k(_k) - { - } -}; - -struct deSkinRGB -{ - int r; - int g; - int b; - - deSkinRGB(int _r, int _g, int _b) - :r(_r), g(_g), b(_b) - { - } - -}; - -struct deSkinRange -{ - int first; - int last; - std::string description; -}; - -void getFelixVonLuschan(std::vector& skins); -void getSkinRanges(std::vector& ranges); - -#endif diff -Nru delaboratory-0.7/src/slider.cc delaboratory-0.8/src/slider.cc --- delaboratory-0.7/src/slider.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/slider.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "slider.h" -#include -#include "layer_processor.h" - -void deSlider::updateValueFromSlider(bool finished) -{ - deValue v = valueMin + slider->GetValue() * ((valueMax-valueMin) / sliderRange); - if (integerMode) - { - int i = v; - v = i; - } - setEdit(v); - onValueChange(v, finished); -} - -void deSlider::setValue(deValue v) -{ - setEdit(v); - setSlider(v); -} - -void deSlider::setEdit(deValue v) -{ - std::ostringstream oss; - oss.str(); - oss << v; - if (labelValue) - { - std::string s = oss.str(); - labelValue->SetLabel(wxString::FromAscii(oss.str().c_str())); - } - else - { - } -} - -void deSlider::setSlider(deValue v) -{ - if (sliderRange == 0) - { - return; - } - - if (valueMax == valueMin) - { - return; - } - - deValue sl = (v - valueMin) / ((valueMax-valueMin) / sliderRange); - - if (!slider) - { - return; - } - - slider->SetValue(sl); -} - -void deSlider::moveSlider(wxCommandEvent &event) -{ - updateValueFromSlider(false); -} - -void deSlider::finishMoveSlider(wxCommandEvent &event) -{ - updateValueFromSlider(true); -} - -deSlider::deSlider(wxWindow *parent, const std::string& labelString, int _sliderRange, deValue _valueMin, deValue _valueMax, deValue _defaultValue) -:wxPanel(parent), sliderRange(_sliderRange), valueMin(_valueMin), valueMax(_valueMax), defaultValue(_defaultValue) -{ - integerMode = false; - sizer = new wxBoxSizer(wxHORIZONTAL); - - if (labelString.size() > 0) - { - label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(labelString.c_str()), wxDefaultPosition, wxSize(120, 30)); - sizer->Add(label, 0, wxCENTER); - } - else - { - label = NULL; - } - - slider = new wxSlider(this, wxID_ANY, sliderRange, 0, sliderRange, wxDefaultPosition, wxSize(sliderRange, -1), wxSL_HORIZONTAL); - sizer->Add(slider, 0); - - reset = new wxButton(this, wxID_ANY, _T("r"), wxDefaultPosition, wxSize(25,25)); - sizer->Add(reset, 0, wxCENTER); - - labelValue = new wxStaticText(this, wxID_ANY, _T("inv"), wxDefaultPosition, wxSize(40, 30)); - sizer->Add(labelValue, 0, wxCENTER); - - SetSizer(sizer); - - Connect(wxEVT_SCROLL_THUMBTRACK, wxCommandEventHandler(deSlider::moveSlider)); - Connect(wxEVT_SCROLL_CHANGED, wxCommandEventHandler(deSlider::finishMoveSlider)); - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deSlider::click)); - -} - -deSlider::~deSlider() -{ -} - -void deSlider::setIntegerMode() -{ - integerMode = true; -} - -void deSlider::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - if (reset->GetId() == id) - { - setValue(defaultValue); - onValueChange(defaultValue, true); - } -} diff -Nru delaboratory-0.7/src/slider.h delaboratory-0.8/src/slider.h --- delaboratory-0.7/src/slider.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/slider.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SLIDER_H -#define _DE_SLIDER_H - -#include -#include "value.h" -class deLayerProcessor; - -class deSlider:public wxPanel -{ - private: - wxSizer* sizer; - wxStaticText* label; - wxStaticText* labelValue; - wxButton* reset; - wxSlider* slider; - int sliderRange; - deValue valueMin; - deValue valueMax; - deValue defaultValue; - bool integerMode; - - void moveSlider(wxCommandEvent &event); - void finishMoveSlider(wxCommandEvent &event); - - void updateValueFromSlider(bool finished); - - void setEdit(deValue v); - void setSlider(deValue v); - - void click(wxCommandEvent &event); - - public: - deSlider(wxWindow *parent, const std::string& labelString, int _sliderRange, deValue _valueMin, deValue _valueMax, deValue defaultValue); - virtual ~deSlider(); - - void setIntegerMode(); - - void setValue(deValue v); - - virtual void onValueChange(deValue value, bool finished) = 0; -}; - -#endif diff -Nru delaboratory-0.7/src/source_image_layer.cc delaboratory-0.8/src/source_image_layer.cc --- delaboratory-0.7/src/source_image_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/source_image_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "source_image_layer.h" -#include "channel_manager.h" -#include "scale_channel.h" -#include -#include "view_manager.h" -#include "logger.h" -#include "static_image.h" -#include "copy_channel.h" -#include "str.h" - -deSourceImageLayer::deSourceImageLayer(int _index, deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace) -:deLayer("source image", _colorSpace, _index, -1), -previewChannelManager(_previewChannelManager), -viewManager(_viewManager), -image(_colorSpace, _previewChannelManager), -sourceImage(_sourceImage) -{ -} - -deSourceImageLayer::~deSourceImageLayer() -{ -} - -bool deSourceImageLayer::updateImage() -{ - logMessage("source image layer update image start"); - - deChannel* sourceChannelR = sourceImage.getChannel(0); - deChannel* sourceChannelG = sourceImage.getChannel(1); - deChannel* sourceChannelB = sourceImage.getChannel(2); - - if (!sourceChannelR) - { - std::cout << "deSourceImageLayer::updateImage !sourceChannelR" << std::endl; - return false; - } - - logMessage("enabling channels..."); - image.enableChannel(0); - image.enableChannel(1); - image.enableChannel(2); - logMessage("enabled channels"); - - deChannel* channelR = previewChannelManager.getChannel(image.getChannelIndex(0)); - deChannel* channelG = previewChannelManager.getChannel(image.getChannelIndex(1)); - deChannel* channelB = previewChannelManager.getChannel(image.getChannelIndex(2)); - - sourceChannelR->lockRead(); - sourceChannelG->lockRead(); - sourceChannelB->lockRead(); - channelR->lockWrite(); - channelG->lockWrite(); - channelB->lockWrite(); - - const deSize ss = sourceImage.getSize(); - - const deSize ds = previewChannelManager.getChannelSize(); - - deValue z_x1; - deValue z_y1; - deValue z_x2; - deValue z_y2; - viewManager.getZoom(z_x1, z_y1, z_x2, z_y2); - - logMessage("z_x1: " + str(z_x1) + " z_x2: " + str(z_x2) + " z_y1: " + str(z_y1) + " z_y2: " + str(z_y2)); - - int x1 = ss.getW() * z_x1; - int y1 = ss.getH() * z_y1; - int x2 = ss.getW() * z_x2; - int y2 = ss.getH() * z_y2; - - logMessage("x1: " + str(x1) + " x2: " + str(x2) + " y1: " + str(y1) + " y2: " + str(y2)); - - int w = ds.getW(); - int h = ds.getH(); - - logMessage("w: " + str(w) + " h: " + str(h)); - - int ws = ss.getW(); - - if (ss == ds) - { - copyChannel(sourceChannelR->getPixels(), channelR->getPixels(), ss); - copyChannel(sourceChannelG->getPixels(), channelG->getPixels(), ss); - copyChannel(sourceChannelB->getPixels(), channelB->getPixels(), ss); - } - else - { - scaleChannel(sourceChannelR->getPixels(), channelR->getPixels(), x1, y1, x2, y2, w, h, ws); - scaleChannel(sourceChannelG->getPixels(), channelG->getPixels(), x1, y1, x2, y2, w, h, ws); - scaleChannel(sourceChannelB->getPixels(), channelB->getPixels(), x1, y1, x2, y2, w, h, ws); - } - - sourceChannelR->unlockRead(); - sourceChannelG->unlockRead(); - sourceChannelB->unlockRead(); - channelR->unlockWrite(); - channelG->unlockWrite(); - channelB->unlockWrite(); - - logMessage("source image layer update image end"); - - return true; -} - -const deImage& deSourceImageLayer::getImage() const -{ - return image; -} - -void deSourceImageLayer::updateChannelUsage(std::map& channelUsage) const -{ - image.updateChannelUsage(channelUsage, index); -} - diff -Nru delaboratory-0.7/src/source_image_layer.h delaboratory-0.8/src/source_image_layer.h --- delaboratory-0.7/src/source_image_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/source_image_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_SOURCE_IMAGE_LAYER_H -#define _DE_SOURCE_IMAGE_LAYER_H - -#include "layer.h" -class deProject; -#include "image.h" -class deChannelManager; -class deViewManager; -class deStaticImage; - -class deSourceImageLayer:public deLayer -{ - private: - deChannelManager& previewChannelManager; - deViewManager& viewManager; - - deImage image; - deStaticImage& sourceImage; - - virtual std::string getType() const {return "source_image";}; - - virtual bool updateImage(); - - public: - deSourceImageLayer(int _index, deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace); - virtual ~deSourceImageLayer(); - - virtual const deImage& getImage() const; - - virtual void updateChannelUsage(std::map& channelUsage) const; - - virtual void load(xmlNodePtr root) {}; - virtual void save(xmlNodePtr root) {saveCommon(root);}; - - void setOffset(deValue x, deValue y); - - virtual bool randomize() {return false;}; - -}; - -#endif diff -Nru delaboratory-0.7/src/static_image.cc delaboratory-0.8/src/static_image.cc --- delaboratory-0.7/src/static_image.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/static_image.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "static_image.h" -#include "channel.h" -#include "logger.h" - -deStaticImage::deStaticImage() -:colorSpace(deColorSpaceInvalid), - size(0,0), - mutex(wxMUTEX_RECURSIVE) -{ - int n = 3; - int i; - for (i = 0; i < n; i++) - { - deChannel* c = new deChannel(); - channels.push_back(c); - channels[i]->allocate(size.getN()); - } -} - -void deStaticImage::setColorSpace(deColorSpace c) -{ - if (getColorSpaceSize(c) == 3) - { - colorSpace = c; - } -} - -deStaticImage::~deStaticImage() -{ - while (!channels.empty()) - { - std::vector::iterator i = channels.end(); - i--; - delete *i; - channels.erase(i); - } -} - -deColorSpace deStaticImage::getColorSpace() const -{ - return colorSpace; -} - -deChannel* deStaticImage::getChannel(int index) -{ - if (index < 0) - { - return NULL; - } - int n = 3; - if (index >= n) - { - return NULL; - } - return channels[index]; -} - -void deStaticImage::setSize(const deSize& _size) -{ - if (size == _size) - { - return; - } - size = _size; - int n = 3; - int i; - for (i = 0; i < n; i++) - { - channels[i]->deallocate(); - channels[i]->allocate(size.getN()); - } -} - -deSize deStaticImage::getSize() const -{ - return size; -} - -void deStaticImage::lock() -{ - lockWithLog(mutex, "static image mutex"); -} - -void deStaticImage::unlock() -{ - mutex.Unlock(); -} diff -Nru delaboratory-0.7/src/static_image.h delaboratory-0.8/src/static_image.h --- delaboratory-0.7/src/static_image.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/static_image.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_STATIC_IMAGE_H -#define _DE_STATIC_IMAGE_H - -#include "color_space.h" -#include "size.h" -class deChannel; - -class deStaticImage -{ - private: - deColorSpace colorSpace; - std::vector channels; - deSize size; - mutable wxMutex mutex; - - deStaticImage(const deStaticImage& i); - deStaticImage& operator = (const deStaticImage& i); - - public: - deStaticImage(); - - virtual ~deStaticImage(); - - void setColorSpace(deColorSpace c); - deColorSpace getColorSpace() const; - - deChannel* getChannel(int index); - - void setSize(const deSize& _size); - deSize getSize() const; - - void lock(); - void unlock(); -}; - -#endif diff -Nru delaboratory-0.7/src/str.cc delaboratory-0.8/src/str.cc --- delaboratory-0.7/src/str.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/str.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "str.h" -#include - -std::string getBaseName(const std::string& s) -{ - int pos = s.rfind("."); - return s.substr(0, pos); -} - -std::string getExtension(const std::string& s) -{ - int pos = s.rfind("."); - return s.substr(pos + 1, s.size() - pos - 1); -} - -std::string removePathAndExtension(const std::string& fileName) -{ - size_t posDot = fileName.rfind("."); -#ifdef _WIN32 - size_t posSlash = fileName.rfind("\\"); -#else - size_t posSlash = fileName.rfind("/"); -#endif - int posStart; - if (posSlash > fileName.size()) - { - posStart= 0; - } - else - { - posStart = posSlash + 1; - } - return fileName.substr(posStart, posDot - posStart ); -} - -std::string str(int n) -{ - std::ostringstream oss; - oss << n; - return oss.str(); -} - -std::string str(unsigned int n) -{ - std::ostringstream oss; - oss << n; - return oss.str(); -} - -std::string str(deValue n) -{ - std::ostringstream oss; - oss << n; - return oss.str(); -} - -deValue getValue(const std::string& s) -{ - deValue v; - std::istringstream iss(s); - iss >> v; - return v; -} - -int getInt(const std::string& s) -{ - int v; - std::istringstream iss(s); - iss >> v; - return v; -} - -bool getBool(const std::string& s) -{ - if (s == "true") - { - return true; - } - else - { - // TODO some kind of assert of exception in other case? - return false; - } -} - -std::string str(bool b) -{ - if (b) - { - return "true"; - } - else - { - return "false"; - } -} - - -std::string str(wxString& ws) -{ - char cstring[1024]; - strncpy(cstring, (const char*)ws.mb_str(wxConvUTF8), 1023); - - return cstring; -} - - -std::string getTmp() -{ - wxString temp; - if (wxGetEnv(_T("TEMP"), &temp)) - { - // on Windows $TEMP should be set - return str(temp); - } - else - { - return "/tmp"; - } -} diff -Nru delaboratory-0.7/src/str.h delaboratory-0.8/src/str.h --- delaboratory-0.7/src/str.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/str.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_STR_H -#define _DE_STR_H - -#include -#include "value.h" -#include - -/* returns str before ".", so for "abcde.jpg" returns "abcde" */ -std::string getBaseName(const std::string& s); - -/* returns str after ".", so for "abcde.jpg" returns "jpg" */ -std::string getExtension(const std::string& s); - -//std::string replaceExtension(const std::string& s, const std::string& ext); -std::string removePathAndExtension(const std::string& fileName); - -std::string str(deValue n); -std::string str(int n); -std::string str(unsigned int n); -std::string str(bool b); -std::string str(wxString& ws); - -deValue getValue(const std::string& s); -int getInt(const std::string& s); -bool getBool(const std::string& s); - -std::string getTmp(); - -#endif diff -Nru delaboratory-0.7/src/threads_panel.cc delaboratory-0.8/src/threads_panel.cc --- delaboratory-0.7/src/threads_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/threads_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "threads_panel.h" -#include "layer_processor.h" - -deThreadsPanel::deThreadsPanel(wxWindow* parent) -:wxPanel(parent) -{ - wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("thread activity")); - SetSizer(sizerP); - - processingInfo = new wxStaticText(this, wxID_ANY, _T("[processing]"), wxDefaultPosition); - sizerP->Add(processingInfo, 0, wxEXPAND); - - renderingInfo = new wxStaticText(this, wxID_ANY, _T("[rendering]"), wxDefaultPosition); - sizerP->Add(renderingInfo, 0, wxEXPAND); - - histogramInfo = new wxStaticText(this, wxID_ANY, _T("[histogram]"), wxDefaultPosition); - sizerP->Add(histogramInfo, 0, wxEXPAND); - - dcrawInfo = new wxStaticText(this, wxID_ANY, _T("[dcraw]"), wxDefaultPosition); - sizerP->Add(dcrawInfo, 0, wxEXPAND); -} - -deThreadsPanel::~deThreadsPanel() -{ - -} - -void deThreadsPanel::setInfoColor(int i) -{ - int e = 100; - int e2 = 50; - int d = 150; - switch (i) - { - case DE_PROCESSING_START: - { - processingInfo->SetForegroundColour(wxColour(e, e, e)); - break; - } - case DE_PROCESSING_END: - { - processingInfo->SetForegroundColour(wxColour(d, d, d)); - break; - } - case DE_RENDERING_START: - { - renderingInfo->SetForegroundColour(wxColour(e, e, e)); - break; - } - case DE_RENDERING_END: - { - renderingInfo->SetForegroundColour(wxColour(d, d, d)); - break; - } - case DE_HISTOGRAM_START: - { - histogramInfo->SetForegroundColour(wxColour(e, e, e)); - break; - } - case DE_HISTOGRAM_END: - { - histogramInfo->SetForegroundColour(wxColour(d, d, d)); - break; - } - case DE_DCRAW_START: - { - dcrawInfo->SetForegroundColour(wxColour(e2, e2, e2)); - break; - } - case DE_DCRAW_END: - { - dcrawInfo->SetForegroundColour(wxColour(d, d, d)); - break; - } - } -} - diff -Nru delaboratory-0.7/src/threads_panel.h delaboratory-0.8/src/threads_panel.h --- delaboratory-0.7/src/threads_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/threads_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_THREADS_PANEL_H -#define _DE_THREADS_PANEL_H - -#include - -class deThreadsPanel:public wxPanel -{ - private: - wxStaticText* processingInfo; - wxStaticText* renderingInfo; - wxStaticText* histogramInfo; - //wxStaticText* debugInfo; - wxStaticText* dcrawInfo; - public: - deThreadsPanel(wxWindow* parent); - virtual ~deThreadsPanel(); - - void setInfoColor(int i); - - -}; - -#endif diff -Nru delaboratory-0.7/src/usm_frame.cc delaboratory-0.8/src/usm_frame.cc --- delaboratory-0.7/src/usm_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/usm_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "usm_frame.h" -#include "usm_layer.h" -#include -#include "property_value_slider.h" -#include "layer_processor.h" - -deUSMFrame::deUSMFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deUSMLayer& usmLayer = dynamic_cast(_layer); - - int range = 400; - - int n = usmLayer.getNumberOfValueProperties(); - - int i; - - for (i = 0; i < n; i++) - { - dePropertyValue* p = usmLayer.getPropertyValue(i); - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, usmLayer, layerProcessor); - valueSliders.push_back(s); - sizer->Add(s); - } - } - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - std::vector presets; - usmLayer.getPresets(presets); - - std::vector::iterator j; - for (j = presets.begin(); j != presets.end(); j++) - { - wxButton* b = new wxButton(this, wxID_ANY, wxString::FromAscii(j->c_str()), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(b, 0); - buttons[*j] = b; - } - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deUSMFrame::click)); -} - -deUSMFrame::~deUSMFrame() -{ -} - -void deUSMFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deUSMLayer& usmLayer = dynamic_cast(layer); - - std::map::iterator i; - - for (i = buttons.begin(); i != buttons.end(); i++) - { - if (i->second->GetId() == id) - { - usmLayer.applyPreset(i->first); - } - } - - std::vector::iterator j; - for (j = valueSliders.begin(); j != valueSliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} diff -Nru delaboratory-0.7/src/usm_frame.h delaboratory-0.8/src/usm_frame.h --- delaboratory-0.7/src/usm_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/usm_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_USM_FRAME_H -#define _DE_USM_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include -#include - -class dePropertyValueSlider; -class deLayerProcessor; - -class deUSMFrame:public deActionFrame -{ - private: - std::vector valueSliders; - std::map buttons; - - deLayerProcessor& layerProcessor; - - void click(wxCommandEvent &event); - - public: - deUSMFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deUSMFrame(); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/usm_layer.cc delaboratory-0.8/src/usm_layer.cc --- delaboratory-0.7/src/usm_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/usm_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "usm_layer.h" -#include "project.h" -#include -#include "blur.h" -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "layer_processor.h" -#include "preset.h" - -deUSMLayer::deUSMLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager) -{ - blurRadiusPropertyIndex = registerPropertyValue("blur_radius"); - amountPropertyIndex = registerPropertyValue("amount"); - thresholdPropertyIndex = registerPropertyValue("threshold"); - - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 5.0)); - p->addPresetValue(new dePresetValue("amount", 0.1)); - p->addPresetValue(new dePresetValue("threshold", 0.0)); - presets["reset"] = p; - } - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 3.0)); - p->addPresetValue(new dePresetValue("amount", 3.0)); - p->addPresetValue(new dePresetValue("threshold", 0.0)); - presets["sharp"] = p; - } - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 100)); - p->addPresetValue(new dePresetValue("amount", 0.1)); - p->addPresetValue(new dePresetValue("threshold", 0.0)); - presets["hiraloam"] = p; - } - { - dePresetLayer* p = new dePresetLayer(*this); - p->addPresetValue(new dePresetValue("blur_radius", 150)); - p->addPresetValue(new dePresetValue("amount", 0.2)); - p->addPresetValue(new dePresetValue("threshold", 0.0)); - presets["hiraloam2"] = p; - } - - dePropertyValue* blurRadius = valueProperties[blurRadiusPropertyIndex]; - dePropertyValue* amount = valueProperties[amountPropertyIndex]; - - blurRadius->setMin(1); - blurRadius->setMax(200); - applyPreset("reset"); - amount->setMax(5); - blurRadius->setLabel("radius"); -} - -deUSMLayer::~deUSMLayer() -{ -} - -bool deUSMLayer::processAction(int index, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("usm start"); - - int n = size.getN(); - - deValue* unsharpMask = NULL; - try - { - unsharpMask = new deValue [size.getN()]; - } - catch (std::bad_alloc) - { - logMessage("ERROR allocating memory in USM"); - if (unsharpMask) - { - delete [] unsharpMask; - } - return false; - } - - dePropertyValue* blurRadius = valueProperties[blurRadiusPropertyIndex]; - dePropertyValue* amount = valueProperties[amountPropertyIndex]; - dePropertyValue* threshold = valueProperties[thresholdPropertyIndex]; - - const deValue* source = sourceChannel.getPixels(); - deValue* destination = channel.getPixels(); - deBlurType type = deGaussianBlur; - deValue b_t = 0.0; - - deValue r = viewManager.getRealScale() * blurRadius->get(); - - bool result = blurChannel(source, unsharpMask, size, r, r, type, b_t); - - int i; - - deValue t = threshold->get(); - deValue a = amount->get(); - - if (t > 0) - { - for (i = 0; i < n; i++) - { - deValue src = source[i]; - deValue u = src - unsharpMask[i]; - - if (fabs(u) >= t) - { - deValue d = src + a * u; - - if (d < 0) - { - destination[i] = 0; - } - else if (d > 1) - { - destination[i] = 1; - } - else - { - destination[i] = d; - } - } - else - { - destination[i] = src; - } - } - } - else - { - for (i = 0; i < n; i++) - { - deValue src = source[i]; - deValue u = src - unsharpMask[i]; - - deValue d = src + a * u; - - if (d < 0) - { - destination[i] = 0; - } - else if (d > 1) - { - destination[i] = 1; - } - else - { - destination[i] = d; - } - } - } - - - delete [] unsharpMask; - - logMessage("usm end"); - - return result; -} - - -bool deUSMLayer::isChannelNeutral(int index) -{ - dePropertyValue* blurRadius = valueProperties[blurRadiusPropertyIndex]; - return (blurRadius->get() == 0); -} - -void deUSMLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - saveValueProperties(root); -} - -void deUSMLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - loadValueProperties(child); - - child = child->next; - } -} - -bool deUSMLayer::randomize() -{ - dePropertyValue* blurRadius = valueProperties[blurRadiusPropertyIndex]; - dePropertyValue* amount = valueProperties[amountPropertyIndex]; - dePropertyValue* threshold = valueProperties[thresholdPropertyIndex]; - - deValue r = (deValue) rand() / RAND_MAX; - r *= 0.5; - blurRadius->set(r + 0.001); - - deValue r2 = (deValue) rand() / RAND_MAX; - r2 *= 5; - amount->set(r2); - - deValue r3 = (deValue) rand() / RAND_MAX; - r3 *= 0.2; - threshold->set(r3); - - return true; -} - - diff -Nru delaboratory-0.7/src/usm_layer.h delaboratory-0.8/src/usm_layer.h --- delaboratory-0.7/src/usm_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/usm_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_USM_LAYER_H -#define _DE_USM_LAYER_H - -#include "action_layer.h" -#include "property_value.h" - - -class deUSMLayer:public deActionLayer -{ - private: - int blurRadiusPropertyIndex; - int amountPropertyIndex; - int thresholdPropertyIndex; - - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "usm";}; - virtual std::string getLabel() const {return "unsharp mask";}; - - public: - deUSMLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deUSMLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "usm";}; - - virtual bool randomize(); - - -}; - -#endif diff -Nru delaboratory-0.7/src/value.cc delaboratory-0.8/src/value.cc --- delaboratory-0.7/src/value.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/value.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "value.h" diff -Nru delaboratory-0.7/src/value.h delaboratory-0.8/src/value.h --- delaboratory-0.7/src/value.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/value.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VALUE_H -#define _DE_VALUE_H - -#define deValue float - -#endif diff -Nru delaboratory-0.7/src/view_manager.cc delaboratory-0.8/src/view_manager.cc --- delaboratory-0.7/src/view_manager.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/view_manager.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "view_manager.h" -#include "project.h" -#include "layer.h" -#include "layer_processor.h" -#include "str.h" -#include "channel_manager.h" -#include "layer_stack.h" -#include "zoom_manager.h" - -deViewManager::deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager) -:project(_project), layerProcessor(_processor), zoomManager(_zoomManager) -{ - view = 0; - showBlendMask = false; - single = false; - blendMaskChannel = 0; -} - -deViewManager::~deViewManager() -{ -} - -int deViewManager::getView() const -{ - return view; -} - -void deViewManager::setView(int v) -{ - logMessage("view manager set view " + str(v) + " start"); - hideMask(); - logMessage("view manager set view " + str(v) + " step a"); - int old = view; - view = v; - logMessage("view manager set view " + str(v) + " step b"); - project.onChangeView(old); - logMessage("view manager set view " + str(v) + " end"); -} - -void deViewManager::setSingleChannel(int _channel) -{ - single = true; - channel = _channel; - project.onChangeViewMode(); - layerProcessor.onChangeViewMode(); - -} - -void deViewManager::setNormal() -{ - single = false; - project.onChangeViewMode(); - layerProcessor.onChangeViewMode(); -} - -void deViewManager::hideMask() -{ - showBlendMask = false; - project.onChangeViewMode(); -} - -void deViewManager::showMask(int maskChannel) -{ - showBlendMask = true; - blendMaskChannel = maskChannel; - project.onChangeViewMode(); -} - -void deViewManager::hideThisMask(int maskChannel) -{ - if (blendMaskChannel != maskChannel) - { - return; - } - showBlendMask = false; - project.onChangeViewMode(); -} - -bool deViewManager::maskVisible() const -{ - return showBlendMask; -} - -int deViewManager::getMaskChannel() const -{ - return blendMaskChannel; -} - -deColorSpace deViewManager::getColorSpace() const -{ - deLayerStack& layerStack = project.getLayerStack(); - deLayer* layer = layerStack.getLayer(view); - if (!layer) - { - return deColorSpaceInvalid; - } - - return layer->getColorSpace(); -} - -void deViewManager::setHistogramChannel(int channel) -{ - project.setHistogramChannel(channel); -} - -deValue deViewManager::getRealScale() const -{ - deSize ps = project.getPreviewChannelManager().getChannelSize(); - - deSize ss = project.getSourceImageSize(); - - deValue sx = (deValue) ps.getW() / ss.getW(); - deValue sy = (deValue) ps.getH() / ss.getH(); - - deValue s = sx; - if (sy < s) - { - s = sy; - } - - return s; -} - -void deViewManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) -{ - return zoomManager.getZoom(_x1, _y1, _x2, _y2); -} diff -Nru delaboratory-0.7/src/view_manager.h delaboratory-0.8/src/view_manager.h --- delaboratory-0.7/src/view_manager.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/view_manager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_PREVIEW_MANAGER_H -#define _DE_PREVIEW_MANAGER_H - -class deProject; -class deLayerProcessor; -class deZoomManager; -#include "color_space.h" - -class deViewManager -{ - private: - int view; - deProject& project; - deLayerProcessor& layerProcessor; - deZoomManager& zoomManager; - bool single; - int channel; - bool showBlendMask; - int blendMaskChannel; - - - public: - deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager); - virtual ~deViewManager(); - - void setView(int v); - int getView() const; - - void setSingleChannel(int _channel); - void setNormal(); - - deColorSpace getColorSpace() const; - - bool isSingleChannel() const {return single;}; - int getChannel() const {return channel;}; - - void showMask(int maskChannel); - void hideThisMask(int maskChannel); - void hideMask(); - - bool maskVisible() const; - int getMaskChannel() const; - - void setHistogramChannel(int channel); - - deValue getRealScale() const; - - void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); - -}; - -#endif diff -Nru delaboratory-0.7/src/view_mode.h delaboratory-0.8/src/view_mode.h --- delaboratory-0.7/src/view_mode.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/view_mode.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VIEW_MODE -#define _DE_VIEW_MODE - -enum deViewMode -{ - deViewDisabled, - deViewNormal, - deViewSingleChannel -}; - -#endif diff -Nru delaboratory-0.7/src/view_mode_panel.cc delaboratory-0.8/src/view_mode_panel.cc --- delaboratory-0.7/src/view_mode_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/view_mode_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "view_mode_panel.h" -#include -#include "color_space.h" -#include "project.h" -#include -#include "logger.h" - -void deViewModePanel::select(wxCommandEvent &event) -{ - int i = event.GetId(); - deViewManager& viewManager = project.getViewManager(); - - if (buttons[0]->GetId() == i) - { - viewManager.setNormal(); - return; - } - - int j; - for (j = 0; j < 4; j++) - { - if (buttons[j+1]->GetId() == i) - { - viewManager.setSingleChannel(j); - } - } - -} - -deViewModePanel::deViewModePanel(wxWindow* parent, deProject& _project) -:wxPanel(parent), project(_project) -{ - project.setViewModePanel(this); - - wxSizer* sizerS = new wxStaticBoxSizer(wxVERTICAL, this, _T("view")); - SetSizer(sizerS); - - wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); - sizerS->Add(sizer); - - int i; - for (i = 0; i < 5; i++) - { - int style = 0; - if (i == 0) - { - style = wxRB_GROUP; - } - wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); - sizer->Add(b); - buttons.push_back(b); - - } - - updateNames(); - updateMode(); - - Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deViewModePanel::select)); - -} - -deViewModePanel::~deViewModePanel() -{ - -} - -void deViewModePanel::updateNames() -{ - logMessage("update names in view mode panel"); - - deViewManager& viewManager = project.getViewManager(); - - deColorSpace colorSpace = viewManager.getColorSpace(); - - int i; - int n = getColorSpaceSize(colorSpace); - for (i = 0; i < 5; i++) - { - wxRadioButton* b = buttons[i]; - if (i == 0) - { - b->SetLabel(wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); - b->Show(); - } - else - { - int c = i - 1; - if (c < n) - { - std::string name = getChannelName(colorSpace, c); - b->SetLabel(wxString::FromAscii(name.c_str())); - b->Show(); - } - else - { - b->Hide(); - } - } - - } - - Layout(); - Fit(); - SetFocus(); -} - -void deViewModePanel::updateMode() -{ - logMessage("update mode in view mode panel"); - - deViewManager& viewManager = project.getViewManager(); - - if (viewManager.isSingleChannel()) - { - int c = viewManager.getChannel(); - buttons[c+1]->SetValue(1); - } - else - { - buttons[0]->SetValue(1); - } -} - diff -Nru delaboratory-0.7/src/view_mode_panel.h delaboratory-0.8/src/view_mode_panel.h --- delaboratory-0.7/src/view_mode_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/view_mode_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VIEW_MODE_PANEL_H -#define _DE_VIEW_MODE_PANEL_H - -#include -#include -#include -#include "color_space.h" -class deProject; - -class deViewModePanel:public wxPanel -{ - private: - std::vector buttons; - deProject& project; - - void select(wxCommandEvent &event); - public: - deViewModePanel(wxWindow* parent, deProject& _project); - virtual ~deViewModePanel(); - - void updateNames(); - void updateMode(); - -}; - -#endif diff -Nru delaboratory-0.7/src/vignette.cc delaboratory-0.8/src/vignette.cc --- delaboratory-0.7/src/vignette.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "vignette.h" -#include -#include -#include "logger.h" -#include "str.h" - -deEllipse::deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY) -:centerX(_centerX), - centerY(_centerY), - radiusX(_radiusX), - radiusY(_radiusY) -{ -} - -deEllipse::~deEllipse() -{ -} - -deValue deEllipse::processX(deValue x) const -{ - x = x - centerX; - - x /= radiusX; - - return x; -} - -deValue deEllipse::processY(deValue y) const -{ - y = y - centerY; - - y /= radiusY; - - return y; -} - -bool deEllipse::isValid() const -{ - if (radiusX <= 0.0) - { - return false; - } - if (radiusY <= 0.0) - { - return false; - } - - return true; -} - -void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot) -{ - if (!ellipse.isValid()) - { - return; - } - - int w = size.getW(); - int h = size.getH(); - - if (w == 0) - { - return; - } - - if (h == 0) - { - return; - } - - deValue ww = w / 2.0; - deValue hh = h / 2.0; - - int i; - int j; - - int p = 0; - - for (i = 0; i < h; i++) - { - deValue y = (i - hh) / hh; - - y = ellipse.processY(y); - - for (j = 0; j < w; j++) - { - deValue x = (j - ww) / ww; - - x = ellipse.processX(x); - - deValue r = sqrt(x * x + y * y); - - deValue v = 1.0 - r + spot; - if (v < 0) - { - v = 0; - } - if (v > 1) - { - v = 1; - } - - deValue vv = darkness + (light - darkness) * v; - if (vv < 0) - { - vv = 0; - } - if (vv > 1) - { - vv = 1; - } - - destination[p] = vv; - p++; - } - } - -} - -void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse1, deEllipse ellipse2, deValue light, deValue darkness, deValue spot) -{ - if (!ellipse1.isValid()) - { - return; - } - - if (!ellipse2.isValid()) - { - return; - } - - - int w = size.getW(); - int h = size.getH(); - - if (w == 0) - { - return; - } - - if (h == 0) - { - return; - } - - deValue ww = w / 2.0; - deValue hh = h / 2.0; - - int i; - int j; - - int p = 0; - - for (i = 0; i < h; i++) - { - deValue y = (i - hh) / hh; - - deValue y1 = ellipse1.processY(y); - deValue y2 = ellipse2.processY(y); - - for (j = 0; j < w; j++) - { - deValue x = (j - ww) / ww; - - deValue x1 = ellipse1.processX(x); - deValue x2 = ellipse2.processX(x); - - deValue r1 = sqrt(x1 * x1 + y1 * y1); - deValue r2 = sqrt(x2 * x2 + y2 * y2); - - deValue v1 = 1.0 - r1 + spot; - if (v1 < 0) - { - v1 = 0; - } - if (v1 > 1) - { - v1 = 1; - } - - deValue v2 = 1.0 - r2 + spot; - if (v2 < 0) - { - v2 = 0; - } - if (v2 > 1) - { - v2 = 1; - } - - deValue v = v1; - if (v2 > v) - { - v = v2; - } - - deValue vv = darkness + (light - darkness) * v; - if (vv < 0) - { - vv = 0; - } - if (vv > 1) - { - vv = 1; - } - - destination[p] = vv; - p++; - } - } - -} - diff -Nru delaboratory-0.7/src/vignette_frame.cc delaboratory-0.8/src/vignette_frame.cc --- delaboratory-0.7/src/vignette_frame.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette_frame.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "vignette_frame.h" -#include "vignette_layer.h" -#include -#include "property_value_slider.h" -#include "layer_processor.h" - -deVignetteFrame::deVignetteFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager) -:deActionFrame(parent, _layer, _frameManager), layerProcessor(_layerProcessor) -{ - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(sizer); - - deVignetteLayer& vignetteLayer = dynamic_cast(_layer); - - int range = 400; - - int n = vignetteLayer.getNumberOfValueProperties(); - - int i; - - for (i = 0; i < n; i++) - { - dePropertyValue* p = vignetteLayer.getPropertyValue(i); - if (p) - { - dePropertyValueSlider* s = new dePropertyValueSlider(this, range, *p, vignetteLayer, layerProcessor); - valueSliders.push_back(s); - sizer->Add(s); - } - } - - wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); - sizer->Add(sizerB, 0); - - reset = new wxButton(this, wxID_ANY, _T("reset"), wxDefaultPosition, wxSize(100,25)); - sizerB->Add(reset, 0); - - Fit(); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deVignetteFrame::click)); -} - -deVignetteFrame::~deVignetteFrame() -{ -} - -void deVignetteFrame::click(wxCommandEvent &event) -{ - int id = event.GetId(); - deVignetteLayer& vignetteLayer = dynamic_cast(layer); - - if (reset->GetId() == id) - { - vignetteLayer.reset(); - } - - std::vector::iterator j; - for (j = valueSliders.begin(); j != valueSliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); -} - -bool deVignetteFrame::onImageClick(deValue x, deValue y) -{ - if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) - { - return false; - } - deVignetteLayer& vignetteLayer = dynamic_cast(layer); - bool result = vignetteLayer.setCenter(x, y); - - std::vector::iterator j; - for (j = valueSliders.begin(); j != valueSliders.end(); j++) - { - (*j)->setFromProperty(); - } - - int index = layer.getIndex(); - layerProcessor.markUpdateAllChannels(index); - - return result; -} diff -Nru delaboratory-0.7/src/vignette_frame.h delaboratory-0.8/src/vignette_frame.h --- delaboratory-0.7/src/vignette_frame.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette_frame.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VIGNETTE_FRAME_H -#define _DE_VIGNETTE_FRAME_H - -#include "action_frame.h" -#include "slider.h" -#include - -class dePropertyValueSlider; -class deLayerProcessor; - -class deVignetteFrame:public deActionFrame -{ - private: - std::vector valueSliders; - deLayerProcessor& layerProcessor; - - wxButton* reset; - - void click(wxCommandEvent &event); - - public: - deVignetteFrame(wxWindow *parent, deActionLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager); - virtual ~deVignetteFrame(); - - virtual bool onImageClick(deValue x, deValue y); - - -}; - - -#endif diff -Nru delaboratory-0.7/src/vignette.h delaboratory-0.8/src/vignette.h --- delaboratory-0.7/src/vignette.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VIGNETTE_H -#define _DE_VIGNETTE_H - -#include "value.h" -#include "size.h" - -class deEllipse -{ - private: - deValue centerX; - deValue centerY; - deValue radiusX; - deValue radiusY; - public: - deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY); - virtual ~deEllipse(); - - deValue processX(deValue x) const; - deValue processY(deValue y) const; - - bool isValid() const; - -}; - -void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot); -void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse1, deEllipse ellipse2, deValue light, deValue darkness, deValue spot); - -#endif diff -Nru delaboratory-0.7/src/vignette_layer.cc delaboratory-0.8/src/vignette_layer.cc --- delaboratory-0.7/src/vignette_layer.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette_layer.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,288 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "vignette_layer.h" -#include "vignette.h" -#include "project.h" -#include -#include "str.h" -#include "xml.h" -#include "frame_factory.h" -#include "layer_processor.h" - -deVignetteLayer1::deVignetteLayer1(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deVignetteLayer(_colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager, _name, 1) -{ -} - - -deVignetteLayer1::~deVignetteLayer1() -{ -} - -deVignetteLayer2::deVignetteLayer2(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name) -:deVignetteLayer(_colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager, _name, 2) -{ -} - - -deVignetteLayer2::~deVignetteLayer2() -{ -} - -deVignetteLayer::deVignetteLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name, int _vignettes) -:deActionLayer(_name, _colorSpace, _index, _sourceLayer, _layerStack, _channelManager, _viewManager), - vignettes(_vignettes) -{ - lightIndex = registerPropertyValue("light"); - darknessIndex = registerPropertyValue("darkness"); - spotIndex = registerPropertyValue("spot"); - - center1XIndex = registerPropertyValue("center1_x"); - center1YIndex = registerPropertyValue("center1_y"); - radius1XIndex = registerPropertyValue("radius1_x"); - radius1YIndex = registerPropertyValue("radius1_y"); - - if (vignettes == 2) - { - center2XIndex = registerPropertyValue("center2_x"); - center2YIndex = registerPropertyValue("center2_y"); - radius2XIndex = registerPropertyValue("radius2_x"); - radius2YIndex = registerPropertyValue("radius2_y"); - } - - dePropertyValue* radius1X = valueProperties[radius1XIndex]; - dePropertyValue* radius1Y = valueProperties[radius1YIndex]; - dePropertyValue* center1X = valueProperties[center1XIndex]; - dePropertyValue* center1Y = valueProperties[center1YIndex]; - - dePropertyValue* light = valueProperties[lightIndex]; - dePropertyValue* darkness = valueProperties[darknessIndex]; - dePropertyValue* spot = valueProperties[spotIndex]; - - radius1X->setMin(0.01); - radius1X->setMax(1.0); - radius1Y->setMin(0.01); - radius1Y->setMax(1.0); - center1X->setMin(-1); - center1Y->setMin(-1); - - light->setMin(0.0); - light->setMax(1.0); - spot->setMin(0.0); - spot->setMax(2.0); - darkness->setMin(0.0); - darkness->setMax(1.0); - - if (vignettes == 2) - { - dePropertyValue* radius2X = valueProperties[radius2XIndex]; - dePropertyValue* radius2Y = valueProperties[radius2YIndex]; - dePropertyValue* center2X = valueProperties[center2XIndex]; - dePropertyValue* center2Y = valueProperties[center2YIndex]; - radius2X->setMin(0.01); - radius2X->setMax(1.0); - radius2Y->setMin(0.01); - radius2Y->setMax(1.0); - center2X->setMin(-1); - center2Y->setMin(-1); - } - - reset(); - - disableNotLuminance(); -} - -deVignetteLayer::~deVignetteLayer() -{ -} - -deEllipse calcEllipse(deValue radX, deValue radY, deValue cenX, deValue cenY, deValue x1, deValue y1, deValue x2, deValue y2) -{ - deValue w = x2 - x1; - deValue h = y2 - y1; - - deValue rx = radX / w; - deValue ry = radY / h; - - // 0..1 - deValue ccx = (cenX + 1.0) / 2.0; - deValue ccy = (cenY + 1.0) / 2.0; - - deValue cccx = (ccx - x1) / w; - deValue cccy = (ccy - y1) / h; - - // -1..1 - deValue cx = cccx * 2.0 - 1.0; - deValue cy = cccy * 2.0 - 1.0; - - return deEllipse(cx, cy, rx, ry); -} - -bool deVignetteLayer::processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size) -{ - logMessage("deVignetteLayer::processAction i=" + str(i)); - - deValue* destination = channel.getPixels(); - - if (!destination) - { - logMessage("ERROR channel pixels are NULL"); - return false; - } - - deValue x1; - deValue y1; - deValue x2; - deValue y2; - - viewManager.getZoom(x1, y1, x2, y2); - - dePropertyValue* radius1X = valueProperties[radius1XIndex]; - dePropertyValue* radius1Y = valueProperties[radius1YIndex]; - dePropertyValue* center1X = valueProperties[center1XIndex]; - dePropertyValue* center1Y = valueProperties[center1YIndex]; - - dePropertyValue* light = valueProperties[lightIndex]; - dePropertyValue* darkness = valueProperties[darknessIndex]; - dePropertyValue* spot = valueProperties[spotIndex]; - - deEllipse ellipse1 = calcEllipse(radius1X->get(), radius1Y->get(), center1X->get(), center1Y->get(), x1, y1, x2, y2); - - if (vignettes == 2) - { - dePropertyValue* radius2X = valueProperties[radius2XIndex]; - dePropertyValue* radius2Y = valueProperties[radius2YIndex]; - dePropertyValue* center2X = valueProperties[center2XIndex]; - dePropertyValue* center2Y = valueProperties[center2YIndex]; - - deEllipse ellipse2 = calcEllipse(radius2X->get(), radius2Y->get(), center2X->get(), center2Y->get(), x1, y1, x2, y2); - vignetteChannel(destination, size, ellipse1, ellipse2, light->get(), darkness->get(), spot->get()); - } - else - { - vignetteChannel(destination, size, ellipse1, light->get(), darkness->get(), spot->get()); - } - - logMessage("deVignetteLayer::processAction i=" + str(i) + " done"); - - return true; -} - -bool deVignetteLayer::isChannelNeutral(int index) -{ - return false; -} - -void deVignetteLayer::reset() -{ - dePropertyValue* radius1X = valueProperties[radius1XIndex]; - dePropertyValue* radius1Y = valueProperties[radius1YIndex]; - dePropertyValue* center1X = valueProperties[center1XIndex]; - dePropertyValue* center1Y = valueProperties[center1YIndex]; - - dePropertyValue* light = valueProperties[lightIndex]; - dePropertyValue* darkness = valueProperties[darknessIndex]; - dePropertyValue* spot = valueProperties[spotIndex]; - - setBlendMode(deBlendOverlay); - setOpacity(1.0); - - radius1X->set(0.5); - radius1Y->set(0.5); - center1X->set(0.0); - center1Y->set(0.0); - - if (vignettes == 2) - { - dePropertyValue* radius2X = valueProperties[radius2XIndex]; - dePropertyValue* radius2Y = valueProperties[radius2YIndex]; - dePropertyValue* center2X = valueProperties[center2XIndex]; - dePropertyValue* center2Y = valueProperties[center2YIndex]; - - radius2X->set(0.5); - radius2Y->set(0.5); - center2X->set(0.0); - center2Y->set(0.0); - } - - light->set(0.5); - spot->set(1.0); - darkness->set(0.2); -} - -void deVignetteLayer::save(xmlNodePtr root) -{ - saveCommon(root); - saveBlend(root); - saveValueProperties(root); -} - -void deVignetteLayer::load(xmlNodePtr root) -{ - loadBlend(root); - - xmlNodePtr child = root->xmlChildrenNode; - - while (child) - { - loadValueProperties(child); - child = child->next; - } - -} - -bool deVignetteLayer::randomize() -{ -/* - dePropertyValue* radiusX = valueProperties[radiusXIndex]; - dePropertyValue* radiusY = valueProperties[radiusYIndex]; - dePropertyValue* centerX = valueProperties[centerXIndex]; - dePropertyValue* centerY = valueProperties[centerYIndex]; - dePropertyValue* light = valueProperties[lightIndex]; - dePropertyValue* darkness = valueProperties[darknessIndex]; - - deValue r = (deValue) rand() / RAND_MAX; - r *= 0.5; - radiusX->set(r + 0.8); - - deValue r2 = (deValue) rand() / RAND_MAX; - r2 *= 0.5; - radiusY->set(r2 + 0.8); - - deValue r3 = (deValue) rand() / RAND_MAX; - r3 *= 2.0; - centerX->set(r3 - 1.0); - - deValue r4 = (deValue) rand() / RAND_MAX; - r4 *= 2.0; - centerY->set(r4 - 1.0); -*/ - - return true; -} - -bool deVignetteLayer::setCenter(deValue x, deValue y) -{ - dePropertyValue* center1X = valueProperties[center1XIndex]; - dePropertyValue* center1Y = valueProperties[center1YIndex]; - center1X->set(2 * x - 1); - center1Y->set(2 * y - 1); - - return true; -} diff -Nru delaboratory-0.7/src/vignette_layer.h delaboratory-0.8/src/vignette_layer.h --- delaboratory-0.7/src/vignette_layer.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/vignette_layer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_VIGNETTE_LAYER_H -#define _DE_VIGNETTE_LAYER_H - -#include "action_layer.h" -#include "property_value.h" - -class deVignetteLayer:public deActionLayer -{ - private: - int vignettes; - - int radius1XIndex; - int radius1YIndex; - int center1XIndex; - int center1YIndex; - - int radius2XIndex; - int radius2YIndex; - int center2XIndex; - int center2YIndex; - - int lightIndex; - int darknessIndex; - int spotIndex; - - protected: - virtual bool singleChannelProcessing() const {return true;}; - virtual std::string getType() const {return "vignette";}; - - public: - deVignetteLayer(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name, int _vignettes); - virtual ~deVignetteLayer(); - - virtual bool isChannelNeutral(int index); - - virtual bool processAction(int i, const deChannel& sourceChannel, deChannel& channel, deSize size); - - virtual void load(xmlNodePtr root); - virtual void save(xmlNodePtr root); - - virtual std::string getActionName() {return "vign";}; - - void reset(); - - virtual bool randomize(); - - bool setCenter(deValue x, deValue y); - -}; - -class deVignetteLayer1:public deVignetteLayer -{ - public: - deVignetteLayer1(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deVignetteLayer1(); - - virtual std::string getType() const {return "vignette1";}; -}; - -class deVignetteLayer2:public deVignetteLayer -{ - public: - deVignetteLayer2(deColorSpace _colorSpace, int _index, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, const std::string& _name); - virtual ~deVignetteLayer2(); - - virtual std::string getType() const {return "vignette2";}; -}; - -#endif diff -Nru delaboratory-0.7/src/xml.cc delaboratory-0.8/src/xml.cc --- delaboratory-0.7/src/xml.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/xml.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "xml.h" - -void saveChild(xmlNodePtr node, std::string name, std::string value) -{ - xmlChar* _name = BAD_CAST(name.c_str()); - xmlChar* _value = BAD_CAST(value.c_str()); - - xmlNodePtr child = xmlNewChild(node, NULL, _name, NULL); - xmlNodeSetContent(child, _value); -} - -std::string getContent(xmlNodePtr node) -{ - xmlChar* xs = xmlNodeGetContent(node); - std::string s = (char*)(xs); - xmlFree(xs); - return s; -} diff -Nru delaboratory-0.7/src/xml.h delaboratory-0.8/src/xml.h --- delaboratory-0.7/src/xml.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/xml.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_XML_H -#define _DE_XML_H - -#include -#include - -void saveChild(xmlNodePtr node, std::string name, std::string value); -std::string getContent(xmlNodePtr node); - -#endif diff -Nru delaboratory-0.7/src/zoom_manager.cc delaboratory-0.8/src/zoom_manager.cc --- delaboratory-0.7/src/zoom_manager.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/zoom_manager.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "zoom_manager.h" - -deZoomManager::deZoomManager() -{ - selectionMode = false; - fullZoomOut(); -} - -deZoomManager::~deZoomManager() -{ -} - -void deZoomManager::fullZoomOut() -{ - z_x1 = 0; - z_y1 = 0; - z_x2 = 1; - z_y2 = 1; -} - -bool deZoomManager::isInSelectionMode() const -{ - return selectionMode; -} - -void deZoomManager::enableSelectionMode() -{ - selectionMode = true; - s_x1 = 0; - s_x2 = 0; - s_y1 = 0; - s_y2 = 0; -} - -bool deZoomManager::onClick(deValue x, deValue y) -{ - s_x1 = x; - s_x2 = x; - s_y1 = y; - s_y2 = y; - return true; -} - -bool deZoomManager::onMove(deValue x, deValue y) -{ - if (x > 1) - { - x = 1; - } - if (y > 1) - { - y = 1; - } - if (x < s_x1) - { - x = s_x1; - } - if (y < s_y1) - { - y = s_y1; - } - - s_x2 = x; - s_y2 = y; - return true; -} - -bool deZoomManager::onRelease() -{ - if ((s_x1 < s_x2) && (s_y1 < s_y2)) - { - deValue x1 = z_x1 + s_x1 * (z_x2 - z_x1); - deValue x2 = z_x1 + s_x2 * (z_x2 - z_x1); - deValue y1 = z_y1 + s_y1 * (z_y2 - z_y1); - deValue y2 = z_y1 + s_y2 * (z_y2 - z_y1); - z_x1 = x1; - z_x2 = x2; - z_y1 = y1; - z_y2 = y2; - } - else - { - fullZoomOut(); - } - - selectionMode = false; - return true; -} - -void deZoomManager::getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) -{ - _x1 = s_x1; - _y1 = s_y1; - _x2 = s_x2; - _y2 = s_y2; -} - -void deZoomManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) -{ - _x1 = z_x1; - _y1 = z_y1; - _x2 = z_x2; - _y2 = z_y2; -} - -bool deZoomManager::isZoomed() const -{ - if (z_x1 > 0.0) - { - return true; - } - - if (z_y1 > 0.0) - { - return true; - } - - if (z_x2 < 1.0) - { - return true; - } - - if (z_y2 < 1.0) - { - return true; - } - - return false; -} diff -Nru delaboratory-0.7/src/zoom_manager.h delaboratory-0.8/src/zoom_manager.h --- delaboratory-0.7/src/zoom_manager.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/zoom_manager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_ZOOM_MANAGER_H -#define _DE_ZOOM_MANAGER_H - -#include "value.h" - -class deZoomManager -{ - private: - bool selectionMode; - - deValue s_x1; - deValue s_y1; - deValue s_x2; - deValue s_y2; - - deValue z_x1; - deValue z_y1; - deValue z_x2; - deValue z_y2; - - public: - deZoomManager(); - virtual ~deZoomManager(); - - bool isInSelectionMode() const; - void enableSelectionMode(); - - bool onClick(deValue x, deValue y); - bool onMove(deValue x, deValue y); - bool onRelease(); - - void getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); - void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); - - void fullZoomOut(); - - bool isZoomed() const; -}; - -#endif diff -Nru delaboratory-0.7/src/zoom_panel.cc delaboratory-0.8/src/zoom_panel.cc --- delaboratory-0.7/src/zoom_panel.cc 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/zoom_panel.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "zoom_panel.h" -#include "zoom_manager.h" -#include "image_area_panel.h" - -deZoomPanel::deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager) -:wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), zoomManager(_zoomManager) -{ - imageAreaPanel = NULL; - - wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("zoom")); - SetSizer(sizerS); - - zoomIn = new wxButton(this, wxID_ANY, _T("select"), wxDefaultPosition, wxSize(60,25)); - sizerS->Add(zoomIn); - - zoomOut = new wxButton(this, wxID_ANY, _T("full"), wxDefaultPosition, wxSize(60,25)); - sizerS->Add(zoomOut); - - Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deZoomPanel::click)); - - updateButtons(); - -} - -void deZoomPanel::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) -{ - imageAreaPanel = _imageAreaPanel; -} - -deZoomPanel::~deZoomPanel() -{ -} - -void deZoomPanel::click(wxCommandEvent &event) -{ - int id = event.GetId(); - - if (zoomIn->GetId() == id) - { - zoomManager.enableSelectionMode(); - } - - if (zoomOut->GetId() == id) - { - zoomManager.fullZoomOut(); - if (imageAreaPanel) - { - imageAreaPanel->updateSize(true); - } - } - - updateButtons(); - -} - -void deZoomPanel::updateButtons() -{ - if (zoomManager.isInSelectionMode()) - { - zoomIn->Disable(); - zoomOut->Disable(); - return; - } - - if (zoomManager.isZoomed()) - { - //zoomIn->Disable(); - zoomIn->Enable(); - zoomOut->Enable(); - } - else - { - zoomIn->Enable(); - zoomOut->Disable(); - } - -} diff -Nru delaboratory-0.7/src/zoom_panel.h delaboratory-0.8/src/zoom_panel.h --- delaboratory-0.7/src/zoom_panel.h 2012-04-10 13:42:29.000000000 +0000 +++ delaboratory-0.8/src/zoom_panel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - delaboratory - color correction utility - Copyright (C) 2011 Jacek Poplawski - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _DE_ZOOM_PANEL_H -#define _DE_ZOOM_PANEL_H - -#include -class deZoomManager; -class deImageAreaPanel; - -class deZoomPanel:public wxPanel -{ - private: - deZoomManager& zoomManager; - deImageAreaPanel* imageAreaPanel; - - wxButton* zoomIn; - wxButton* zoomOut; - - void click(wxCommandEvent &event); - - - public: - deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager); - virtual ~deZoomPanel(); - - void updateButtons(); - - void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); -}; - -#endif