Skip to content

Commit 12fc165

Browse files
committed
crop custom fixed.
1 parent 3645abe commit 12fc165

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

relight/imagecropper.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ void ImageCropper::setProportion(const QSizeF& _proportion) {
5151
emit areaChanged(croppedRect());
5252
}
5353

54-
void ImageCropper::setProportionFixed(const bool _isFixed)
55-
{
56-
if (isProportionFixed != _isFixed) {
57-
isProportionFixed = _isFixed;
58-
setProportion(proportion);
59-
}
54+
void ImageCropper::setProportionFixed(const bool _isFixed) {
55+
isProportionFixed = _isFixed;
6056
}
6157

6258
//returns cropped rect in image ccords

relightlab/cropframe.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ CropFrame::CropFrame(QWidget *parent): QFrame(parent) {
7373
aspect_layout->setSpacing(10);
7474

7575
aspect_combo = new QComboBox;
76-
aspect_combo->addItem("None"); //0
77-
aspect_combo->addItem("Custom"); //1
78-
aspect_combo->addItem("Square"); //2
79-
aspect_combo->addItem("4:3 Photo"); //3
76+
aspect_combo->addItem("None"); //0
77+
aspect_combo->addItem("Custom"); //1
78+
aspect_combo->addItem("Square"); //2
79+
aspect_combo->addItem("4:3 Photo"); //3
8080
aspect_combo->addItem("3:2 Postcard"); //4
8181
aspect_combo->addItem("16:10 Widescreen"); //5
8282
aspect_combo->addItem("16:9 Widescreen"); //6
@@ -142,17 +142,15 @@ void CropFrame::setAspectRatio() {
142142
int aspect = aspect_combo->currentIndex();
143143
double aspects[9][2] = { {1, 1}, {1, 1}, {1, 1}, {4, 3} , {3, 2}, {16, 10}, {16, 9}, {2, 3}, {3, 4} };
144144

145-
switch(aspect) {
146-
case 0: return; //none
147-
case 1:
148-
aspects[1][0] = aspect_width->value();
149-
aspects[1][1] = aspect_height->value();
150-
break;
145+
if(aspect == 1) { //custom
146+
aspects[aspect][0] = aspect_width->value();
147+
aspects[aspect][1] = aspect_height->value();
151148
}
152-
153149
double *s = aspects[aspect];
154-
cropper->setProportion(QSizeF(s[0], s[1]));
155150
cropper->setProportionFixed(aspect > 0);
151+
if(aspect != 0)
152+
cropper->setProportion(QSizeF(s[0], s[1]));
153+
156154
}
157155

158156
void CropFrame::setArea(QRect rect) {

0 commit comments

Comments
 (0)