Added grid as crop guid for lens and perspective correction; see issue #387, also for further ideas
This commit is contained in:
parent
8b16345d60
commit
024fdb29ce
@ -594,6 +594,7 @@ TP_COLORSHIFT_GREENMAGENTA;Green-Magenta
|
||||
TP_COLORSHIFT_LABEL;Color Shift
|
||||
TP_CROP_DPI;DPI=
|
||||
TP_CROP_FIXRATIO;Fix Ratio:
|
||||
TP_CROP_GTGRID;Grid
|
||||
TP_CROP_GTDIAGONALS;Rule of diagonals
|
||||
TP_CROP_GTHARMMEANS1;Harmonic means 1
|
||||
TP_CROP_GTHARMMEANS2;Harmonic means 2
|
||||
|
@ -145,6 +145,7 @@ Crop::Crop () {
|
||||
guide->append_text (M("TP_CROP_GTHARMMEANS2"));
|
||||
guide->append_text (M("TP_CROP_GTHARMMEANS3"));
|
||||
guide->append_text (M("TP_CROP_GTHARMMEANS4"));
|
||||
guide->append_text (M("TP_CROP_GTGRID"));
|
||||
guide->set_active (0);
|
||||
|
||||
w->set_range (0, maxw);
|
||||
@ -249,6 +250,8 @@ void Crop::read (const ProcParams* pp, const ParamsEdited* pedited) {
|
||||
guide->set_active (5);
|
||||
else if (pp->crop.guide == "Harmonic means 4")
|
||||
guide->set_active (6);
|
||||
else if (pp->crop.guide == "Grid")
|
||||
guide->set_active (7);
|
||||
|
||||
x->set_value (pp->crop.x);
|
||||
y->set_value (pp->crop.y);
|
||||
@ -334,6 +337,8 @@ void Crop::write (ProcParams* pp, ParamsEdited* pedited) {
|
||||
pp->crop.guide = "Harmonic means 3";
|
||||
else if (guide->get_active_row_number()==6)
|
||||
pp->crop.guide = "Harmonic means 4";
|
||||
else if (guide->get_active_row_number()==7)
|
||||
pp->crop.guide = "Grid";
|
||||
|
||||
if (pedited) {
|
||||
pedited->crop.enabled = !enabled->get_inconsistent();
|
||||
|
@ -1,7 +1,6 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -65,7 +64,7 @@ Glib::ustring getExtension (const Glib::ustring& filename) {
|
||||
|
||||
void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int imh, int startx, int starty, double scale, const rtengine::procparams::CropParams& cparams) {
|
||||
|
||||
cr->set_line_width (1.0);
|
||||
cr->set_line_width (0.7);
|
||||
cr->rectangle (imx+0.5, imy+0.5, imw, imh);
|
||||
cr->clip ();
|
||||
|
||||
@ -136,11 +135,30 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
|
||||
else if (cparams.guide=="Harmonic means 4") {
|
||||
horiz_ratios.push_back (0.618);
|
||||
vert_ratios.push_back (0.618);
|
||||
}
|
||||
for (int i=0; i<vert_ratios.size(); i++) {
|
||||
}
|
||||
else if (cparams.guide=="Grid") {
|
||||
// To have even distribution, normalize it a bit
|
||||
const int longSideNumLines=10;
|
||||
|
||||
int w=rectx2-rectx1, h=recty2-recty1, shortSideNumLines;
|
||||
if (w>longSideNumLines && h>longSideNumLines) {
|
||||
if (w>h) {
|
||||
for (int i=1;i<longSideNumLines;i++) vert_ratios.push_back ((double)i/longSideNumLines);
|
||||
|
||||
shortSideNumLines=(int)round(h*(double)longSideNumLines/w);
|
||||
for (int i=1;i<shortSideNumLines;i++) horiz_ratios.push_back ((double)i/shortSideNumLines);
|
||||
} else {
|
||||
for (int i=1;i<longSideNumLines;i++) horiz_ratios.push_back ((double)i/longSideNumLines);
|
||||
|
||||
shortSideNumLines=(int)round(w*(double)longSideNumLines/h);
|
||||
for (int i=1;i<shortSideNumLines;i++) vert_ratios.push_back ((double)i/shortSideNumLines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Horizontals
|
||||
for (int i=0; i<horiz_ratios.size(); i++) {
|
||||
cr->set_source_rgb (1.0, 1.0, 1.0);
|
||||
cr->move_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty1);
|
||||
cr->line_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty2);
|
||||
cr->move_to (rectx1, recty1 + (recty2-recty1) * horiz_ratios[i]);
|
||||
cr->line_to (rectx2, recty1 + (recty2-recty1) * horiz_ratios[i]);
|
||||
cr->stroke ();
|
||||
@ -148,13 +166,27 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
|
||||
std::valarray<double> ds (1);
|
||||
ds[0] = 4;
|
||||
cr->set_dash (ds, 0);
|
||||
cr->move_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty1);
|
||||
cr->line_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty2);
|
||||
cr->move_to (rectx1, recty1 + (recty2-recty1) * horiz_ratios[i]);
|
||||
cr->line_to (rectx2, recty1 + (recty2-recty1) * horiz_ratios[i]);
|
||||
cr->stroke ();
|
||||
ds.resize (0);
|
||||
cr->set_dash (ds, 0);
|
||||
}
|
||||
// Verticals
|
||||
for (int i=0; i<vert_ratios.size(); i++) {
|
||||
cr->set_source_rgb (1.0, 1.0, 1.0);
|
||||
cr->move_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty1);
|
||||
cr->line_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty2);
|
||||
cr->stroke ();
|
||||
cr->set_source_rgb (0.0, 0.0, 0.0);
|
||||
std::valarray<double> ds (1);
|
||||
ds[0] = 4;
|
||||
cr->set_dash (ds, 0);
|
||||
cr->move_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty1);
|
||||
cr->line_to (rectx1 + (rectx2-rectx1) * vert_ratios[i], recty2);
|
||||
cr->stroke ();
|
||||
ds.resize (0);
|
||||
cr->set_dash (ds, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user