Permalink
Browse files

Using SmoothTransformation instead of FastTransformation

  • Loading branch information...
vookimedlo committed Dec 8, 2017
1 parent fe6e603 commit ac2131e50f9dbbd64ceb486c514be34168bf47be
@@ -31,7 +31,6 @@ BraceWrapping:
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunctionBody: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
@@ -14,7 +14,7 @@ compiler:
env:
matrix:
- QT=59 BREW=@5.9 PPA=beineri/opt-qt592-trusty
- QT=59 BREW=@5.9 PPA=beineri/opt-qt593-trusty
before_install:
- '[ "$TRAVIS_OS_NAME" != linux ] || sudo add-apt-repository -y ppa:$PPA'
@@ -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
@@ -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>
@@ -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\ |
@@ -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>
@@ -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);
@@ -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
@@ -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);

0 comments on commit ac2131e

Please sign in to comment.