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) {
// Turn alpha on if demanded
ACG::Vec4f backColorBak;
ACG::Vec4f newBack;
if(_alpha) {
backColorBak = properties()->backgroundColor();
newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], 0.0f);
properties()->backgroundColor(newBack);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
backColorBak = properties()->backgroundColor();
newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], (_alpha ? 0.0f : 1.0f));
properties()->backgroundColor(newBack);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL();
......
......@@ -51,7 +51,8 @@
SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, int _h, QWidget *parent)
: QDialog(parent),
captureViewers_(_captureViewers),
aspect_(_w / _h)
aspect_((double)_w / (double)_h),
blockSpinBox_(false)
{
setupUi(this);
......@@ -61,6 +62,7 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i
// in viewer snapshot mode
resButton->setDisabled(captureViewers_);
keepAspect->setDisabled(!captureViewers_);
transparent->setDisabled(!captureViewers_);
snapWidth->setValue(_w);
snapHeight->setValue(_h);
......@@ -76,15 +78,23 @@ SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, int _w, i
void SnapshotDialog::snapWidthChanged(int _w) {
if(blockSpinBox_) return;
if(keepAspect->isChecked()) {
snapHeight->setValue((int)(_w / aspect_));
blockSpinBox_ = true;
snapHeight->setValue((int)((double)_w / aspect_));
blockSpinBox_ = false;
}
}
void SnapshotDialog::snapHeightChanged(int _h) {
if(blockSpinBox_) return;
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
private:
bool captureViewers_;
double aspect_;
bool blockSpinBox_;
private slots:
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