216e1a9f71
Commit the original Caesium 1.7.0 codebase with some adjustment. You can also get the original source at: https://sourceforge.net/projects/caesium/files/1.7.0/ Since the file names listed in the Qt resource file have encoding issue which can cause compile failure, these files get removed. Adjustments: + .gitignore M icons.qrc - *.pro.user(.*) - icons/language/*.png
35 lines
924 B
C++
35 lines
924 B
C++
#include "imageresize.h"
|
|
#include <QDebug>
|
|
|
|
ImageResize::ImageResize()
|
|
{
|
|
}
|
|
|
|
QImage ImageResize::fixedResize(QImage image, int width, int height, bool keepRatio, bool doNotEnlarge)
|
|
{
|
|
if ((image.width() > width) || (image.height() > height) || (doNotEnlarge == false))
|
|
{
|
|
if (width < 0 || height < 0)
|
|
{
|
|
width = image.width();
|
|
height = image.height();
|
|
}
|
|
if (keepRatio)
|
|
{
|
|
image = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
}
|
|
else
|
|
{
|
|
image = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
}
|
|
}
|
|
return image;
|
|
}
|
|
|
|
QImage ImageResize::pergentageResize(QImage image, int width, int height)
|
|
{
|
|
image = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
|
return image;
|
|
}
|