Skip to content

Commit

Permalink
Using SmoothTransformation instead of FastTransformation
Browse files Browse the repository at this point in the history
  • Loading branch information
vookimedlo committed Dec 8, 2017
1 parent fe6e603 commit ac2131e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ BraceWrapping:
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunctionBody: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ compiler:

env:
matrix:
- QT=59 [email protected] PPA=beineri/opt-qt592-trusty
- QT=59 [email protected] PPA=beineri/opt-qt593-trusty

before_install:
- '[ "$TRAVIS_OS_NAME" != linux ] || sudo add-apt-repository -y ppa:$PPA'
Expand Down
2 changes: 1 addition & 1 deletion build/cmake/mac/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

target=VookiImageViewer.app/Contents/PlugIns/imageformats/

~/Qt/5.9.3/clang_64/bin/macdeployqt build/VookiImageViewer.app -always-overwrite
~/Qt/5.10.0/clang_64/bin/macdeployqt build/VookiImageViewer.app -always-overwrite

cd build
cp -f libvooki_kimg_pcx.so libvooki_kimg_pic.so libvooki_kimg_psd.so libvooki_kimg_ras.so libvooki_kimg_rgb.so libvooki_kimg_tga.so libvooki_kimg_xcf.so $target
Expand Down
1 change: 1 addition & 0 deletions build/cmake/mac/support/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string>ppm</string>
<string>xbm</string>
<string>xpm</string>
<string>tif</string>
<string>tiff</string>
<string>webp</string>
<string>tga</string>
Expand Down
2 changes: 1 addition & 1 deletion build/cmake/windows/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Expected environment variables

| Environment Variable | Value |
|-----------------------|-------------------------------|
| QTDIR | c:\Qt\5.9.3\msvc2017_64 |
| QTDIR | c:\Qt\5.10.0\msvc2017_64 |
| Qt5Core_DIR | %QTDIR%\lib\cmake\Qt5Core\ |
| Qt5Gui_DIR | %QTDIR%\lib\cmake\Qt5Gui\ |
| Qt5Widgets_DIR | %QTDIR%\lib\cmake\Qt5Widgets\ |
Expand Down
20 changes: 13 additions & 7 deletions src/ui/ImageAreaWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
#include <QColor>
#include <QDebug>
#include <QImage>
#include <QImageReader>
#include <QPaintEvent>
#include <QPainter>
#include <QRect>
Expand Down Expand Up @@ -58,8 +59,13 @@ void ImageAreaWidget::drawBorder(const bool draw, const QColor &color)

bool ImageAreaWidget::showImage(const QString &fileName)
{
if (!m_originalImage.load(fileName))
QImageReader reader(fileName);
reader.setQuality(100);
m_originalImage = reader.read();

if (m_originalImage.isNull())
return false;

m_flipHorizontally = m_flipVertically = false;
m_imageOffsetX = m_imageOffsetY = 0;
m_rotateIndex.reset(0);
Expand Down Expand Up @@ -321,7 +327,7 @@ void ImageAreaWidget::transformImage()
{
QTransform transform;
const QTransform trans = transform.rotate(m_rotateIndex * 90);
QImage rotatedImage = m_originalImage.transformed(trans);
QImage rotatedImage = m_originalImage.transformed(trans, Qt::SmoothTransformation);
QImage scaledImage;

// It seems that Qt implementation has swapped the meaning of the vertical and horizontal flip
Expand All @@ -331,25 +337,25 @@ void ImageAreaWidget::transformImage()
{
QTransform transform;
QTransform trans = transform.rotate(180, Qt::XAxis);
rotatedImage = rotatedImage.transformed(trans);
rotatedImage = rotatedImage.transformed(trans, Qt::SmoothTransformation);
}

if (m_flipVertically)
{
QTransform transform;
QTransform trans = transform.rotate(180, Qt::YAxis);
rotatedImage = rotatedImage.transformed(trans);
rotatedImage = rotatedImage.transformed(trans, Qt::SmoothTransformation);
}

if (m_isFitToWindow)
{
m_imageOffsetX = m_imageOffsetY = 0;
scaledImage = rotatedImage.scaledToWidth(width());
scaledImage = rotatedImage.scaledToWidth(width(), Qt::SmoothTransformation);
if (scaledImage.height() > height())
scaledImage = rotatedImage.scaledToHeight(height());
scaledImage = rotatedImage.scaledToHeight(height(), Qt::SmoothTransformation);
}
else
scaledImage = rotatedImage.scaledToWidth(rotatedImage.width() * m_scaleFactor);
scaledImage = rotatedImage.scaledToWidth(rotatedImage.width() * m_scaleFactor, Qt::SmoothTransformation);

QSize newSize = scaledImage.size().expandedTo(size());
QImage newImage(newSize, QImage::Format_RGB32);
Expand Down

0 comments on commit ac2131e

Please sign in to comment.