Commit 604cf2af authored by Mike Kremer's avatar Mike Kremer

Corrected keep aspect ratio behavior when capturing screenshots.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9913 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bee05ee8
...@@ -2073,12 +2073,11 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha) { ...@@ -2073,12 +2073,11 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha) {
// Turn alpha on if demanded // Turn alpha on if demanded
ACG::Vec4f backColorBak; ACG::Vec4f backColorBak;
ACG::Vec4f newBack; ACG::Vec4f newBack;
if(_alpha) {
backColorBak = properties()->backgroundColor(); backColorBak = properties()->backgroundColor();
newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], 0.0f); newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], (_alpha ? 0.0f : 1.0f));
properties()->backgroundColor(newBack); properties()->backgroundColor(newBack);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL(); paintGL();
......
...@@ -51,7 +51,8 @@ ...@@ -51,7 +51,8 @@
SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, int _h, QWidget *parent) SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, int _h, QWidget *parent)
: QDialog(parent), : QDialog(parent),
captureViewers_(_captureViewers), captureViewers_(_captureViewers),
aspect_(_w / _h) aspect_((double)_w / (double)_h),
blockSpinBox_(false)
{ {
setupUi(this); setupUi(this);
...@@ -61,6 +62,7 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i ...@@ -61,6 +62,7 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i
// in viewer snapshot mode // in viewer snapshot mode
resButton->setDisabled(captureViewers_); resButton->setDisabled(captureViewers_);
keepAspect->setDisabled(!captureViewers_); keepAspect->setDisabled(!captureViewers_);
transparent->setDisabled(!captureViewers_);
snapWidth->setValue(_w); snapWidth->setValue(_w);
snapHeight->setValue(_h); snapHeight->setValue(_h);
...@@ -76,15 +78,23 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i ...@@ -76,15 +78,23 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i
void SnapshotDialog::snapWidthChanged(int _w) { void SnapshotDialog::snapWidthChanged(int _w) {
if(blockSpinBox_) return;
if(keepAspect->isChecked()) { if(keepAspect->isChecked()) {
snapHeight->setValue((int)(_w / aspect_)); blockSpinBox_ = true;
snapHeight->setValue((int)((double)_w / aspect_));
blockSpinBox_ = false;
} }
} }
void SnapshotDialog::snapHeightChanged(int _h) { void SnapshotDialog::snapHeightChanged(int _h) {
if(blockSpinBox_) return;
if(keepAspect->isChecked()) { if(keepAspect->isChecked()) {
snapWidth->setValue((int)(_h * aspect_)); blockSpinBox_ = true;
snapWidth->setValue((int)((double)_h * aspect_));
blockSpinBox_ = false;
} }
} }
......
...@@ -53,6 +53,8 @@ class SnapshotDialog : public QDialog, public Ui::SnapshotDialog ...@@ -53,6 +53,8 @@ class SnapshotDialog : public QDialog, public Ui::SnapshotDialog
private: private:
bool captureViewers_; bool captureViewers_;
double aspect_; double aspect_;
bool blockSpinBox_;
private slots: private slots:
void slotOk(); void slotOk();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment